Main Conversion
SQL> EXEC DBMS_REDEFINITION.CAN_REDEF_TABLE('QP','QP_LIST_HEADERS_B',2);
PL/SQL procedure successfully completed.
set heading off;
set echo off;
Set pages 999;
set long 90000;
spool a.log
SELECT DBMS_METADATA.GET_DDL('TABLE','QP_PRICING_ATTRIBUTES','QP') FROM DUAL;
make the changes.
· Change the name to add “_nopart”. This will be the interim table.
· Remove all the “not null” constraints
· remove the not required the partition clause
once the _nopart is created.
SQL> EXEC dbms_redefinition.start_redef_table('QP','QP_LIST_HEADERS_B','QP_LIST_HEADERS_B_NOPART',NULL,2);
PL/SQL procedure successfully completed.
SQL> VARIABLE NUM_ERRORS NUMBER;
SQL> exec DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS('QP','QP_LIST_HEADERS_B','QP_LIST_HEADERS_B_NOPART',1,TRUE,TRUE,TRUE,TRUE,:NUM_ERRORS,FALSE);
PL/SQL procedure successfully completed.
SQL> PRINT NUM_ERRORS
NUM_ERRORS
----------
1
SQL> SHOW ERROR
No errors.
SQL>
SQL> EXEC DBMS_REDEFINITION.SYNC_INTERIM_TABLE('QP','QP_LIST_HEADERS_B','QP_LIST_HEADERS_B_NOPART');
PL/SQL procedure successfully completed.
SQL> EXEC DBMS_REDEFINITION.FINISH_REDEF_TABLE('QP','QP_LIST_HEADERS_B','QP_LIST_HEADERS_B_NOPART');
PL/SQL procedure successfully completed.
Checks
SQL> Select partition_name, high_value from DBA_tab_partitions where table_name='QP_LIST_HEADERS_B';
no rows selected
SQL> DESC QP.QP_LIST_HEADERS_B;
Name Null? Type
----------------------------------------- -------- ----------------------------
LIST_HEADER_ID NUMBER
CREATION_DATE DATE
CREATED_BY NUMBER
LAST_UPDATE_DATE DATE
LAST_UPDATED_BY NUMBER
LAST_UPDATE_LOGIN NUMBER
PROGRAM_APPLICATION_ID NUMBER
PROGRAM_ID NUMBER
PROGRAM_UPDATE_DATE DATE
REQUEST_ID NUMBER
LIST_TYPE_CODE VARCHAR2(30)
START_DATE_ACTIVE DATE
END_DATE_ACTIVE DATE
AUTOMATIC_FLAG VARCHAR2(1)
CURRENCY_CODE VARCHAR2(30)
ROUNDING_FACTOR NUMBER
SHIP_METHOD_CODE VARCHAR2(30)
FREIGHT_TERMS_CODE VARCHAR2(30)
TERMS_ID NUMBER
COMMENTS VARCHAR2(2000)
DISCOUNT_LINES_FLAG VARCHAR2(1)
GSA_INDICATOR VARCHAR2(1)
PRORATE_FLAG VARCHAR2(30)
SOURCE_SYSTEM_CODE VARCHAR2(30)
ASK_FOR_FLAG VARCHAR2(1)
ACTIVE_FLAG VARCHAR2(1)
PARENT_LIST_HEADER_ID NUMBER
START_DATE_ACTIVE_FIRST DATE
END_DATE_ACTIVE_FIRST DATE
ACTIVE_DATE_FIRST_TYPE VARCHAR2(30)
START_DATE_ACTIVE_SECOND DATE
END_DATE_ACTIVE_SECOND DATE
ACTIVE_DATE_SECOND_TYPE VARCHAR2(30)
CONTEXT VARCHAR2(30)
ATTRIBUTE1 VARCHAR2(240)
ATTRIBUTE2 VARCHAR2(240)
ATTRIBUTE3 VARCHAR2(240)
ATTRIBUTE4 VARCHAR2(240)
ATTRIBUTE5 VARCHAR2(240)
ATTRIBUTE6 VARCHAR2(240)
ATTRIBUTE7 VARCHAR2(240)
ATTRIBUTE8 VARCHAR2(240)
ATTRIBUTE9 VARCHAR2(240)
ATTRIBUTE10 VARCHAR2(240)
ATTRIBUTE11 VARCHAR2(240)
ATTRIBUTE12 VARCHAR2(240)
ATTRIBUTE13 VARCHAR2(240)
ATTRIBUTE14 VARCHAR2(240)
ATTRIBUTE15 VARCHAR2(240)
LIMIT_EXISTS_FLAG VARCHAR2(1)
MOBILE_DOWNLOAD VARCHAR2(1)
CURRENCY_HEADER_ID NUMBER
PTE_CODE VARCHAR2(30)
LIST_SOURCE_CODE VARCHAR2(30)
ORIG_SYSTEM_HEADER_REF VARCHAR2(50)
ORIG_ORG_ID NUMBER
GLOBAL_FLAG VARCHAR2(1)
SHAREABLE_FLAG VARCHAR2(1)
SOLD_TO_ORG_ID NUMBER
LOCKED_FROM_LIST_HEADER_ID NUMBER
SQL> DESC DBA_INDEXES;
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER NOT NULL VARCHAR2(30)
INDEX_NAME NOT NULL VARCHAR2(30)
INDEX_TYPE VARCHAR2(27)
TABLE_OWNER NOT NULL VARCHAR2(30)
TABLE_NAME NOT NULL VARCHAR2(30)
TABLE_TYPE VARCHAR2(11)
UNIQUENESS VARCHAR2(9)
COMPRESSION VARCHAR2(8)
PREFIX_LENGTH NUMBER
TABLESPACE_NAME VARCHAR2(30)
INI_TRANS NUMBER
MAX_TRANS NUMBER
INITIAL_EXTENT NUMBER
NEXT_EXTENT NUMBER
MIN_EXTENTS NUMBER
MAX_EXTENTS NUMBER
PCT_INCREASE NUMBER
PCT_THRESHOLD NUMBER
INCLUDE_COLUMN NUMBER
FREELISTS NUMBER
FREELIST_GROUPS NUMBER
PCT_FREE NUMBER
LOGGING VARCHAR2(3)
BLEVEL NUMBER
LEAF_BLOCKS NUMBER
DISTINCT_KEYS NUMBER
AVG_LEAF_BLOCKS_PER_KEY NUMBER
AVG_DATA_BLOCKS_PER_KEY NUMBER
CLUSTERING_FACTOR NUMBER
STATUS VARCHAR2(8)
NUM_ROWS NUMBER
SAMPLE_SIZE NUMBER
LAST_ANALYZED DATE
DEGREE VARCHAR2(40)
INSTANCES VARCHAR2(40)
PARTITIONED VARCHAR2(3)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
BUFFER_POOL VARCHAR2(7)
USER_STATS VARCHAR2(3)
DURATION VARCHAR2(15)
PCT_DIRECT_ACCESS NUMBER
ITYP_OWNER VARCHAR2(30)
ITYP_NAME VARCHAR2(30)
PARAMETERS VARCHAR2(1000)
GLOBAL_STATS VARCHAR2(3)
DOMIDX_STATUS VARCHAR2(12)
DOMIDX_OPSTATUS VARCHAR2(6)
FUNCIDX_STATUS VARCHAR2(8)
JOIN_INDEX VARCHAR2(3)
IOT_REDUNDANT_PKEY_ELIM VARCHAR2(3)
DROPPED VARCHAR2(3)
SQL> select privilege, grantee from dba_tab_privs where table_name='QP_LIST_HEADERS_B';
PRIVILEGE GRANTEE
---------------------------------------- ------------------------------
ALTER APPS
DELETE APPS
INDEX APPS
INSERT APPS
SELECT XXBI_OWNER
SELECT OECA_ORDER_ENTRY
SELECT OEX0_ORDER_ENTRY
SELECT ARW_READ_ONLY
SELECT OEUS_ORDER_ENTRY
SELECT NOETIX_SYS
SELECT OEON1_ORDER_ENTRY
SELECT APPS
UPDATE APPS
REFERENCES APPS
ON COMMIT REFRESH APPS
QUERY REWRITE APPS
DEBUG APPS
FLASHBACK APPS
18 rows selected.
SQL> SELECT * FROM DBA_INDEXES WHERE TABLE_NAME='QP_LIST_HEADERS_B';
OWNER INDEX_NAME
------------------------------ ------------------------------
INDEX_TYPE TABLE_OWNER
--------------------------- ------------------------------
TABLE_NAME TABLE_TYPE UNIQUENES COMPRESS PREFIX_LENGTH
------------------------------ ----------- --------- -------- -------------
TABLESPACE_NAME INI_TRANS MAX_TRANS INITIAL_EXTENT NEXT_EXTENT
------------------------------ ---------- ---------- -------------- -----------
MIN_EXTENTS MAX_EXTENTS PCT_INCREASE PCT_THRESHOLD INCLUDE_COLUMN FREELISTS
----------- ----------- ------------ ------------- -------------- ----------
FREELIST_GROUPS PCT_FREE LOG BLEVEL LEAF_BLOCKS DISTINCT_KEYS
--------------- ---------- --- ---------- ----------- -------------
AVG_LEAF_BLOCKS_PER_KEY AVG_DATA_BLOCKS_PER_KEY CLUSTERING_FACTOR STATUS
----------------------- ----------------------- ----------------- --------
NUM_ROWS SAMPLE_SIZE LAST_ANAL DEGREE
---------- ----------- --------- ----------------------------------------
INSTANCES PAR T G S BUFFER_ USE DURATION
---------------------------------------- --- - - - ------- --- ---------------
PCT_DIRECT_ACCESS ITYP_OWNER ITYP_NAME
----------------- ------------------------------ ------------------------------
PARAMETERS
--------------------------------------------------------------------------------
GLO DOMIDX_STATU DOMIDX FUNCIDX_ JOI IOT DRO
--- ------------ ------ -------- --- --- ---
QP QP_LIST_HEADERS_B_N9
NORMAL QP
QP_LIST_HEADERS_B TABLE NONUNIQUE DISABLED
APPS_TS_TX_IDX 11 255 131072 131072
1 2147483645 0
10 YES 2 2014 331590
1 1 77931 VALID
331590 331590 28-JAN-11 1
1 NO N N N DEFAULT NO
NO NO NO NO
QP QP_LIST_HEADERS_B_N10
NORMAL QP
QP_LIST_HEADERS_B TABLE NONUNIQUE DISABLED
APPS_TS_TX_IDX 11 255 131072 131072
1 2147483645 0
10 YES 1 2 358
1 1 286 VALID
358 358 28-JAN-11 1
1 NO N N N DEFAULT NO
NO NO NO NO
QP QP_LIST_HEADERS_B_N6
NORMAL QP
QP_LIST_HEADERS_B TABLE NONUNIQUE DISABLED
APPS_TS_TX_IDX 11 255 131072 131072
1 2147483645 0
10 YES 2 715 2
357 4738 9477 VALID
331590 331590 28-JAN-11 1
1 NO N N N DEFAULT NO
NO NO NO NO
QP QP_LIST_HEADERS_B_N7
NORMAL QP
QP_LIST_HEADERS_B TABLE NONUNIQUE DISABLED
APPS_TS_TX_IDX 11 255 131072 131072
1 2147483645 0
10 YES 2 1045 331590
1 1 78800 VALID
331590 331590 28-JAN-11 1
1 NO N N N DEFAULT NO
NO NO NO NO
QP QP_LIST_HEADERS_B_N1
NORMAL QP
QP_LIST_HEADERS_B TABLE NONUNIQUE DISABLED
APPS_TS_TX_IDX 11 255 131072 131072
1 2147483645 0
10 YES 2 1426 331590
1 1 77931 VALID
331590 331590 28-JAN-11 1
1 NO N N N DEFAULT NO
NO NO NO NO
QP QP_LIST_HEADERS_B_N2
NORMAL QP
QP_LIST_HEADERS_B TABLE NONUNIQUE DISABLED
APPS_TS_TX_IDX 11 255 131072 131072
1 2147483645 0
10 YES 2 1046 331590
1 1 78413 VALID
331590 331590 28-JAN-11 1
1 NO N N N DEFAULT NO
NO NO NO NO
QP QP_LIST_HEADERS_B_N3
NORMAL QP
QP_LIST_HEADERS_B TABLE NONUNIQUE DISABLED
APPS_TS_TX_IDX 11 255 131072 131072
1 2147483645 0
10 YES 2 715 5
143 1919 9597 VALID
331590 331590 28-JAN-11 1
1 NO N N N DEFAULT NO
NO NO NO NO
QP QP_LIST_HEADERS_B_N5
NORMAL QP
QP_LIST_HEADERS_B TABLE NONUNIQUE DISABLED
APPS_TS_TX_IDX 11 255 131072 131072
1 2147483645 0
10 YES 1 2 358
1 1 286 VALID
358 358 28-JAN-11 1
1 NO N N N DEFAULT NO
NO NO NO NO
QP QP_LIST_HEADERS_B_PK
NORMAL QP
QP_LIST_HEADERS_B TABLE UNIQUE DISABLED
APPS_TS_TX_IDX 11 255 131072 131072
1 2147483645 0
10 YES 1 715 331590
1 1 77931 VALID
331590 331590 28-JAN-11 1
1 NO N N N DEFAULT NO
NO NO NO NO
9 rows selected.
SQL> SELECT * FROM DBA_CONSTRAINTS WHERE TABLE_NAME = 'QP_LIST_HEADERS_B';
OWNER CONSTRAINT_NAME C
------------------------------ ------------------------------ -
TABLE_NAME
------------------------------
SEARCH_CONDITION
--------------------------------------------------------------------------------
R_OWNER R_CONSTRAINT_NAME DELETE_RU STATUS
------------------------------ ------------------------------ --------- --------
DEFERRABLE DEFERRED VALIDATED GENERATED BAD RELY LAST_CHAN
-------------- --------- ------------- -------------- --- ---- ---------
INDEX_OWNER INDEX_NAME INVALID
------------------------------ ------------------------------ -------
VIEW_RELATED
--------------
QP SYS_C0043783 C
QP_LIST_HEADERS_B
"LIST_HEADER_ID" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE NOT VALIDATED USER NAME 28-JAN-11
QP SYS_C0043784 C
QP_LIST_HEADERS_B
"CREATION_DATE" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE NOT VALIDATED USER NAME 28-JAN-11
QP SYS_C0043788 C
QP_LIST_HEADERS_B
"LIST_TYPE_CODE" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE NOT VALIDATED USER NAME 28-JAN-11
QP SYS_C0043786 C
QP_LIST_HEADERS_B
"LAST_UPDATE_DATE" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE NOT VALIDATED USER NAME 28-JAN-11
QP SYS_C0043787 C
QP_LIST_HEADERS_B
"LAST_UPDATED_BY" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE NOT VALIDATED USER NAME 28-JAN-11
QP SYS_C0043785 C
QP_LIST_HEADERS_B
"CREATED_BY" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE NOT VALIDATED USER NAME 28-JAN-11
6 rows selected.
SQL> C/QP_LIST_HEADERS_B/QP_LIST_HEADERS_B_NOPART
1* SELECT * FROM DBA_CONSTRAINTS WHERE TABLE_NAME = 'QP_LIST_HEADERS_B_NOPART'
SQL> /
OWNER CONSTRAINT_NAME C
------------------------------ ------------------------------ -
TABLE_NAME
------------------------------
SEARCH_CONDITION
--------------------------------------------------------------------------------
R_OWNER R_CONSTRAINT_NAME DELETE_RU STATUS
------------------------------ ------------------------------ --------- --------
DEFERRABLE DEFERRED VALIDATED GENERATED BAD RELY LAST_CHAN
-------------- --------- ------------- -------------- --- ---- ---------
INDEX_OWNER INDEX_NAME INVALID
------------------------------ ------------------------------ -------
VIEW_RELATED
--------------
QP TMP$$_SYS_C00437831 C
QP_LIST_HEADERS_B_NOPART
"LIST_HEADER_ID" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE NOT VALIDATED USER NAME 19-JAN-11
QP TMP$$_SYS_C00437841 C
QP_LIST_HEADERS_B_NOPART
"CREATION_DATE" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE NOT VALIDATED USER NAME 19-JAN-11
QP TMP$$_SYS_C00437881 C
QP_LIST_HEADERS_B_NOPART
"LIST_TYPE_CODE" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE NOT VALIDATED USER NAME 19-JAN-11
QP TMP$$_SYS_C00437861 C
QP_LIST_HEADERS_B_NOPART
"LAST_UPDATE_DATE" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE NOT VALIDATED USER NAME 19-JAN-11
QP TMP$$_SYS_C00437871 C
QP_LIST_HEADERS_B_NOPART
"LAST_UPDATED_BY" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE NOT VALIDATED USER NAME 19-JAN-11
QP TMP$$_SYS_C00437851 C
QP_LIST_HEADERS_B_NOPART
"CREATED_BY" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE NOT VALIDATED USER NAME 19-JAN-11
6 rows selected.
SQL> C/NOPART/PART
1* SELECT * FROM DBA_CONSTRAINTS WHERE TABLE_NAME = 'QP_LIST_HEADERS_B_PART'
SQL> /
OWNER CONSTRAINT_NAME C
------------------------------ ------------------------------ -
TABLE_NAME
------------------------------
SEARCH_CONDITION
--------------------------------------------------------------------------------
R_OWNER R_CONSTRAINT_NAME DELETE_RU STATUS
------------------------------ ------------------------------ --------- --------
DEFERRABLE DEFERRED VALIDATED GENERATED BAD RELY LAST_CHAN
-------------- --------- ------------- -------------- --- ---- ---------
INDEX_OWNER INDEX_NAME INVALID
------------------------------ ------------------------------ -------
VIEW_RELATED
--------------
QP TMP$$_SYS_C00437830 C
QP_LIST_HEADERS_B_PART
"LIST_HEADER_ID" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE VALIDATED GENERATED NAME 15-JUN-04
QP TMP$$_SYS_C00437840 C
QP_LIST_HEADERS_B_PART
"CREATION_DATE" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE VALIDATED GENERATED NAME 15-JUN-04
QP TMP$$_SYS_C00437850 C
QP_LIST_HEADERS_B_PART
"CREATED_BY" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE VALIDATED GENERATED NAME 15-JUN-04
QP TMP$$_SYS_C00437860 C
QP_LIST_HEADERS_B_PART
"LAST_UPDATE_DATE" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE VALIDATED GENERATED NAME 15-JUN-04
QP TMP$$_SYS_C00437870 C
QP_LIST_HEADERS_B_PART
"LAST_UPDATED_BY" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE VALIDATED GENERATED NAME 15-JUN-04
QP TMP$$_SYS_C00437880 C
QP_LIST_HEADERS_B_PART
"LIST_TYPE_CODE" IS NOT NULL
ENABLED
NOT DEFERRABLE IMMEDIATE VALIDATED GENERATED NAME 15-JUN-04
6 rows selected.