I wanna create temporary tables with random names in a MySQL stored procedure. I also need to store the name in order to access the table from another stored procedure. I was thinking of using MD5 hashes:
SELECT md5(RAND()+CURRENT_TIMESTAMP());
I wonder if this will generate totally collision free strings or not?
You could use uuid() and remove the dashes from the result... that is the closest thing I can think of that would give you anything reliably unique.
select concat("table_prefix_", replace(uuid(), '-', '')) as unique_name;
it would end up being like this:
mysql> select concat("table_prefix_",replace(uuid(), '-', '')) as unique_name;
+-----------------------------------------------+
| unique_name |
+-----------------------------------------------+
| table_prefix_39f14dd9418011e3bd86c0cb38cd4f18 |
+-----------------------------------------------+
1 row in set (0.00 sec)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With