Example: Deleting a partition v16

This example deletes a partition of the sales table.

Create the sales table:

CREATE TABLE sales
(
  dept_no     number,
  part_no     varchar2,
  country     varchar2(20),
  date        date,
  amount      number
)
PARTITION BY LIST(country)
(
  PARTITION europe VALUES('FRANCE', 'ITALY'),
  PARTITION asia VALUES('INDIA', 'PAKISTAN'),
  PARTITION americas VALUES('US', 'CANADA')
);

Query the ALL_TAB_PARTITIONS view to display the partition names:

edb=# SELECT partition_name, high_value FROM ALL_TAB_PARTITIONS;
Output
 partition_name |     high_value
----------------+---------------------
 EUROPE         | 'FRANCE', 'ITALY'
 ASIA           | 'INDIA', 'PAKISTAN'
 AMERICAS       | 'US', 'CANADA'
(3 rows)

Delete the americas partition from the sales table:

ALTER TABLE sales DROP PARTITION americas;

Query the ALL_TAB_PARTITIONS view to show that the partition was successfully deleted:

edb=# SELECT partition_name, high_value FROM ALL_TAB_PARTITIONS;
Output
 partition_name |     high_value
----------------+---------------------
 EUROPE         | 'FRANCE', 'ITALY'
 ASIA           | 'INDIA', 'PAKISTAN'
(2 rows)