[英]mySQL drop unique key constraint
I am not sure how drop unique key constraint in mySql.我不确定如何在 mySql 中删除唯一键约束。
create table Lesson
(
lessonId int not null auto_increment,
friendlyId varchar(255) not null,
primary key (lessonId),
unique key friendlyId (friendlyId)
);
I have tried this but its a syntax error for mySql:我试过这个,但它是 mySql 的语法错误:
alter table Lesson
drop constraint friendlyId;
Drop the index with the unique constraint and recreate the index without unique constraint.删除具有唯一约束的索引并重新创建没有唯一约束的索引。
ALTER TABLE table_name DROP INDEX index_name;
ALTER TABLE table_name ADD INDEX index_name (columns);
in your case:在你的情况下:
ALTER TABLE Lesson DROP INDEX friendlyId;
ALTER TABLE Lesson ADD INDEX friendlyId (friendlyId);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.