主键约束自动建立索引问题(二)

2014-11-24 13:04:19 · 作者: · 浏览: 1
4
15 12
15 10
如果一个表数据量多可通过如下方法查找
SQL> alter table t drop constraint pk_i;
Table altered.
SQL>conn y / 123
SQL> @$ORACLE_HOME/rdbms/admin/utlexcpt.sql
Table created.
SQL> alter table t add constraint pk_i primary key (i) exceptions into exceptions;
SQL>select * from t where rowid in (select row_id from exceptions) ;
I V
---------- ------------------------
15 12
15 10
找到了重复的记录
修正
SQL>update t set i=10 where v=12;
SQL> select * from t;
I V
---------- ----------
1 2
3 4
10 12
15 10
再建主键约束
SQL>alter table t add constraint pk_i primary key (i) ;
Table altered.