db2 partition table test

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 =>


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/725820/viewspace-2125516/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/725820/viewspace-2125516/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值