开发者

MySQL Auto Generated Unique Text Value?

开发者 https://www.devze.com 2023-03-02 00:40 出处:网络
I have a MySQL table that looks like this: my_numbermy_unique_text_field in which, my_number is an integer

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

0

精彩评论

暂无评论...
验证码 换一张
取 消