Hi,

Jindo Soul writes:
 > Hello,
 > 
 > I've never understood the difference between TinyInt(1) and TinyInt(4).  For
 > CHAR data
 > type, I know the number enclosed in the bracket means the length of the CHAR
 > type.
 > But how does TinyInt(1) differ from TinyInt(4)?  I tried to experiment with
 > different numbers
 > yet could not feel any difference:
 > 
 > tinyint (1) falls between {-127, 127}
 > tinyint (4) falls between {-127, 127}

-128, actually :)

Anyway, tinyint can store 1 byte, which is 255. The display size does
not restrict this (same goes for all integer types). The display size
with integers is used mostly for 2 purposes, it's coding
documentation; putting tinyint(1) to a table definition tells people
that only numbers 0-9 should be inserted, the table was not designed
to have other values.

Another thing is that you can use it with attribute ZEROFILL.
ZEROFILL will fill numbers that are less than the display size with
zeroes in front of them. For example TINYINT(3) with ZEROFILL, insert
value 4 and you will get '004' in there.

 > MySQL doc says: TINYINT(M) where M Indicates the maximum display size. The
 > maximum
 > legal display size is 255.   What exactly does "display size" mean?  I can't
 > tell any difference
 > in SELECT output.  TINYINT(1) and TINYINT(4) gives the exact same output.
 > 
 > Any ideas?
 > 
 > Jindo

Regards,

- Jani

For technical support contracts, visit https://order.mysql.com/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Mr. Jani Tolonen <[EMAIL PROTECTED]>
 / /|_/ / // /\ \/ /_/ / /__   MySQL AB, Full-Time Developer
/_/  /_/\_, /___/\___\_\___/   Helsinki, Finland
       <___/   www.mysql.com

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to