db2 => CREATE TABLE carsales(sale_date DATE, VIN char(30)) PARTITION BY RANGE(sale_date) (part q113 STARTING MINVALUE ENDING '3/31/2013' EXCLUSIVE, part q213 STARTING '3/31/2013' ENDING '6/30/2013' EXCLUSIVE, part q313 STARTING '6/30/2013' ENDING '9/30/2013' EXCLUSIVE, part q413 STARTING '9/30/2013' ENDING '12/31/2013')
DB20000I The SQL command completed successfully.
db2 => describe data partitions for table carsales show detail
PartitionId PartitionName TableSpId PartObjId IndexTblSpId LongTblSpId AccessMode
Status
----------- ------------------------------- ----------- ----------- ------------ ----------- - ------
0 Q113 2 523 2 2 F
1 Q213 2 524 2 2 F
2 Q313 2 525 2 2 F
3 Q413 2 526 2 2 F
4 record(s) selected.
PartitionId Inclusive (y/n) Inclusive (y/n)
Low Value High Value
----------- - ------------------------------- - -------------------------------
0 Y MINVALUE N '2013-03-31'
1 Y '2013-03-31' N '2013-06-30'
2 Y '2013-06-30' N '2013-09-30'
3 Y '2013-09-30' Y '2013-12-31'
4 record(s) selected.
db2 => alter table carsales detach partition q113 into tblq113
DB20000I The SQL command completed successfully.
db2 => describe data partitions for table carsales show detail
PartitionId PartitionName TableSpId PartObjId IndexTblSpId LongTblSpId AccessMode
Status
----------- ------------------------------- ----------- ----------- ------------ ----------- - ------
1 Q213 2 524 2 2 F
2 Q313 2 525 2 2 F
3 Q413 2 526 2 2 F
3 record(s) selected.
PartitionId Inclusive (y/n) Inclusive (y/n)
Low Value High Value
----------- - ------------------------------- - -------------------------------
1 Y '2013-03-31' N '2013-06-30'
2 Y '2013-06-30' N '2013-09-30'
3 Y '2013-09-30' Y '2013-12-31'
3 record(s) selected.
db2 => insert into tblq113 values('2013-01-01','Jan')
db2 => ALTER TABLE carsales ATTACH PARTITION STARTING MINVALUE ENDING ('3/31/2013') EXCLUSIVE FROM tblq113
SQL3601W The statement caused one or more tables to automatically be placed
in the Set Integrity Pending state. SQLSTATE=01586
db2 => set integrity for carsales immediate checked
DB20000I The SQL command completed successfully.
db2 => select * from carsales
SALE_DATE VIN
---------- ------------------------------
01/01/2013 Jan
1 record(s) selected.
db2 =>
DB20000I The SQL command completed successfully.
db2 => describe data partitions for table carsales show detail
PartitionId PartitionName TableSpId PartObjId IndexTblSpId LongTblSpId AccessMode
Status
----------- ------------------------------- ----------- ----------- ------------ ----------- - ------
0 Q113 2 523 2 2 F
1 Q213 2 524 2 2 F
2 Q313 2 525 2 2 F
3 Q413 2 526 2 2 F
4 record(s) selected.
PartitionId Inclusive (y/n) Inclusive (y/n)
Low Value High Value
----------- - ------------------------------- - -------------------------------
0 Y MINVALUE N '2013-03-31'
1 Y '2013-03-31' N '2013-06-30'
2 Y '2013-06-30' N '2013-09-30'
3 Y '2013-09-30' Y '2013-12-31'
4 record(s) selected.
db2 => alter table carsales detach partition q113 into tblq113
DB20000I The SQL command completed successfully.
db2 => describe data partitions for table carsales show detail
PartitionId PartitionName TableSpId PartObjId IndexTblSpId LongTblSpId AccessMode
Status
----------- ------------------------------- ----------- ----------- ------------ ----------- - ------
1 Q213 2 524 2 2 F
2 Q313 2 525 2 2 F
3 Q413 2 526 2 2 F
3 record(s) selected.
PartitionId Inclusive (y/n) Inclusive (y/n)
Low Value High Value
----------- - ------------------------------- - -------------------------------
1 Y '2013-03-31' N '2013-06-30'
2 Y '2013-06-30' N '2013-09-30'
3 Y '2013-09-30' Y '2013-12-31'
3 record(s) selected.
db2 => insert into tblq113 values('2013-01-01','Jan')
db2 => ALTER TABLE carsales ATTACH PARTITION STARTING MINVALUE ENDING ('3/31/2013') EXCLUSIVE FROM tblq113
SQL3601W The statement caused one or more tables to automatically be placed
in the Set Integrity Pending state. SQLSTATE=01586
db2 => set integrity for carsales immediate checked
DB20000I The SQL command completed successfully.
db2 => select * from carsales
SALE_DATE VIN
---------- ------------------------------
01/01/2013 Jan
1 record(s) selected.
db2 =>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/725820/viewspace-2125516/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/725820/viewspace-2125516/