关于insert append的问题

[复制链接]
查看11 | 回复9 | 2017-3-27 08:04:23 | 显示全部楼层 |阅读模式
目前想将分区表A修改分区方式,原来按照字段col1分区,现修改为按col2分区。所以对某A表做移行过程中出现如下问题,请各位帮忙分析一下会是什么原因:
1、rename A to A_temp;
2、重建分区表A,建主键,其中字段和主键跟A_temp完全一致;
3、insert /*+ append*/ into A select * from A_temp;执行到这步时报主键冲突。
后来采用另外一种方式:
1、rename A to A_temp;
2、重建分区表A,其中字段和主键跟A_temp完全一致;这一步没有建主键约束
3、insert /*+ append*/ into A select * from A_temp;
4、对A表建唯一键约束(和A_temp一致)。报错。
后来发现表A比表A_temp多一条记录a,其余完全一致。但是记录a在表A_temp中明明是不存在的,且记录a和A_temp表中记录b主键是一致的,其中部分字段有差异。
对该问题比较困惑,这条记录a会是从哪里钻出来的恩,各位达人帮忙分析一下原因。谢谢!
回复

使用道具 举报

千问 | 2017-3-27 08:04:23 | 显示全部楼层
That's odd. Can you create a small test case so we can reproduce?
Yong Huang
回复

使用道具 举报

千问 | 2017-3-27 08:04:23 | 显示全部楼层
” 主键冲突, a会是从哪里钻出来的恩 “
查一下PK相同的重复记录,看看相似性
回复

使用道具 举报

千问 | 2017-3-27 08:04:23 | 显示全部楼层
我的理解,rename的话,索引还是保留的,所以新建索引会冲突。
回复

使用道具 举报

千问 | 2017-3-27 08:04:23 | 显示全部楼层
to Yong Huang:另外还有两张同数量级的表(几千万条纪录),,其他两张做同样的操作,,并没有出现该问题。。
回复

使用道具 举报

千问 | 2017-3-27 08:04:23 | 显示全部楼层
to tolywang
:查一下PK相同的重复记录,看看相似性
这个是啥意思??按主键group by 了一下,,没有count(*)大于1的。。
回复

使用道具 举报

千问 | 2017-3-27 08:04:23 | 显示全部楼层
新建表,不用Append试一下。
回复

使用道具 举报

千问 | 2017-3-27 08:04:23 | 显示全部楼层
Append should have no relationship with the values of record. This hint just used to restrict the data to be inserted to be placed at the end of the table. HWM will be increased after using APPEND hint. And it doesn't use free space in the eariler blocks in segment. So it's no effect with the row contents inside table.
回复

使用道具 举报

千问 | 2017-3-27 08:04:23 | 显示全部楼层
1、rename A to A_temp;
2、重建分区表A,建主键,其中字段和主键跟A_temp完全一致;
2.5 truncate table A
3、insert /*+ append*/ into A select * from A_temp;执行到这步时报主键冲突。
回复

使用道具 举报

千问 | 2017-3-27 08:04:23 | 显示全部楼层
原帖由 rollingpig 于 2008-4-29 16:38 发表
1、rename A to A_temp;
2、重建分区表A,建主键,其中字段和主键跟A_temp完全一致;
2.5 truncate table A
3、insert /*+ append*/ into A select * from A_temp;执行到这步时报主键冲突。


这有效果吗?
表A不是新建的吗,难道会有数据?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行