打对了

宇宙和生命从哪里来?又要到哪里去呢?

 

导入的数据,删除约束后没有自动删除对应索引,重建约束出错

查了资料,有两种情况,一种Oracle 10G的一个BUG:3894962,但一直没有发布补丁。

Note:292096.1,Note:370633.1这两篇文章有介绍,当导出导入表的时候,如果有主键约束及索引,索引导入的时候没有和主键约束建立依赖,所以删除约束时,索引没有被删除。

另一种情况是Oracle 10G的一项改变,Note:309821.1

提供的解决办法就是加上删除索引的语法:alter table < table > drop constraint < constraint > drop index;
注意:
Drop index的语法是9i才支持的。

Subject: Oracle 10G Does not Drop User Index Associated With Unique/Primary Key Constraints
  Doc ID: Note:309821.1 Type: PROBLEM
  Last Revision Date: 31-MAY-2005 Status: MODERATED
<script language="JavaScript"></script>

The information in this document applies to:

Oracle Server - Enterprise Edition - Version: 10.1.0.2 to 10.2.0.0
This problem can occur on any platform.

Symptoms

Drop constraint does not drop a associated index in 10G

Cause


In 10g, a change was made to an internal function "atbdui" to not to drop the user index when the constraint using the index is dropped.

In 9i, this behavior is different the user index
gets dropped when the constraint is dropped.

Select index_name,generated from dba_indexes where index_name='< ;index_name >';

Generated column would show 'Y' If the index is system generated.If 'N' ,it is user generated.

Solution


This behaviour is because of the code changes made in 10G.

Use the workaround:

alter table < table > drop constraint < constraint > drop index;

Note

If the index is non unique, we can still use them for enforcing primary key constraints or unique constraints.

But dropping the constraint does not drop the non-unique index.
This behaviour is seen from 8174 to 10.2.0.0.

Sample Output

SQL> create table test( a number );

Table created.

SQL> create index ind on test ( a );

Index created.

SQL> alter table test add constraint c1_pk primary key(a) using index;

Table altered.

SQL> select index_name from user_indexes where table_name='TEST';

INDEX_NAME
------------------------------
IND

SQL> alter table test drop constraint c1_pk;

Table altered.

SQL> select index_name from user_indexes where table_name='TEST';

INDEX_NAME
------------------------------
IND

References

Note 292096.1 - Encountering ora-00955 when trying to create primary key on an imported table in 10g

Keywords

'USING~INDEX'  

posted on 2007-06-14 13:24 知道得越多知道的越少 阅读(260) 评论(0)  编辑 收藏 网摘 所属分类: Oracle


标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
Google站内搜索

相关文章:

相关链接:


 

导航

统计

公告

对你说打错了 我不是你那个什么
你想找的那个 就算我跟她同名同姓又如何
都说你打错了 我要欺骗你干什么
你们多久没见连 我跟她的声音你都不认得
你怎么样过 什么样的生活 是否难耐寂寞
你到底是谁 总是阴差阳错 擦过我的耳朵
第几次打错了 这是注定还是巧合
谁是玛格列特 她知道你的着急一定很快乐
你们发生什么 还是你欠了她什么
有什么舍不得 她不住这里你却非找她不可
你怎么样过 什么样的生活 是否难耐寂寞
你到底是谁 总是阴差阳错 擦过我的耳朵
你怎么样过 什么样的生活 是否难耐寂寞
你到底是谁 总是阴差阳错 擦过我的耳朵
你们会讲什么口气会不会软软的
你紧张得想哭 多年后想起今天值得不值得

与我联系

搜索

 

常用链接

留言簿(4)

我参与的团队

我的标签

随笔分类

随笔档案

文章分类

文章档案

收藏夹

音乐

有价值的blog

最新评论

阅读排行榜

评论排行榜