MySQL Auto Generated Unique Text Value?
I have a MySQL
table that looks like this:
my_number
my_unique_text_field
in which, my_number
is an integer
Whenever I insert a number to field my_number
, I'd like a unique text value to be assigned to field my_unique_text_field
. Is it possible to achieve this using M开发者_StackOverflow社区ySQL
directly? or must I generate this unique text string using my client (I am using python
)?
mysql's UUID is good enough. But in case if you still worry about possible duplicates - you'd better generate it in python and handle unique constraint error.
If you are just after a unique id and not Text, your best bet is using UUID
精彩评论