轉摘:EXCHANGE PARTITION those pesky columns
感覺有點意思,特引用:
Here is my partitioned table
SQL> desc PAR
Name Null? Type
—————————– ——– ————
X NUMBER(38)
Y NUMBER(38)
and it has a couple of partitions
SQL> select partition_name
2 from dba_tab_partitions
3 where table_name = ‘PAR’;
PARTITION_NAME
——————————
P1
P2
So now I want to do the standard operation of creating a ‘template’ table which I can then use to perform. an exchange partition operation.
SQL> create table EXCH as
2 select * from PAR
3 where 1=0;
Table created.
SQL> desc EXCH
Name Null? Type
—————————– ——– ————–
X NUMBER(38)
Y NUMBER(38)
So now I’m ready to go…But then this happens…
SQL> alter table PAR exchange partition P1 with table EXCH;
alter table PAR exchange partition P1 with table EXCH
*
ERROR at line 1:
ORA-14097: column type or size mismatch in ALTER TABLE EXCHANGE PARTITION
Well…that’s odd. I created the EXCH table as simple create-table-as-select. Let’s try it again using the “WITHOUT VALIDATION” clause.
SQL> alter table PAR exchange partition P1 with table EXCH without validation;
alter table PAR exchange partition P1 with table EXCH without validation
*
ERROR at line 1:
ORA-14097: column type or size mismatch in ALTER TABLE EXCHANGE PARTITION
Nope…still problems. So I go back and double check the columns
SQL> select column_name
2 from dba_tab_columns
3 where table_name = ‘PAR’;
COLUMN_NAME
——————————
X
Y
SQL> select column_name
2 from dba_tab_columns
3 where table_name = ‘EXCH’;
COLUMN_NAME
——————————
X
Y
So what could be the problem ? Its a “sleeper problem”. Some time ago, I did something to the columns in my partitioned table that is no longer readily apparent.
I dropped a column. Or more accurately, because it was a partitioned table (and presumably a large table), I set a column to unused. What Oracle has done behind the scenes is retain that column but make it invisible for “day to day” usage. We can see that by querying DBA_TAB_COLS
SQL> select column_name
2 from dba_tab_cols
3 where table_name = ‘PAR’;
COLUMN_NAME
——————————
SYS_C00003_12121820:22:09$
Y
X
And there’s the culprit.
So am I stuck forever ? Do I have to drop the column ? Or reload the PAR table without the unused column ? All of those things don’t sound too palatable.
No. All I need do is get the columns in my template table into a similar state.
SQL> alter table EXCH add Z int;
Table altered.
SQL> alter table EXCH set unused column Z;
Table altered.
And we can try again…
SQL> alter table PAR exchange partition P1 with table EXCH;
Table altered.來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/354732/viewspace-753023/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Those配置
- CSS columnsCSS
- 分割槽函式partition by的基本用法【轉載】函式
- Color Rows and Columns
- Partition Pruning和Partition-Wise Joins
- 摘文
- CSS3 columnsCSSS3
- Clique Partition
- 摘果果
- rebuttal 摘錄
- oracle partition by group by,詳解partition by和group by對比Oracle
- CSS columns 多列布局CSS
- F. Color Rows and Columns
- 分割槽Partition
- rebuttal 摘錄(3)
- markdown使用摘記
- alter table drop unused columns checkpoint
- Exchange Online Mailbox RestorationAIREST
- 7.74 DATAOBJ_TO_PARTITIONOBJ
- 86. Partition List
- oracle partition by 語法Oracle
- B. Range and Partition
- progit摘錄筆記Git筆記
- 【精通比特幣】摘記比特幣
- PostgreSQL DBA(53) - PG 12 Generated columnsSQL
- CSS columns多列布局瀑布流CSS
- Exchange - Add Owner of Distribution Group
- Peace or partition? Cyprus - Espresso EconomistEspresso
- 7.73 DATAOBJ_TO_MAT_PARTITIONOBJ
- 3-Partition 問題
- 《癌症·真相》讀書簡摘
- 番茄工作法摘錄
- 知:孫子兵法摘錄
- 摘:裝飾器@property @setter
- 【SSL】2128可可摘蘋果蘋果
- Datatables學習筆記——columns.render筆記
- 【RabbitMQ】direct type exchange example in golangMQGolang
- 【RabbitMQ】topic type exchange example in golangMQGolang
- 【RabbitMQ】fanout type exchange example in golangMQGolang