on update cascade -- 更新部门表中的数据,自动将所有关联表中的外键数据,一并更新
)engine = innodb charset = utf8;
insert into employees_temp4_2 values (101,'王五','小五',100);
insert into employees_temp4_2 values (102,'李四','小四',200);
复制代码
查询数据:
select * from employees_temp4_2;
select * from departments_temp1_2;
复制代码
部门表数据更新:
-- 当设置外键属性为级联更新时删除时,更新部门表中的数据,自动将所有关联表中的外键数据,一并更新update departments_temp1_2 set dept_id = 111 where dept_id = 100;-- 再次查询数据select * from employees_temp4_2;