Does anyone one know when is the best time to use each one of the above. I'm confused.

If I can do INT(10) then why would I use BIGINT(10), I'm confused by the whole thing.

Type Bytes Minimum Value Maximum Value
(Signed/Unsigned) (Signed/Unsigned)
TINYINT 1 -128 127
0 255
SMALLINT 2 -32768 32767
0 65535
MEDIUMINT 3 -8388608 8388607
0 16777215
INT 4 -2147483648 2147483,647
0 4294967295
BIGINT 8 -9223372036854775808 9223372036854775807
0 18446744073709551615

The problem I have is I see databases with BIGINT(10) INT(10) and it confuses me why people choose one way or the others it seems like if you choose INT then you would always want INT(10) not INT(5).

In other words if your going to use INT then why not use it's max value or maybe I'm missing what is meant by INT(5)?

    the parenthetical numbers only relate to the display width of integer data types, not the range or storage requirements for each data type. read up on Numeric Types. generally you should use the smallest data type you need as this will reduce the storage required.

      then again storage space is cheap so always use BIGINT and you will never be in trouble if the project grows unexpectedly.

        Then again, CPUs are still mostly 32-bit, so an INT is just the right size for the processor. There's nothing stopping you from altering the type later should it be necessary (or you get a 64-bit server).

          Write a Reply...