ON DELETE SET DEFAULT
ON DELETE SET DEFAULT is a SQL statement in the Constraints category. When parent row is deleted, child's foreign key is set to its default value. The syntax is FOREIGN KEY (col) REFERENCES parent(id) ON DELETE SET DEFAULT;. It returns constraint with SET DEFAULT. A typical example: CREATE TABLE orders ( id INT PRIMARY KEY, customer_id INT DEFAULT 0, FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE SET DEFAULT ); -- When customer is deleted, order.customer_id becomes 0 -- The default value (0) must exist in the parent table or be a valid placeholder -- Not supported in all databases (MySQL uses SET NULL instead) A close relative is PRIMARY KEY, which a column or set of columns that uniquely identifies each row. Only one PK per table. Automatically creates a unique index. A close relative is FOREIGN KEY, which ensures referential integrity: values in this column must exist in the referenced parent table.