Mysql 外鍵 主鍵

1,爲已添加好數據的表加外鍵sql

語法:code

alter table Sell add constraint FK_ID foreign key(Ware_Id) REFERENCES Ware(Ware_Id);


2,刪除外鍵table

語法:class

alter table Sell drop foreign key Ware_Id;


3,查詢主鍵語法

desc 表名;(不須要加table)


4,建立聯合主鍵im

alter table tb_name add primary key (字段1,字段2,字段3);
相關文章
相關標籤/搜索