ON DELETE NO ACTION
ON DELETE NO ACTION is a SQL statement in the Constraints category. Prevents deletion of a parent row if child rows exist (the default behavior). Throws an error. The syntax is FOREIGN KEY (col) REFERENCES parent(id) ON DELETE NO ACTION;. It returns constraint (prevents delete). A typical example: CREATE TABLE orders ( id INT PRIMARY KEY, customer_id INT, FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE NO ACTION ); -- DELETE FROM customers WHERE id = 5; -- ERROR: FK constraint violation - orders exist for this customer -- 'NO ACTION' vs 'RESTRICT': -- In SQL standard, NO ACTION is deferred, RESTRICT is immediate -- In practice, most DBs treat them identically 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.