Mysql automatic random integer integer value

I know that auto_increment automatically assigns a primary key value to each new row that you insert in the table. Is there some default value that you can assign an integer primary key that results in a random number with each new insertion? Something like DEFAULT_VALUE = FLOOR(RAND() * (1000000-1)) ? I know that this is probably a very banal and stupid question, but I will be grateful for any help in advance! Thanks!

+4
source share
1 answer

Why not just use a UUID ?

Alternatively, why not let id do its thing, style AUTO_INCREMENT and create a secondary column that is randomly generated and indexed by UNIQUE , so it serves as a secondary primary?

+4
source

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


All Articles