我很难找到在表中创建唯一依赖项的文档,例如,有两列,每一列可以有多个相似的值,但是两列都不能有两行相同的值(如在另一行中)......
换言之...... colA colB
row1 1 2 //this is ok
row2 1 3 //this is ok
row3 2 2 //this is ok
row4 2 2 //this would NOT be ok, because this is just like row 3, and that combination should be unique.
答案 0 :(得分:3)
听起来你只想在有问题的列上使用UNIQUE约束。在MySQL中类似于:
ALTER TABLE MyTable ADD UNIQUE (colA, colB);