MySQL set default id UUID

后端 未结 2 1091
庸人自扰
庸人自扰 2020-12-31 14:19

I\'m trying to create tables in a database that has an id field that will populate the id with an UUID by default.

I tried something like:



        
2条回答
  •  一生所求
    2020-12-31 15:11

    If you use binary(16) as the type, you can set the default as follows:

    unhex(replace(uuid(),'-',''))
    

提交回复
热议问题