How to start every value in auto increment column with 0

Hi !
I am looking for solution that every auto incremented value in each row should start with 0 in mysql table . for example
01, 02, 03,— 010, … 099, 0100 and so on!
is that possible to do that without any concatenate or without any trigger ???

What is the use case? A database is not meant to be the output formatter. It should store data a way that it is most fast searchable. When you add the 0 in front of your index it’s no longer an integer value (which is the fastest format for a computer to handle data) but it will become a string and the search and sort will loose great performance.

So if you need the data be shown to the user as 01, 010 etc, add this value directly before you print it out and not in the database and even not in the backend code.

5 Likes

nope

the ~only~ feature of an auto_increment column that is guaranteed is that it produces unique values – and not necessarily free of gaps

anything else you want to use them for is an anti-pattern

5 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.