Unique Constraint with conditions in MYSQL

后端 未结 5 1790
心在旅途
心在旅途 2020-12-18 09:35

In postgres we have a constraint defined that essentially allows us to limit the number of entries in a table with a certain value to one. We created this constraint:

5条回答
  •  攒了一身酷
    2020-12-18 09:51

    My two cents:

    why don't you create a column only to store the unique value (maybe you can call it something like is_list_type_default) and another to store all the values. If you do this, you can put a unique constraint on the first column.

提交回复
热议问题