# tinyint, smallint, mediumint, int, bigint ??????

• Dec 11, 2000, 11:39
Jppr
Hi,

I recently asked some table descriptions of devshed.com's database. In "article" and "articlePage", I found that authorID is an int(6) where articleID is int(11). Then
articlePageNumber is smallint(11).

First of all, what is the difference between those types of int. In the manual I found:

TINYINT[(M)] [UNSIGNED] [ZEROFILL]
A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
SMALLINT[(M)] [UNSIGNED] [ZEROFILL]
A small integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535.
MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]
A medium-size integer. The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215.
INT[(M)] [UNSIGNED] [ZEROFILL]
A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.

So if I understand correctly, it is just the size the integer could take.
But, articleID is int (unsigned) so they can have more than 4'000'000'000 articles. Why do they think so big? And why do they use smallint for articleID. Does it have special meanings or something?

Secondly, what does that 11 and 6 between the parentheses mean? I don't get it. If I understand the manual correctly, it's the max number chars. But 11 chars in an integer is quite big no? A billion would fit in it!

Thomas
• Dec 11, 2000, 13:51
Bartimeus
You are correct in your assumption. The number is the size of the int. So a int(11) would fit 11 digits.

The different forms of ints have no other meaning then the limited number that may be stored in them. A tinyint can not contain as large a number as a int. That is obvious. Now why use a tinyint? Well it takes up smaler place in memory. So use a "smaler" int form then int if you know that your var will keep a limited number.

Hope this help.