【REDEFINITION】不可使用dbms_redefinition完成列型別的調整(ORA-42016)
線上重定義多用於以下場景
1)修改表的儲存引數
2)調整表空間
3)增加或刪除分割槽
4)將堆表改變為索引組織表
5)增加加或刪除列
其中堆表調整為分割槽表的應用場景較普遍。
參考一下Oracle官方文件中關於線上重定義的描述。
Oracle Database provides a mechanism to make table structure modifications without significantly affecting the availability of the table. The mechanism is called online table redefinition. Redefining tables online provides a substantial increase in availability compared to traditional methods of redefining tables.
Online table redefinition enables you to:
參考連結: ... bles.htm#ADMIN01514
注意因為線上重定義過程中要求列的屬性要相同,因此不可使用dbms_redefinition完成列型別的調整,實驗驗證之。
1.建立表T1,包含一個NUMBER型別的列
sec@ora10g> create table T1 (x NUMBER(19) primary key);
sec@ora10g> insert into t1 select rownum from all_objects;
11946 rows created.
sec@ora10g> commit;
Commit complete.
2.建立中間表T1
sec@ora10g> create table T2 (x varchar2(20) primary key);
3.授予使用者所需要的許可權
sec@ora10g> conn / as sysdba
Connected.
sys@ora10g> grant EXECUTE_CATALOG_ROLE,CREATE ANY TABLE,ALTER ANY TABLE,DROP ANY TABLE,LOCK ANY TABLE,SELECT ANY TABLE to sec;
Grant succeeded.
4.嘗試使用dbms_redefinition線上重定義
sec@ora10g> exec dbms_redefinition.abort_redef_table('SEC','T1','T2');
PL/SQL procedure successfully completed.
sec@ora10g> exec dbms_redefinition.can_redef_table('SEC','T1');
PL/SQL procedure successfully completed.
sec@ora10g> exec dbms_redefinition.start_redef_table('SEC','T1','T2');
BEGIN dbms_redefinition.start_redef_table('SEC','T1','T2'); END;
*
ERROR at line 1:
ORA-42016: shape of interim table does not match specified column mapping
ORA-06512: at "SYS.DBMS_REDEFINITION", line 50
ORA-06512: at "SYS.DBMS_REDEFINITION", line 1343
ORA-06512: at line 1
5.關於ORA-42016錯誤的解釋
sec@ora10g> !oerr ora 42016
42016, 0000, "shape of interim table does not match specified column mapping"
// *Cause: The number of columns, or the type or the length semantics of a
// column, in the interim table did not match the specified
// column mapping.
// *Action: Ensure that the interim table matches the column mapping by
// either modifying the column mapping string or altering the
// interim table's column definition(s).
6.小結
在使用一項新技術之前要充分了解本身的優勢和劣勢,這樣會提高我們工作效率。
Good luck.
secooler
10.03.18
-- The End --
1)修改表的儲存引數
2)調整表空間
3)增加或刪除分割槽
4)將堆表改變為索引組織表
5)增加加或刪除列
其中堆表調整為分割槽表的應用場景較普遍。
參考一下Oracle官方文件中關於線上重定義的描述。
Oracle Database provides a mechanism to make table structure modifications without significantly affecting the availability of the table. The mechanism is called online table redefinition. Redefining tables online provides a substantial increase in availability compared to traditional methods of redefining tables.
Online table redefinition enables you to:
- Modify the storage parameters of a table or cluster
- Move a table or cluster to a different tablespace in the same schema
- Add, modify, or drop one or more columns in a table or cluster
- Add or drop partitioning support (non-clustered tables only)
- Change partition structure
- Change physical properties of a single table partition, including moving it to a different tablespace in the same schema
- Change physical properties of a materialized view log or an Oracle Streams Advanced Queueing queue table
- Add support for parallel queries
- Re-create a table or cluster to reduce fragmentation
- Change the organization of a normal table (heap organized) to an index-organized table, or do the reverse.
- Convert a relational table into a table with object columns, or do the reverse.
- Convert an object table into a relational table or a table with object columns, or do the reverse.
參考連結: ... bles.htm#ADMIN01514
注意因為線上重定義過程中要求列的屬性要相同,因此不可使用dbms_redefinition完成列型別的調整,實驗驗證之。
1.建立表T1,包含一個NUMBER型別的列
sec@ora10g> create table T1 (x NUMBER(19) primary key);
sec@ora10g> insert into t1 select rownum from all_objects;
11946 rows created.
sec@ora10g> commit;
Commit complete.
2.建立中間表T1
sec@ora10g> create table T2 (x varchar2(20) primary key);
3.授予使用者所需要的許可權
sec@ora10g> conn / as sysdba
Connected.
sys@ora10g> grant EXECUTE_CATALOG_ROLE,CREATE ANY TABLE,ALTER ANY TABLE,DROP ANY TABLE,LOCK ANY TABLE,SELECT ANY TABLE to sec;
Grant succeeded.
4.嘗試使用dbms_redefinition線上重定義
sec@ora10g> exec dbms_redefinition.abort_redef_table('SEC','T1','T2');
PL/SQL procedure successfully completed.
sec@ora10g> exec dbms_redefinition.can_redef_table('SEC','T1');
PL/SQL procedure successfully completed.
sec@ora10g> exec dbms_redefinition.start_redef_table('SEC','T1','T2');
BEGIN dbms_redefinition.start_redef_table('SEC','T1','T2'); END;
*
ERROR at line 1:
ORA-42016: shape of interim table does not match specified column mapping
ORA-06512: at "SYS.DBMS_REDEFINITION", line 50
ORA-06512: at "SYS.DBMS_REDEFINITION", line 1343
ORA-06512: at line 1
5.關於ORA-42016錯誤的解釋
sec@ora10g> !oerr ora 42016
42016, 0000, "shape of interim table does not match specified column mapping"
// *Cause: The number of columns, or the type or the length semantics of a
// column, in the interim table did not match the specified
// column mapping.
// *Action: Ensure that the interim table matches the column mapping by
// either modifying the column mapping string or altering the
// interim table's column definition(s).
6.小結
在使用一項新技術之前要充分了解本身的優勢和劣勢,這樣會提高我們工作效率。
Good luck.
secooler
10.03.18
-- The End --
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-629864/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【REDEFINITION】使用線上重定義dbms_redefinition完成主鍵列型別的調整型別
- Oracle 11G DBMS_REDEFINITION修改表資料型別Oracle資料型別
- 【dbms包】dbms_redefinition
- Oracle DBMS_REDEFINITION Version 10.2Oracle
- Master Note:Online Redefinition of Tables (DBMS_REDEFINITION)_1357825.1AST
- 使用DBMS_REDEFINITION包執行線上重定義表(ONLINE TABLE REDEFINITION)
- dbms_redefinition線上重定義表
- Shrink a SECUREFILE LOB Using Online Redefinition (DBMS_REDEFINITION)?1394613.1
- Oracle線上重定義之DBMS_REDEFINITIONOracle
- Partitioning a table online with DBMS_REDEFINITION
- 利用DBMS_REDEFINITION線上重定義表
- 改變表的欄位順序dbms_REDEFINITION
- 使用DBMS_REDEFINITION線上重定義表普通表為分割槽表
- DBMS_REDEFINITION(線上重定義一個重要bug)
- 執行DBMS_REDEFINITION報ORA-42030錯誤
- 線上重定義表(Redefine Tables Online) - dbms_redefinition
- 分割槽表和dbms_redefinition包線上重定義表
- 利用dbms_redefinition實現普通heap表和分割槽表的轉化
- PostgreSQL安裝完成後,引數調整SQL
- 整數型別型別
- 列舉型別在JPA中的使用型別
- Java列舉型別的使用和原理Java型別
- C#中列舉型別的使用C#型別
- 使用dbms_redefinition包線上把大資料量非分割槽錶轉換為分割槽表大資料
- 【自動化】使用PL/SQL輔助完成表空間的分類調整SQL
- 整數型別(轉)型別
- 利用ORACLE DBMS_REDEFINITION包進行普通表到分割槽表的線上轉換Oracle
- Mysql 資料型別之整數型別MySQL 資料型別
- PostgreSQL 陣列型別使用詳解SQL陣列型別
- 如何設定textarea文字框不可以調整大小
- Python語法--可變型別和不可變型別Python型別
- Java列舉型別enum的詳解及使用Java型別
- 修改全域性變數時,可變型別和不可變型別的區別變數型別
- win10 怎麼調整工作列顯示樣式 win10怎麼調整工作列Win10
- 列舉型別型別
- 使用POI生成Excel檔案,可以自動調整excel列寬Excel
- 【劍指offer】調整陣列順序陣列
- Java不可不知的泛型使用Java泛型