Delete a partitioned table

Updated at:
Copy as MD

DROP TABLE permanently removes a partitioned table and all its partitions from the database, including all associated indexes, rules, triggers, and constraints.

Only the table owner, schema owner, or superuser can drop a table.

The DROP TABLE statement in PolarDB for PostgreSQL (Compatible with Oracle) is fully compatible with PostgreSQL. For the full syntax reference, see PostgreSQL documentation.

Syntax

DROP [ TABLE ] name [ CASCADE | RESTRICT ]

Parameters

ParameterDescription
nameThe name of the partitioned table to drop.
CASCADEDrops the table and all objects that depend on it, such as views and tables with foreign key constraints referencing this table.
RESTRICTRefuses to drop the table if any objects depend on it.

Usage notes

DROP TABLE is a destructive operation. To clear all rows without removing the table structure, use DELETE or TRUNCATE instead.

To delete a table referenced by a view or a foreign key constraint of another table, you must use CASCADE.

Examples

Drop a partitioned table

DROP TABLE tab_range;