Drop Table

Learn how to use PostgreSQL DROP TABLE to remove one or more tables, handle dependent objects with CASCADE, and avoid errors with IF EXISTS.

4 min read · Last updated: March 2026 · Back to overview

Quick Answer

Use DROP TABLE table_name; to remove a table from the database. Add IF EXISTS to suppress errors when the table does not exist, and CASCADE to automatically drop dependent objects such as foreign key constraints and views.

Spin up a Postgres database in 20 seconds with Vela.

Try Vela Sandbox

The DROP TABLE statement permanently removes a table and all of its data from the database. By default PostgreSQL rejects the operation if any other object — such as a view or a foreign key constraint — depends on the table. You can override this with CASCADE, which drops the dependent objects too.

Syntax and options

The basic syntax is:

DROP TABLE [IF EXISTS] table_name [CASCADE | RESTRICT];

Key options:

  • IF EXISTS — issues a notice instead of an error when the table does not exist.
  • CASCADE — removes the table and all objects that depend on it (foreign key constraints, views, etc.).
  • RESTRICT — the default; refuses to drop the table if any dependent objects exist.

To drop multiple tables in one statement, separate their names with commas:

DROP TABLE IF EXISTS tvshows, animes;

Practical examples

Attempting to drop a table that does not exist raises an error:

DROP TABLE author;
-- ERROR:  table "author" does not exist

Using IF EXISTS converts the error into a notice:

DROP TABLE IF EXISTS author;
-- NOTICE:  table "author" does not exist, skipping

When a table has dependent objects, DROP TABLE fails without CASCADE:

CREATE TABLE authors (
  author_id INT PRIMARY KEY,
  firstname VARCHAR(50) NOT NULL,
  lastname  VARCHAR(50) NOT NULL
);

CREATE TABLE pages (
  page_id   SERIAL PRIMARY KEY,
  title     VARCHAR(255) NOT NULL,
  author_id INT NOT NULL,
  FOREIGN KEY (author_id) REFERENCES authors(author_id)
);

-- This fails because pages.author_id references authors:
DROP TABLE IF EXISTS authors;
-- ERROR:  cannot drop table authors because other objects depend on it
-- HINT:   Use DROP ... CASCADE to drop the dependent objects too.

Add CASCADE to drop both the table and the foreign key constraint on pages:

DROP TABLE authors CASCADE;
-- NOTICE:  drop cascades to constraint pages_author_id_fkey on table pages

Production tips

  • Always use IF EXISTS in migration scripts so they are idempotent and do not fail on re-runs.
  • Use CASCADE with caution — review which dependent objects will be removed before running it in production.
  • You need to be a superuser, schema owner, or table owner to drop a table.
  • Wrap destructive DDL in a transaction so you can roll back if something unexpected is dropped.
  • Consider TRUNCATE instead of DROP TABLE when you want to keep the table structure but remove all rows quickly.

Continue in Managing Tables: Temporary Table.

Related in this section: PostgreSQL Data Types · Create Table · Select Into

Frequently Asked Questions

What is the difference between DROP TABLE and TRUNCATE TABLE in PostgreSQL?

DROP TABLE removes the table structure and all its data permanently. TRUNCATE TABLE removes all rows but keeps the table structure, indexes, and constraints intact. Use TRUNCATE when you want an empty table; use DROP when you no longer need the table at all.

How do I drop a table that has a foreign key constraint pointing to it?

Use DROP TABLE table_name CASCADE. This removes the table and automatically drops any foreign key constraints in other tables that reference it. PostgreSQL prints a NOTICE listing each object that was dropped as a cascade.

Can I drop multiple tables with a single DROP TABLE statement?

Yes. List the table names separated by commas: DROP TABLE IF EXISTS table1, table2, table3; PostgreSQL drops all listed tables in a single operation.

Does DROP TABLE fire ON DELETE triggers?

No. DROP TABLE does not fire row-level ON DELETE triggers because it does not delete rows individually. If trigger logic must run, delete the rows explicitly with DELETE before dropping the table.

Is DROP TABLE transactional in PostgreSQL?

Yes. DROP TABLE is a DDL statement and is fully transactional in PostgreSQL. If you wrap it in a BEGIN/COMMIT block and then ROLLBACK, the table will be restored.