Old 20-02-2007, 12:41   #1 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,340
Stupid SQL Question

Are TINYINT(3), INT(3), SMALLINT(3) all the same?

My feeble mind is having trouble with the "length" thing. Am I correct in thinking that it means the number of digits - assuming UNSIGNED: (2) would be 0-99, (3) would be 0-999.

That right?
  Reply With Quote
Old 20-02-2007, 12:47   #2 (permalink)
dtrenz
blam blam
 
dtrenz's Avatar
 
Join Date: Aug 2006
Location: ann arbor, mi usa
Posts: 527
yes, 3 equals length of digits.
and yes, i believe they are all the same (some deprecated), much like text and blob or bool and boolean.
  Reply With Quote
Old 20-02-2007, 12:49   #3 (permalink)
2Dfruit
Biscuit
 
2Dfruit's Avatar
 
Join Date: Jun 2006
Location: Ireland
Posts: 973
i also think it has something to do with the amount of decimals it can handle...i think
  Reply With Quote
Old 20-02-2007, 12:51   #4 (permalink)
paulanthony
mingin dawg baitch
 
paulanthony's Avatar
 
Join Date: Apr 2004
Location: Belfast
Posts: 1,035
Send a message via MSN to paulanthony
bigint

Integer (whole number) data from -2^63 (-9,223,372,036,854,775,808) through 2^63-1 (9,223,372,036,854,775,807). Storage size is 8 bytes.

int

Integer (whole number) data from -2^31 (-2,147,483,648) through 2^31 - 1 (2,147,483,647). Storage size is 4 bytes. The SQL-92 synonym for int is integer.

smallint

Integer data from -2^15 (-32,768) through 2^15 - 1 (32,767). Storage size is 2 bytes.

tinyint

Integer data from 0 through 255. Storage size is 1 byte.
__________________
  Reply With Quote
Old 20-02-2007, 13:14   #5 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,340
So, the only difference between INT(3) UNSIGNED, and SMALLINT(3) UNSIGNED would be the number of bytes it takes up, right?

Both would be 0-999.
  Reply With Quote
Old 21-02-2007, 04:15   #6 (permalink)
funkyprem
For all your goober needs
 
funkyprem's Avatar
 
Join Date: Dec 2004
Location: Coventry, UK
Posts: 1,531
Quote:
Originally Posted by pgo
Both would be 0-999.
no mate, in paulantonys post the number in brackets is the range of numbers it can store. so a tiny int can't store a value of 257 and a smallint can't store 40,000 as they're both outside of thier respective ranges.
__________________
Time is really the only capital that any human being has, and the one thing that he can’t afford to lose. - Thomas Edison

prem ghinde
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8