-- 對應不到,就設定成null
on delete set null;
-- 對應不到,就把整筆資料刪掉
on delete cascade;
delete from employee
where emp_id
= 207;
把員工ID為207的刪掉,這時候再去看BRANCH表格時,行政部門的manager_id就會顯示null; 看works_with表格時會發現原本5行資料剩下4行,emp_id的部分刪掉了,因為有設定 on delete cascade的關係
on delete set null要注意,如果是primary key的話不能設為NULL,會出錯