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? 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. 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? 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. 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? 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. 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
Archived
This topic is now archived and is closed to further replies.