CASCADE is a referential-action keyword defined in the SQL standard. When attached to a foreign-key clause (ON DELETE CASCADE or ON UPDATE CASCADE) it instructs the database to propagate the triggering row change to all child rows that reference it. This keeps referential integrity intact without manual cleanup.Many dialects also allow CASCADE with DDL statements such as DROP TABLE, DROP SCHEMA, or ALTER TABLE ... DROP CONSTRAINT. In those contexts CASCADE forces the database to drop or alter objects that depend on the target object (views, constraints, foreign keys, etc.) instead of raising an error.Key behaviors- ON DELETE CASCADE: deleting a parent row automatically deletes matching child rows.- ON UPDATE CASCADE: updating a parent key automatically updates the matching foreign keys in child rows.- DDL CASCADE: dropping an object removes all dependent objects.Caveats- Cascading deletes are irreversible inside the same statement, so use transactions if you might need an undo.- Overuse can hide accidental mass deletions or schema loss. Always combine with proper permissions, backups, and WHERE clauses.- Some engines (SQLite) support CASCADE only for foreign keys, not DDL.- Circular cascading paths are rejected or require special settings.
FOREIGN KEY, ON DELETE, ON UPDATE, SET NULL, DROP TABLE, DROP SCHEMA, ALTER TABLE, REFERENTIAL INTEGRITY
SQL-92
CASCADE propagates the delete or update to child rows, removing or changing them. SET NULL leaves the child row intact but sets its foreign key column to NULL.
Most databases require altering the constraint to a different action or dropping it entirely. Alternatively, wrap the operation in a transaction and roll back if the result is not desired.
Use system catalogs or INFORMATION_SCHEMA views (e.g., pg_depend in PostgreSQL) to list dependent objects before running DROP ... CASCADE.
Cascading operations add extra work for the database engine. For large tables, deletes or updates may be slower. Index foreign key columns and batch large operations to mitigate impact.