分类: Oracle
2006-08-24 11:47:56
SQL> desc testtb_nopart Name Null? Type ----------------------------------------- -------- ---------------------------- TIMESTAMP DATE OWNER VARCHAR2(30) ACTION VARCHAR2(6) OBJECT_NAME VARCHAR2(128) MESSENG VARCHAR2(169) SQL> select to_char(timestamp, 'mm-yyyy'), count(*) from testtb_nopart group by to_char(timestamp, 'mm-yyyy'); TO_CHAR COUNT(*) ------- ---------- 12-2005 2058125 11-2005 1363431 08-2005 150951 10-2005 628149 07-2005 1006340 09-2005 730410 6 rows selected. |
create table testtb_part (timestamp date, owner varchar2(30), action varchar2(6), object_name varchar2(128) , messeng varchar2(169)) tablespace testts partition by range(timestamp)( partition rest values less than (maxvalue)) |
SQL> alter table testtb_part exchange partition rest with table testtb_nopart; Table altered. SQL> select to_char(timestamp, 'mm-yyyy'), count(*) from testtb_nopart group by to_char(timestamp, 'mm-yyyy'); no rows selected SQL> c/nopart/part/ 1* select to_char(timestamp, 'mm-yyyy'), count(*) from testtb_part group by to_char(timestamp, 'mm-yyyy') SQL> / TO_CHAR COUNT(*) ------- ---------- 12-2005 2058125 11-2005 1363431 08-2005 150951 10-2005 628149 07-2005 1006340 09-2005 730410 6 rows selected. |
SQL> alter table testtb_part split partition rest at (to_date('200508','yyyymm')) 2 into (partition part08, partition rest); Table altered. SQL> alter table testtb_part split partition rest at (to_date('200509','yyyymm')) 2 into (partition part08, partition rest); Table altered. SQL> alter table testtb_part split partition rest at (to_date('200510','yyyymm')) 2 into (partition part09, partition rest); Table altered. SQL> alter table testtb_part split partition rest at (to_date('200511','yyyymm')) 2 into (partition part10, partition rest); Table altered. SQL> alter table testtb_part split partition rest at (to_date('200512','yyyymm')) 2 into (partition part11, partition rest); Table altered. SQL> alter table testtb_part split partition rest at (to_date('200601','yyyymm')) 2 into (partition part12, partition rest); Table altered. |
alter table testtb_part rename to testtb_nopart |