分类: Oracle
2006-08-31 23:34:00
SQL> select count(*) from big_table; COUNT(*) ---------- 1000000 SQL> select table_name, tablespace_name from user_tables; TABLE_NAME TABLESPACE_NAME ------------------------------ ------------------------------ BIG_TABLE AQUA |
SQL> l 1 BEGIN 2 DBMS_REDEFINITION.CAN_REDEF_TABLE('AQUA','BIG_TABLE', 3 dbms_redefinition.cons_use_pk); 4* END; SQL> / PL/SQL procedure successfully completed. |
SQL> L 1 CREATE TABLE "AQUA"."BIG_TABLE_INT" ( 2 "ID" NUMBER NOT NULL, 3 "OWNER" VARCHAR2(30 byte) NOT NULL, 4 "OBJECT_NAME" VARCHAR2(30 byte) NOT NULL, 5 "SUBOBJECT_NAME" VARCHAR2(30 byte), 6 "OBJECT_ID" NUMBER NOT NULL, 7 "DATA_OBJECT_ID" NUMBER, 8 "OBJECT_TYPE" VARCHAR2(18 byte), 9 "CREATED" DATE NOT NULL, 10 "LAST_DDL_TIME" DATE NOT NULL, 11 "TIMESTAMP" VARCHAR2(19 byte), 12 "STATUS" VARCHAR2(7 byte), 13 "TEMPORARY" VARCHAR2(1 byte), 14 "GENERATED" VARCHAR2(1 byte), 15 "SECONDARY" VARCHAR2(1 byte), 16 CONSTRAINT "BIG_TABLE_INT_PK" PRIMARY KEY("ID") 17 USING INDEX TABLESPACE "AQUA2" NOLOGGING ) 18 PARTITION BY RANGE(id) 19 (PARTITION aqua200000 VALUES LESS THAN (200001) TABLESPACE AQUA2, 20 PARTITION aqua400000 VALUES LESS THAN (400001) TABLESPACE AQUA2, 21 PARTITION aqua600000 VALUES LESS THAN (600001) TABLESPACE AQUA2, 22 PARTITION aqua800000 VALUES LESS THAN (800001) TABLESPACE AQUA2, 23 PARTITION aqua1000000 VALUES LESS THAN (maxvalue) TABLESPACE AQUA2 24* ) SQL> / Table created. |
SQL> exec DBMS_REDEFINITION.START_REDEF_TABLE('aqua', 'big_table','big_table_int'); PL/SQL procedure successfully completed. |
SQL> exec dbms_redefinition.SYNC_INTERIM_TABLE('aqua', 'big_table', 'big_table_int'); PL/SQL procedure successfully completed. |
SQL> exec dbms_redefinition.FINISH_REDEF_TABLE('aqua', 'big_table', 'big_table_int'); PL/SQL procedure successfully completed. |
SQL> drop table aqua.big_table_int; Table dropped. |
SQL> col segment_name for a20 SQL> l 1* select segment_name,partition_name,segment_type,tablespace_name,bytes from user_segments SQL> / SEGMENT_NAME PARTITION_NAME SEGMENT_TYPE TABLESPACE_NAME BYTES -------------------- ------------------------------ ------------------ ------------------------------ ---------- BIG_TABLE AQUA200000 TABLE PARTITION AQUA2 24117248 BIG_TABLE AQUA400000 TABLE PARTITION AQUA2 24117248 BIG_TABLE AQUA600000 TABLE PARTITION AQUA2 24117248 BIG_TABLE AQUA800000 TABLE PARTITION AQUA2 24117248 BIG_TABLE AQUA1000000 TABLE PARTITION AQUA2 24117248 BIG_TABLE_INT_PK INDEX AQUA2 19922944 6 rows selected. SQL> |