I have a 2 columns in my table: a varchar(8)
and an int
.
I want to auto-increment
the int column
and when I do, I want to copy the value into the varchar(8) column
, but pad it with 0's until it is 8 characters long, so for example, if the int column
was incremented to 3
, the varchar(8)
column would contain '00000003'
.
My two questions are, what happens when the varchar(8)
column gets to '99999999'
because I don't want to have duplicates?
How would I do this in MySQL?
If my values can be between 00000000
to 99999999
, how many values can i have before I run out?
This is my alternative approach to just creating a random 8 character string and checking MySQL for duplicates. I thought this was a better approach and would allow for a greater number of values.