Hi Olaf,

For soon to be a decade I'm fighting with this question... !!!
It's not a silly one... it's quite a tricky one...

As many have noticed all INTEGER types (SMALLINT, MEDIUMINT, INT,
BIGINT) have a "LENGTH"... by all means I can assure you that it has
nothing to do with the maximum number you can store in a column or the
size on the disk !

The only situation, known to me, when the "length" has a value is with
the ZEROFILL atribute.

Let's say you have 2 numbers to be stored:
   4567
456789

If you insert then in a table in a column with the definition:
INT(6) NOT NULL DEFAULT 0
You will get the same values and any value will take 4 bytes on the disk.

If you insert then in a table in a column with the definition:
INT(6) ZEROFILL NOT NULL DEFAULT 0
You will get :
004567
456789
as values and any value will also take 4 bytes on the disk.

The only notable difference... as you can see... is in prepending 0 to
the number to reach the desired "length"... if the number is greater
than or equal to the declared "length" it has no effect.

So AFAIK this is the purpose of the "length"...in INTEGER columns.

-- -- -- -- -- -- -- -- -- -- -- -- --
Gabriel PREDA
Senior Web Developer

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to