ORA-14060的解決
作者 :【轉載時請務必以超連結形式標明文章原始出處和作者資訊】
連結:
由於業務邏輯的改變,需要增加分割槽,分割槽鍵想由VARCHAR2(1)改為VARCHAR2(2)。報了個:
ORA-14060: data type or length of a table partitioning column may not be changed
解決方法挺簡單的,就是使用exchange partition。
簡單模擬如下:
SQL> create table LIST_PAR_TBL 2 ( 3 PARTITION_ID VARCHAR2(1) not null, 4 NAME VARCHAR2(14) 5 ) 6 partition by list (PARTITION_ID) 7 ( partition P01 values ('1'), 8 partition P02 values ('2'), 9 partition P03 values ('3'), 10 partition P04 values ('4'), 11 partition P05 values ('5'), 12 partition P06 values ('6') 13 ); Table created. SQL> insert into LIST_PAR_TBL values('1','p1'); 1 row created. SQL> insert into LIST_PAR_TBL values('2','p2'); 1 row created. SQL> insert into LIST_PAR_TBL values('3','p3'); 1 row created. SQL> insert into LIST_PAR_TBL values('4','p4'); 1 row created. SQL> insert into LIST_PAR_TBL values('5','p5'); 1 row created. SQL> insert into LIST_PAR_TBL values('6','p6'); 1 row created. SQL> commit; Commit complete. SQL> select * from LIST_PAR_TBL partition(p01); P NAME - -------------- 1 p1 SQL> select * from LIST_PAR_TBL partition(p06); P NAME - -------------- 6 p6 SQL> alter table LIST_PAR_TBL modify PARTITION_ID VARCHAR2(2); alter table LIST_PAR_TBL modify PARTITION_ID VARCHAR2(2) * ERROR at line 1: ORA-14060: data type or length of a table partitioning column may not be changed |
接下來就是針對各個分割槽,建立結構相同的表,進行exchange:
SQL> create table LIST_PAR_TBL_P01 2 ( 3 PARTITION_ID VARCHAR2(1) not null, 4 NAME VARCHAR2(14) 5 ); Table created. SQL> create table LIST_PAR_TBL_P02 2 ( 3 PARTITION_ID VARCHAR2(1) not null, 4 NAME VARCHAR2(14) 5 ); Table created. SQL> create table LIST_PAR_TBL_P03 2 ( 3 PARTITION_ID VARCHAR2(1) not null, 4 NAME VARCHAR2(14) 5 ); Table created. SQL> SQL> create table LIST_PAR_TBL_P04 2 ( 3 PARTITION_ID VARCHAR2(1) not null, 4 NAME VARCHAR2(14) 5 ); Table created. SQL> SQL> create table LIST_PAR_TBL_P05 2 ( 3 PARTITION_ID VARCHAR2(1) not null, 4 NAME VARCHAR2(14) 5 ); Table created. SQL> SQL> create table LIST_PAR_TBL_P06 2 ( 3 PARTITION_ID VARCHAR2(1) not null, 4 NAME VARCHAR2(14) 5 ); Table created. SQL> SQL> alter table LIST_PAR_TBL exchange partition P01 with table LIST_PAR_TBL_P01; Table altered. SQL> select * from LIST_PAR_TBL_P01; P NAME - -------------- 1 p1 SQL> select * from LIST_PAR_TBL partition (P01); no rows selected SQL> SQL> alter table LIST_PAR_TBL exchange partition P02 with table LIST_PAR_TBL_P02; Table altered. SQL> alter table LIST_PAR_TBL exchange partition P03 with table LIST_PAR_TBL_P03; Table altered. SQL> alter table LIST_PAR_TBL exchange partition P04 with table LIST_PAR_TBL_P04; Table altered. SQL> alter table LIST_PAR_TBL exchange partition P05 with table LIST_PAR_TBL_P05; Table altered. SQL> alter table LIST_PAR_TBL exchange partition P06 with table LIST_PAR_TBL_P06; Table altered. SQL> SQL> select * from LIST_PAR_TBL; no rows selected |
重建分割槽表,修改相應欄位,再將資料exchange回來:
SQL> drop table LIST_PAR_TBL; Table dropped. SQL> create table LIST_PAR_TBL 2 ( 3 PARTITION_ID VARCHAR2(2) not null, 4 NAME VARCHAR2(14) 5 ) 6 partition by list (PARTITION_ID) 7 ( partition P01 values ('1'), 8 partition P02 values ('2'), 9 partition P03 values ('3'), 10 partition P04 values ('4'), 11 partition P05 values ('5'), 12 partition P06 values ('6') 13 ); Table created. SQL> alter table LIST_PAR_TBL_P01 modify PARTITION_ID varchar2(2); Table altered. SQL> alter table LIST_PAR_TBL exchange partition P01 with table LIST_PAR_TBL_P01; Table altered. SQL> select * from LIST_PAR_TBL partition(p01); PA NAME -- -------------- 1 p1 SQL> select * from LIST_PAR_TBL_P01; no rows selected SQL> alter table LIST_PAR_TBL_P02 modify PARTITION_ID varchar2(2); Table altered. SQL> alter table LIST_PAR_TBL_P03 modify PARTITION_ID varchar2(2); Table altered. SQL> alter table LIST_PAR_TBL_P04 modify PARTITION_ID varchar2(2); Table altered. SQL> alter table LIST_PAR_TBL_P05 modify PARTITION_ID varchar2(2); Table altered. SQL> alter table LIST_PAR_TBL_P06 modify PARTITION_ID varchar2(2); Table altered. SQL> alter table LIST_PAR_TBL exchange partition P02 with table LIST_PAR_TBL_P02; Table altered. SQL> alter table LIST_PAR_TBL exchange partition P03 with table LIST_PAR_TBL_P03; Table altered. SQL> alter table LIST_PAR_TBL exchange partition P04 with table LIST_PAR_TBL_P04; Table altered. SQL> alter table LIST_PAR_TBL exchange partition P05 with table LIST_PAR_TBL_P05; Table altered. SQL> alter table LIST_PAR_TBL exchange partition P06 with table LIST_PAR_TBL_P06; Table altered. SQL> select * from LIST_PAR_TBL; PA NAME -- -------------- 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 6 rows selected. SQL> select * from LIST_PAR_TBL_P06; no rows selected SQL> desc LIST_PAR_TBL; Name Null? Type -------------------- -------- ------------------ PARTITION_ID NOT NULL VARCHAR2(2) NAME VARCHAR2(14) SQL> |
另外需要注意的是,exchange partition需要兩個表的表結構相同,否則會報:
SQL> alter table LIST_PAR_TBL exchange partition P01 with table LIST_PAR_TBL_P01; alter table LIST_PAR_TBL exchange partition P01 with table LIST_PAR_TBL_P01 * ERROR at line 1: ORA-14097: column type or size mismatch in ALTER TABLE EXCHANGE PARTITION |
— The End —
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27036311/viewspace-735921/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORA-14060: data type or length of a table partitioning column may not be changed
- dns劫持怎麼解決 dns劫持的解決方法DNS
- TabError的解決方法Error
- ArtifactDescriptorException的解決方法Exception
- 解決MySQL server has gone away錯誤的解決方案MySqlServerGo
- SS報錯的解決
- iOS 解決MJPhotoBrowser的bugiOS
- 解決自己的提問
- ORA-00439的解決
- AIX dtterm not found的解決AI
- exp 超慢的解決
- Segmentation fault (coredump)的解決Segmentation
- 解決
- ios不支援fixed解決解決方案iOS
- 解決「問題」,不要解決問題
- ntldr is missing怎麼解決 ntldr丟失的解決辦法
- SSH 連線慢的解決方案詳解
- 常用的-前端跨域的解決前端跨域
- 如何解決sms-activate的解決問題
- 域名被牆怎麼解決,域名被牆怎麼解決,解決方案
- Jou 的解決方案系列:序言
- 黑蘋果的問題解決蘋果
- 分散式鎖的解決方案分散式
- 佈局的常用解決方案
- mpvue使用sass的解決方案Vue
- mpvue 使用sass的解決方案Vue
- 前端跨域的解決方案前端跨域
- 探索ABP的EventHub解決方案
- 人工智慧的解決方案人工智慧
- 遇到問題的解決方法
- 浮動坍塌的解決方案
- OpenStack 的NAT解決辦法
- 介面測試的解決方案
- ajax跨域的解決方案跨域
- display:flex解決的問題Flex
- 解決bigdecime的問題
- oracle 鎖問題的解決Oracle
- 開機grub提示的解決