更新时间:2023-01-31 08:12:20
在MySQL Workbench的Alter Table对话框中:
In the Alter Table dialog of MySQL Workbench:
对于这是否很奇怪,有一些讨论,因为索引是与约束不同.我当然不会想去那里看.但是,显然,唯一索引"以与唯一约束相同的方式强制执行唯一性,并且可以提高性能.例如,如果我尝试插入使用此方法后将打破唯一性的行,则会引发"1062 Duplicate entry"错误.
There's some discussion as to whether this is weird, since an index is not the same as a constraint. I certainly wouldn't have thought to look there. However, apparently the `unique index' enforces uniqueness in the same way as a unique constraint, and may improve performance. For example, if I try to insert a row that would break unique together after using this method, it throws an '1062 Duplicate entry' error.