Link to home
Start Free TrialLog in
Avatar of G00fy
G00fy

asked on

integer-questions

http://dev.mysql.com/doc/mysql/en/Numeric_type_overview.html

In this overview you can see for example:
TINYINT = 0 - 255 (unsigned)
SMALLINT = 0 - 65535 (unsigned)
MEDIUMINT = 0 - 16777215 (unsigned)

Now in my database (MySQL) I use for example
SMALLINT(3) for numbers from 0 -> 999. But lately I saw I could use SMALLINT(1) as well for that...

Can someone clarify this?
Avatar of AlanJDM
AlanJDM

"But lately I saw I could use SMALLINT(1) as well for that"

Where did you see that?


Alan

Avatar of G00fy

ASKER

In my database... I was using values of lets say '2300', normally I would use like SMALLINT(4) for that, but lately I saw that when I use SMALLINT(1) as well...
I will be curious to see if anyone has any insight to this as well. I am not sure of the inner workings of MySQL but some logic and some basic math skills would tell you that 2300 can't be stored in one byte. My guess would be that the '1' doesn't represent what it appears to represent.



Alan
Avatar of G00fy

ASKER

My best guess is that the 1 means like (smallint = 2 bytes), so that it would mean 2bytes x 1
And then it is correct. If this is true however, then I am very stupid as all my indexes on my database are like INT(10) :-)
ASKER CERTIFIED SOLUTION
Avatar of half_life_fool
half_life_fool

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial