--在删除一个表主键的时候索引没有删掉的问题,如果主键索引是和主键约束一起建的, 则删除约束的时候索引会自动删除掉,如果是先建了索引,然后建立主键,则删除约束的时候索引不会一起被删除掉测试: --创建测试表 create table dbmgr.test_pk as select * from REINSDATA.REINS_PROP_PLAN_ADJ where rownum <1000--创建主键,同时创建索引,这里using index是默认的,如果不加还是会using index的 --using index alter table dbmgr.test_pk add constraint PK_test primary key (DANGERUNITNO, RERISKCODE, TTYID, CERTINO, RISKCODE) using index--删除约束 alter table dbmgr.test_pk drop constraint PK_test--结果:约束和索引均被删掉--再先创建一个唯一约束,然后添加对应的主键约束 --create unique index create unique index dbmgr.PK_test on dbmgr.test_pk(DANGERUNITNO, RERISKCODE, TTYID, CERTINO, RISKCODE)alter table dbmgr.test_pk add constraint PK_test primary key (CERTINO,RERISKCODE,RISKCODE,DANGERUNITNO,TTYID)--删除约束 alter table dbmgr.test_pk drop constraint PK_test --结果:此时索引没有被删除--对于这种情况,我们需要加上drop index选项,这样无论那种情况索引都会被删除 alter table dbmgr.test_pk drop constraint PK_test drop index;更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12本文永久更新链接地址