i wanted to create a field , which is all in same length.
i.e , all the column named ‘id’ should be like 000001 , 000002 .. 999999 , not 1 , 2 , .. 999999.
If i wanted a 6 digits length field with varchar(6) auto_increment.
Many thanks !
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To do this, you have to use the ZEROFILL option when creating your field. For instance
If you only want 6 digits, then use
Instead of 11 listed in the first part. However, after you reach 1,000,000, the columns will no longer be padded to the same length, because all values below 1,000,000 will only have 6 digits. However, it will continue to increment past the 6 digits specified, all the way to the maximum value for an integer (2 billion).