开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜