[advanced search]
Results from the most recent live auction are here.
22 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 01-22-2007, 08:14 AM   · #1
abc123ben
NamePros Regular
 
Trader Rating: (15)
Join Date: Aug 2005
Posts: 583
NP$: 37.15 (Donate)
abc123ben has a spectacular aura aboutabc123ben has a spectacular aura aboutabc123ben has a spectacular aura about
MySQL 'INT' Question

Okay, I have a simple question, I'm sure what I am think is correct, but I just quickly need clarification.

For instance:

INT(2) UNSIGNED

This will allow numbers up to 99 to be displayed correct?

So for instance:

INT(4) UNSIGNED

This will allow numbers up to 9999 to be displayed correct?

So last but not least; if all is correct:

INT(2)

Should allow numbers from -9999 and 99 to be displayed correct?

Sorry to be a pain, but needs those questions answered.


Please register or log-in into NamePros to hide ads
abc123ben is offline   Reply With Quote
Old 01-22-2007, 08:56 AM   · #2
eagle12
NamePros Member
 
Location: Ontario, Canada
Trader Rating: (1)
Join Date: Nov 2003
Posts: 79
NP$: 19.70 (Donate)
eagle12 is on a distinguished road
I believe that the size you enter doesn't limit the maximum number of integers viewed but the minimum number of integers.

ex.

If you use it in conjunction with zerofill then you have an int(4) and you input the number 12, the record will show 0012. But if you enter the number 123456, you will see 123456 in your record.
eagle12 is offline   Reply With Quote
Old 01-22-2007, 09:00 AM   · #3
TwistMyArm
NamePros Member
 
Trader Rating: (0)
Join Date: May 2006
Posts: 159
NP$: 81.00 (Donate)
TwistMyArm is on a distinguished road
According to http://dev.mysql.com/doc/refman/5.0...e-overview.html the number in brackets after the type does not affect INTEGER types (it only affects the display width). It does, however, seem to have an affect on floating / fixed point types (non-integers).

Really, I can only suggest you look at that link and decide which value 'range' you want. Because of the way integers / numbers are stored, you don't really have 'arbitrary' limits like you ones you are talking about: the limits are all to do with the number of bits that are stored for the number. If you want to restrict like the limits you are talking about, you need to do that outside of the column type / database structure itself.
TwistMyArm is offline   Reply With Quote
Old 01-22-2007, 09:30 AM   · #4
abc123ben
NamePros Regular
 
Trader Rating: (15)
Join Date: Aug 2005
Posts: 583
NP$: 37.15 (Donate)
abc123ben has a spectacular aura aboutabc123ben has a spectacular aura aboutabc123ben has a spectacular aura about
right. So INT(4) = -999 & 9999 - got it! So, want about mediumint etc. I am presuming that MEDIUMINT(4) would be -888 & 8888 - sorry for being a pain :S.

So if:

MEDIUMINT(4) is -888 and 8888 - then SMALLINT(4) would be -777 & 7777 - please correct me if im wrong.
abc123ben is offline   Reply With Quote
Old 01-22-2007, 10:16 AM   · #5
TwistMyArm
NamePros Member
 
Trader Rating: (0)
Join Date: May 2006
Posts: 159
NP$: 81.00 (Donate)
TwistMyArm is on a distinguished road
No, you don't have it. INT(4), INT(5), INT(2), INT(whatever) has no effect on the actual data stored. INT will store any number in the range of -2147483648 to 2147483647. The (4), (5), (2), (whatever) only affects how it shows small numbers, it doesn't affect the range of what it can store. To reduce that range, you can go down to a SMALLINT but even that stores from -32768 to 32767.

Read that page that I linked to and UNDERSTAND it. Once you've read it, let us know what you don't understand about it, then we can be more helpful.
TwistMyArm is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Buy Flash Arcade Game Script Website Header Design EscrowDNS
Advertise your business at NamePros
All times are GMT -7. The time now is 10:38 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0