do I have to specify integer length when creating an id field in MySQL through phpMyAdmin?

本秂侑毒 提交于 2019-12-22 06:17:11

问题


I saw someone not set the length in a tutorial but it was specifically for counting the total number of users and just set to auto-increment. I've been of the habit of always specifying a length because I thought it was mandatory, but I wanted to ask if I can leave it blank unless it specifically a date or pin number etc where the length is always set. (I used to set it as 11 digits or more if I wasn't sure)


回答1:


Every integer field defaults to 11 when left blank so you can leave it.




回答2:


No, you don't have to specify a length for integers. I have never done that.

There are different integral data types with different sizes, so you can just choose the one with the capacity that you need.



来源:https://stackoverflow.com/questions/7053596/do-i-have-to-specify-integer-length-when-creating-an-id-field-in-mysql-through-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!