Create a unique identifier

I was looking for functions that generate unique identifiers - my special requirement is that the unique identifier should only be 8 digits.

In any case, I just realized that we can set the ID auto-increment field to start with any number. So, suppose I started it with 11111111 - am I right in thinking that all new entries will increase from this value? If so, I have my own unique 8-digit identifier and there is no need to use the function for this.

And also, if the record is deleted, will the new record reuse the remote identifier?

+3
source share
2 answers

1) auto-increment values ​​are not reused

2) , 8- (, 10000000), ! ( "AUTO_INCREMENT = N" )

+4

. 11111111, 11111112.

, - .

: , . MySQL:

AUTO_INCREMENT, , . , . , TINYINT, 127. TINYINT UNSIGNED 255.

INT 4294967295 BIGINT 18446744073709551615. . http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

+6

Source: https://habr.com/ru/post/1786412/


All Articles