Part 40: Dropping Tables: DROP TABLE with CASCADE vs RESTRICT

Part 40 Technology Updated September 12, 2026

Part 40: Dropping Tables: DROP TABLE with CASCADE vs RESTRICT

Removing a table completely from the database catalog.


1. Syntax

-- Safe deletion if table exists:
DROP TABLE IF EXISTS legacy_logs;

-- Cascade deletion: drops foreign key constraints in other tables referencing this table:
DROP TABLE IF EXISTS categories CASCADE;

Key Takeaways

  • Always use IF EXISTS.
  • Be aware that CASCADE automatically removes foreign keys pointing to the table.

In Part 41, we enter Module 5 to master Data Manipulation Language (DML): INSERT Statements!