christa Posted December 19, 2010 Share Posted December 19, 2010 hi all, i have a db table with a field INT(4) UNSIGNED autoincrement named "person_ID". The (4) attribute means that i can store up to 9999 values or not? Quote Link to comment https://forums.phpfreaks.com/topic/222124-id-field-for-php-script/ Share on other sites More sharing options...
Pikachu2000 Posted December 19, 2010 Share Posted December 19, 2010 No. The (4) is just a display length. If there are less than 4 digits stored, and you are using zerofill, the number would be padded with zeros to four digits. You'll still be able to store a max unsigned value of 4,294,967,295. Quote Link to comment https://forums.phpfreaks.com/topic/222124-id-field-for-php-script/#findComment-1149243 Share on other sites More sharing options...
christa Posted December 19, 2010 Author Share Posted December 19, 2010 i'm not using zerofill, my field is unsigned. Â plase correct me if I'm wrong: Â value: 156 field: int(4) unsigned zerofill > value becomes 0000156 field: int(4) unsigned > value is 156 Â field: smallint(1) unsigned zerofill > value becomes 0156 field: smallint(1) unsigned > value is 156 Â Right? Â Â Â Â Quote Link to comment https://forums.phpfreaks.com/topic/222124-id-field-for-php-script/#findComment-1149295 Share on other sites More sharing options...
Pikachu2000 Posted December 19, 2010 Share Posted December 19, 2010 No, the length of an int(4) would be padded to a total length of 4 digits, so 156 would become 0156. The max value the field will hold isn't affected. Quote Link to comment https://forums.phpfreaks.com/topic/222124-id-field-for-php-script/#findComment-1149326 Share on other sites More sharing options...
christa Posted December 19, 2010 Author Share Posted December 19, 2010 ok. Last question: when i create a table can I omit the value between () or it is required? Quote Link to comment https://forums.phpfreaks.com/topic/222124-id-field-for-php-script/#findComment-1149334 Share on other sites More sharing options...
Pikachu2000 Posted December 19, 2010 Share Posted December 19, 2010 It depends on the field type. Some require it, where others don't. Your best bet would to look at the manual for the field types, but if you omit one that's required, you should get an error returned to that effect. Quote Link to comment https://forums.phpfreaks.com/topic/222124-id-field-for-php-script/#findComment-1149338 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.