create table tea(
id int(10) primary key auto_increment,
name varchar(20),
);
create table stu(
id int(10) primary key auto_increment,
name varchar(20),
tid int(10),
constraint st_key foreign key (tid) references tea(id)
);
默认是restrict,当删除tea时
[SQL] DROP TABLE tea;
[Err] 1217 - Cannot delete or update a parent row: a foreign key constraint fails
当删除stu时,是可以执行的
[SQL] drop table stu;
受影响的行: 0
时间: 0.051s