In Hologres, you can use the standard DROP TABLE statement to delete an entire partitioned table or a specific partition. Hologres does not support a separate DROP PARTITION TABLE syntax. This topic describes how to delete an entire partitioned table and how to delete a single partition.
Limits
When you delete a parent table, Hologres deletes all its child tables by default.
PARTITION TABLE specifies the partitioned table to delete.
Syntax
In Hologres, you can use the same DROP TABLE syntax to delete a partitioned table or a standard table. Hologres does not support a separate DROP PARTITION TABLE statement. You can choose one of the following actions: delete an entire partitioned table by dropping the parent table, or delete a single partition by running the DROP TABLE statement on the corresponding child table.
The syntax for deleting a partitioned table or a partition is as follows.
DROP TABLE [ IF EXISTS ] table_name [, ...];DROP TABLE can delete multiple tables at once.
The following table describes the parameters.
Parameter | Description |
IF EXISTS |
|
table_name | The name of the table to delete. |
Delete a partition from a partitioned table
To delete a single partition from a partitioned table, run the DROP TABLE statement on the child table that corresponds to that partition. After you run this statement, the partition is removed from the partitioned table. The parent table and other partitions remain unaffected.
To detach the partition from the parent table as an independent table before you delete it, you can first use ALTER TABLE parent_table DETACH PARTITION child_table, and then execute DROP TABLE on the detached table. For more information about the DETACH clause, see ALTER PARTITION TABLE.
Examples
The following examples show how to delete a partitioned table or a child table.
Delete a single partition from a partitioned table (delete the specified child table):
DROP TABLE hologres_child2;After you run this statement,
hologres_child2is removed from the partitioned table. The parent table and other child tables remain.Delete an entire partitioned table (deleting the parent table also deletes all its child tables by default):
DROP TABLE hologres_parent;