添加和刪除外鍵約束

一、添加外鍵 1、在建表時添加。 輸入:constraint 外鍵名 foreign key(列名) references 主表名(主鍵列); 2、添加外鍵 輸入:alter table tableName add constraint 外鍵名 foreign key(列名) references 主表名(主鍵列); 外鍵名如果不寫,系統會自動生成一個外鍵名。 注意事項: ①父表和從表的的存儲引擎
相關文章
相關標籤/搜索