How to detach a partition in a patitioned table
detaching a specific partition ins a partitioned table
First, you have to know what partition you want to detach and its name. To discover it, perform the db2look command below:
Database:
sample
Partitioned table:employee
db2look -d sample -e -t employee
or
db2 "SELECT SUBSTR(tabname, 1,16) tabname, \ SUBSTR(datapartitionname, 1, 12) datapartitionname, \ seqno, SUBSTR(lowvalue, 1, 12) as lowvalue, LOWINCLUSIVE, \ SUBSTR(highvalue, 1, 12) as highvalue,HIGHINCLUSIVE \ FROM SYSCAT.DATAPARTITIONS WHERE TABNAME='SALDOCONTABIL' ORDER BY seqno"
When you get your partition name, you will already detach it:
Example:
Partition name:
part15
db2 alter table employee detach partition part15 into emplo_15
Where emplo_15 is a table where the data from part15 will be storage, this table is created automatically.