为表 project_server 添加联合唯一索引
mysql> alter table project_server add unique index(project_id,object_id); ERROR 1062 (23000): Duplicate entry '11-1177' for key 'project_id'
如果提示说记录已经存在,那么加上 ignore,会自动将重复的去掉,很有效
mysql> alter ignore table project_server add unique index(project_id,object_id); Query OK, 166 rows affected (0.06 sec) Records: 166 Duplicates: 1 Warnings: 0
Leave a Reply