1#query
2SELECT FLOOR(RAND() * 99999)
3AS random_num
4FROM YourTableName
5WHERE "random_num"
6NOT IN (
7 SELECT YourColumnName FROM YourTableName) LIMIT 1
8
1DO
2 SELECT LEFT(UUID(), 8) INTO @var;
3 INSERT INTO col (@var);
4WHILE there_is_a_unique_constraint_violation