Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How does the Length option for a field help.

Status
Not open for further replies.

ApJ

Technical User
Nov 16, 2001
8
0
0
DK
When creating the fields for a table in "MySQL 3.23.49-nt", using "phpMyAdmin 2.2.5", the field have an option called "Length/Values".

I understand that this option can be used to specify how many characters the value of the current field may have: e.g. an UNSIGNED INT with Length=2 would allow the numbers 0->99 to be stored (right?).

To me it seems quite obviouse that limmiting the maximum length of a field should reduce the recources used by the computer when working with the database, but is this correct?

If not, why else limmit the length?

I know this probably is basic stuff, but I couldn't find documentation on this elsewhere, so plaese help [sadeyes].

Thank you in advance
ApJ :)
 
Thanks for responding KarveR :)

What I found this time (and have missed the other 2 times I have been looking in that file) was:
------
With col_name(length) syntax, you can specify an index that uses only a part of a CHAR or VARCHAR column. This can make the index file much smaller.
------

Maybe I should hit myself for asking even more stupid than before... but in my case I'm not going to use the "index" setting for the fields i'm concerned about.

Put in a short way:
I was wondering if the performance of the database would increase if I defined as small a "length" as possible for my non-indexed fields.

I just need to be sure before saying it to the exam.

ApJ

(someone: duh, how is he going to an exam, without knowing this stuff)
 
As I understand it, CHAR is a fixed lenght field which will use all space allocated in the "length" field regardless.
I.e 255 length, contains letter A, all 255 chars used , filled with whhitespace.

VARCHAR if assigned 255 character lenght will actually only use the number of characters stored in it.
as per example above, if only the letter A is contained, the max use of the field will be 1 character. ***************************************
Party on, dudes!
[cannon]
 
Thanks for the explanation... those manuals isn't always easy to get a grip of.
(Seen from my point of view.)

ApJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top