暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle ETL使用exchange分区和ORA-14097

ASKTOM 2020-12-02
1822

问题描述

你好克里斯,你好康纳。

几乎每次我使用分区交换实现ETL进程时,我都会撞到一个ORA-14097: ALTER TABLE exchange分区中的列类型或大小不匹配。

这次我不知道原因是什么。exchange表是由cta * 语句创建的,没有不可见的列,因此列本身必须匹配。我比较了它们,它们确实匹配。目标表上没有主键。所有约束都匹配。

最令人困惑的是: 我已经创建了目标表的完整副本,包括DDL和data。在这个表上,cta * 交换分区语句确实有效!无论我是从原始表还是副本将交换表作为cta *。因此,我无法为您提供重现该问题的示例,对不起。

这种行为的原因是什么?

有没有比cta * 更好的创建交换表的方法?

除了 “检查你的专栏” 之外,还有什么更好的诊断ORA-14097的方法吗?

尽管这种加载方法很有吸引力,但每次实现它都是一种痛苦,主要是因为ORA-14097消息缺少任何细节。

专家解答

您是否有机会在分区表上有任何未使用的列?

您可以通过在 * _ tab_cols中查找并查找系统来发现这些... $ 命名列:

create table tgt (
  c1 int, c2 int
) partition by hash ( c1 ) (
  partition p1
);

alter table tgt
  set unused column c2;
  
select column_name 
from  user_tab_cols
where  table_name = 'TGT';

COLUMN_NAME                  
C1                            
SYS_C00002_20120310:32:37$   


这也将揭示可能引起问题的任何其他系统生成的列。

尽管您无法访问未使用的列,但它们确实阻止了分区交换:

create table src as 
  select * from tgt;
  
insert into src
with rws as (
  select level x from dual
  connect by level <= 3
)
  select * from rws;
commit;
  
alter table tgt 
  exchange partition p1 
  with table src;
  
ORA-14097: column type or size mismatch in ALTER TABLE EXCHANGE PARTITION


从12.2,您可以使用创建表来解决此问题...对于exchange命令:

drop table src;

create table src
  for exchange 
  with table tgt;
  
insert into src
with rws as (
  select level x from dual
  connect by level <= 3
)
  select * from rws;
commit;
  
alter table tgt 
  exchange partition p1 
  with table src;
    
select * from tgt;

C1   
    1 
    2 
    3 


在12.1时,从分区表中删除未使用的列:

truncate table tgt;
drop table src;
alter table tgt
  drop unused columns;

create table src as 
  select * from tgt;
  
insert into src
with rws as (
  select level + 10 x from dual
  connect by level <= 3
)
  select * from rws;
commit;
  
alter table tgt 
  exchange partition p1 
  with table src;
    
select * from tgt;

C1   
   11 
   12 
   13 

文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论