Problem Statement
Which ON DELETE action keeps child rows but nulls their foreign key when the parent is removed?
Explanation
SET NULL preserves the child record but clears the foreign key, which is valid only if the column allows NULL.
CASCADE deletes the children, RESTRICT/NO ACTION prevents the parent delete when children exist.
Code Solution
SolutionRead Only
customer_id BIGINT REFERENCES customers(id) ON DELETE SET NULL
Practice Sets
This question appears in the following practice sets:
