DB2 Version 9.7 for Linux, UNIX, and Windows

Dropping data partitions

To drop a data partition, you detach the partition, and drop the table created by the detach operation. Use the ALTER TABLE statement with the DETACH PARTITION clause to detach the partition and create a stand-alone table, and use the DROP TABLE statement to drop the table.

About this task

To detach a data partition of a partitioned table, issue the ALTER TABLE statement with the DETACH PARTITION clause.

In the following example, the dec01 data partition is detached from table STOCK and placed in table JUNK. After ensuring that the asynchronous partition detach task has made the target table JUNK available, you can drop the table JUNK, effectively dropping the associated data partition.
    ALTER TABLE stock DETACH PART dec01 INTO junk;
     -- After the target table becomes available, issue the DROP TABLE statement 
    DROP TABLE junk;
Note: To make the ALTER TABLE...DETACH as fast as possible with DB2® Version 9.7 Fix Pack 1 and later releases, the asynchronous partition detach task completes the detach operation asynchronously. If there are detached dependent tables, the asynchronous partition detach task does not start and the detached data partition does not become a stand-alone table. In this case, the SET INTEGRITY statement must be issued on all detached dependent tables. After SET INTEGRITY completes, the asynchronous partition detach task starts and makes the target table accessible. When the target table is accessible it can be dropped.

Before you begin

To detach a data partition from a partitioned table the user must have the following authorities or privileges: To drop a table the user must have the following authorities or privileges:
Note: The implication of the detach data partition case is that the authorization ID of the statement is going to effectively issue a CREATE TABLE statement and therefore must have the necessary privileges to perform that operation. The table space is the one where the data partition that is being detached already resides. The authorization ID of the ALTER TABLE statement becomes the definer of the new table with CONTROL authority, as if the user had issued the CREATE TABLE statement. No privileges from the table being altered are transferred to the new table. Only the authorization ID of the ALTER TABLE statement and DBADM or SYSADM have access to the data immediately after the ALTER TABLE...DETACH PARTITION operation.