All Products
Search
Document Center

PolarDB:DROP TABLE

Last Updated:Mar 28, 2026

Permanently removes a table and all its data from the database.

Syntax

DROP TABLE name [CASCADE | RESTRICT | CASCADE CONSTRAINTS]

Description

DROP TABLE permanently removes a table from the database. When you drop a table, all its partitions and subpartitions are also dropped. The statement always removes all indexes, rules, triggers, and constraints associated with the table.

This operation is irreversible. To remove only the rows while keeping the table structure, use DELETE instead.

Behavior with dependent objects:

  • RESTRICT (default) — returns an error if any other object depends on the table.

  • CASCADE or CASCADE CONSTRAINTS — drops all dependent constraints but not other types of dependent objects for a table.

Parameters

ParameterDescription
nameThe name of the table to drop. Can be a partitioned table. The name can be schema-qualified.
CASCADEDrops all dependent constraints but not other types of dependent objects.
RESTRICTReturns an error if the table has dependent objects. This is the default behavior.
CASCADE CONSTRAINTSDrops all dependent constraints but not other types of dependent objects.

Required permissions

To run DROP TABLE, you must be one of the following:

  • The owner of the partitioning root

  • A member of a group that owns the table

  • The schema owner

  • A database superuser

Examples

Drop a table with no dependent objects

DROP TABLE emp;

Drop a table that has dependent objects

Given the following table setup, where items has a foreign key that references orders:

CREATE TABLE orders
  (order_id int PRIMARY KEY, order_date date, …)
CREATE TABLE items
  (order_id int REFERENCES orders, quantity int, …);

The outcome of dropping orders depends on which clause you use:

  • DROP TABLE orders RESTRICT — returns an error because items depends on orders.

  • DROP TABLE orders CASCADE CONSTRAINTS — drops orders and removes the foreign key constraint from items, but leaves the items table intact.