[英]mySQL drop unique key constraint
我不確定如何在 mySql 中刪除唯一鍵約束。
create table Lesson
(
lessonId int not null auto_increment,
friendlyId varchar(255) not null,
primary key (lessonId),
unique key friendlyId (friendlyId)
);
我試過這個,但它是 mySql 的語法錯誤:
alter table Lesson
drop constraint friendlyId;
刪除具有唯一約束的索引並重新創建沒有唯一約束的索引。
ALTER TABLE table_name DROP INDEX index_name;
ALTER TABLE table_name ADD INDEX index_name (columns);
在你的情況下:
ALTER TABLE Lesson DROP INDEX friendlyId;
ALTER TABLE Lesson ADD INDEX friendlyId (friendlyId);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.