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

MySql的级联关系

数据库表: class: teacher class与teacher是一对多 执行sql: delete from teacher where t_id=1; 数据库的级联设置为: restrict时 报错:a foreign key constraint fails 外键关联 这时需要先将class update class set teacher_id=null where c_id=1 no a
数据库表:
class:
teacher
class与teacher是一对多
执行sql:
delete from teacher where t_id=1;
数据库的级联设置为:
restrict时   
报错:a foreign key constraint fails 外键关联 这时需要先将class
update class set teacher_id=null where c_id=1
no action时
与上述一样
set null时
teacher 删除,class中的teacher_id自动设置为null
cascade时
teacher中的内容删除,class中与关联的内容也删除
其它类似信息

推荐信息