constraint
ON DELETE SET DEFAULT
Replaces the referencing value with its default, which must still satisfy the foreign key. Target: PostgreSQL 17; focused syntax.
Formal Syntax & Structure
sql syntaxsql
REFERENCES parent(id) ON DELETE SET DEFAULTWorking Example
Example Snippetsql
CREATE TABLE parent(id INT PRIMARY KEY NOT NULL); CREATE TABLE child(parent_id INT DEFAULT 0 REFERENCES parent(id) ON DELETE SET DEFAULT); INSERT INTO parent VALUES (0),(1); INSERT INTO child VALUES (1);DELETE FROM parent WHERE id=1;SELECT parent_id FROM child;