|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
Int(1) or int(2) design
n00b question. First what I'm asking might not even matter.
I have a int field with real world possible values of 1-10. I'm wondering if I should use an int(1) or int(2). does it matter? do they use the same amount of space? if they don't I could do some hack that says 0=1 1=2 etc in sql or something and do int(1) or I could do int(2) and just use real values. another note: actually having the value 10 although technically possible will be very rare if, I would doubt 1 in 1 billion records would have it. |
|
#2
|
||||
|
||||
|
Quote:
first, i would like to draw your attention to the fact that we have several forums for databases -- forums for db2, mysql, postgresql, firebird, ms sql, oracle, and finally the one you posted into, a generic one for databases not covered by the other forums, or for general topics where the database system doesn't matter judging by your question, i'd say you were using mysql, because mysql is the only one that i know of where people routinely get misled by that silly number in parentheses no, the number in parentheses doesn't matter INT(1) is the same as INT(2) is the same as INT(937) they all take 4 bytes and can hold the same range of numbers so for what you've described, you should be using TINYINT, not INTEGER ![]() |
|
#3
|
|||
|
|||
|
ah... my apologies I didn't realize it was a mysql specific feature (I believe tinyint is as well). I assume it works as a sort of constraint then. thanks for the answer.
|
|
#4
|
||||
|
||||
|
not a constraint, no
the number in parentheses specifies how many total digits including leading zeroes you want to display if you are using the ZEROFILL option ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Int(1) or int(2) design |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|