Home > Database > Mysql Tutorial > MYSQL外键(Foreign Key)的使用--修改(增加)外键方法,外键名不_MySQL

MYSQL外键(Foreign Key)的使用--修改(增加)外键方法,外键名不_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:34:57
Original
2691 people have browsed it

Mysql外键

bitsCN.com

MYSQL外键(Foreign Key)的使用--修改(增加)外键方法,外键名不能有重复的

 

1.今天在建wms中的case_detail中的caseNumber不能与case_head相关联。

 

结果建了数次都提示错误,浪费时间很久。

 

关键字: mysql createtable errno 121 150 错误 建表错误 外键 

 

2.增加外键的语句是

 

[sql] 

ALTER TABLE `setting_group`  

  ADD CONSTRAINT `location_ibfk_2` FOREIGN KEY (`id`) REFERENCES `setting_action` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;  

 

注意:a.外键名不能重要;b.主键名若有误,有报一个错误。

 

3.当修改时,一定要先清空内的数据,再加。当内部有数据时,不能修改,不能增加主键。

bitsCN.com
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template