mysql q
- Started
- Last post
- 5 Responses
- kinetic
if you have an auto increment id field (as many people do) in your mysql tables..this number can go extremely high.
so...say you have another table where you reference that id number (for cross referencing purposes), what type of column should it be?
if its varchar set at 255 that auto_increment field could potentially go past 255 chars which could really screw things up.
or could it? i dont know..ive always wondered about this.
dont know much about mysql.
- zanetate0
I can't imagine that field getting bigger than 255 characters. 1000000 is only 7 characters.
- intoxicated0
Dont worry about it, I have my primary fields set to INT(11), I can; image getting a row upto number 9.999.999.999
- mike0
the int type will hold a number as high as 2.1 billion. if you plan to have more than that number of records without any sort of archiving I would say you should be looking more into performance issues rather than field sizes.
if you don't declare the size of your field it will grow to meet the size demand, so you can go up to 2.1 billion if necessary. also, it would be bad to map an int type to a varchar type. string lookups are much slower than int comparisons.
http://www.mysql.com/doc/en/Numeā¦
hope that helps.
- unfittoprint0
you should never, never put a userID, newsID, postID with a varchar(255), that's used more for small input text (user/item name, title, etc...). For auto-increment use INT(11).
- kinetic0
i usually use TINYINT.
im saying... what i meant was referencing that field in another table that already has its own ID.
but yea, i cant see it going over 255 characters. just curious to see what other people thought