您好,欢迎访问一九零五行业门户网

mysql外键约束有哪些要求

1、在表上建立外键,主表应先存在。
2、一个表可以建立多个外键约束。
3、从表的外键列必须指向主表的主键列。
4、从表的外键列可以与主表参考的列名不同,但数据类型必须相同。
实例
mysql> show create table students\g*************************** 1. row ***************************       table: studentscreate table: create table `students` (  `id` int(11) not null auto_increment,  `uid` int(11) not null,  `name` varchar(6) not null,  primary key (`id`),  key `uid` (`uid`),  constraint `students_ibfk_1` foreign key (`uid`) references `class` (`xuehao`) on delete cascade on update cascade) engine=innodb default charset=utf8
以上就是mysql外键约束有哪些要求的详细内容。
其它类似信息

推荐信息