 |
Results from the most recent live auction are here.
22 members in the live chat room. Join Chat!
| |
01-22-2007, 08:14 AM
|
· #1 | | NamePros Regular Join Date: Aug 2005
Posts: 583
NP$: 37.15 ( Donate)
| 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. |
| |
01-22-2007, 08:56 AM
|
· #2 | | NamePros Member Location: Ontario, Canada Join Date: Nov 2003 | 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. |
| |
01-22-2007, 09:00 AM
|
· #3 | | NamePros Member Join Date: May 2006
Posts: 159
NP$: 81.00 ( Donate)
| 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. |
| |
01-22-2007, 09:30 AM
|
· #4 | | NamePros Regular Join Date: Aug 2005
Posts: 583
NP$: 37.15 ( Donate)
| 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. |
| |
01-22-2007, 10:16 AM
|
· #5 | | NamePros Member Join Date: May 2006
Posts: 159
NP$: 81.00 ( Donate)
| 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. |
| |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |