一个表的主键使用了唯一索引,我直接用
alter table xxx drop constraints pk_xxx;
删除主键,DB扫描时提示说删除约束时必须指定keep index保留索引。
百度了一下,看到了http://zhaolinjnu.i.sohu.com/blog/view/75962031.htm这篇文章。
下面是它的原文:
我们通常的操作是向表中的一列或几列添加一个唯一约束,但有些时候,因为应用方面的原因或者其它原因,我们又需要把约束删掉,但要保留索引.本篇文章就介绍了如何使用keep index的语法,请看下面的实验:
1.不使用keep index的语法来删除约束的情况:
SQL> create table t1(id number,nick varchar2(20));
Table created.
SQL> alter table t1 add constraint uk_t1_id unique(id);
Table altered.
SQL> select table_name,index_name from user_indexes where table_name='T1';
TABLE_NAME INDEX_NAME
------------------------------ ------------------------------
T1 UK_T1_ID
SQL> alter table t1 drop constraint uk_t1_id;
Table altered.
SQL> select table_name,index_name from user_indexes where table_name='T1';
no rows selected
2.使用keep index的语法来删除约束的情况
SQL> alter table t1 add constraint uk_t1_id unique(id);
Table altered.
SQL> select table_name,index_name from user_indexes where table_name='T1';
TABLE_NAME INDEX_NAME
------------------------------ ------------------------------
T1 UK_T1_ID
SQL> alter table t1 drop constraint uk_t1_id keep index;
Table altered.
SQL> select table_name,index_name from user_indexes where table_name='T1';
TABLE_NAME INDEX_NAME
------------------------------ ------------------------------
T1 UK_T1_ID
如果在创建约束前,先创建了索引;那么在删除约束时默认都只删除约束,而不会删除索引.如果你想在删除约束时,保留索引,我建议还是最好明确使用keep index的语法,以避免意想不到的问题发生.
相关推荐
KEEP池的使用十分简单,设置DB_KEEP_CACHE_SIZE的值大于0,就可以将其他对象的BUFFER_POOL参数设置为KEEP了。
Oracle_Index 索引
INSTR的用法 Oracle里的Indexof INSTR的用法 Oracle里的Indexof INSTR的用法 Oracle里的Indexof
Oracle index说明文档,详细说明
Oracle_Index 索引
Oracle Summary Index
Oracle B-Tree Index Internals
Oracle_Index 索引
Oracle数据库,更改表空间的命令,包括table、index、lob对象。
oracle index orcle 索引优化
oracle index index索引的8种使用模式
Oracle Index Internals.pdf
大型数据库系统技术课程 5-1-ORACLE_index Oracle索引 共38页.pptx
oracle 用户 全部 索引 all index sql
只需要在excel里面写好表名列名,即可通过本EXCEL自动生成oracle table index sequence syn等表信息,注:只支持office 32位,系统多少位不影响。。
oracle 数据库oracle 数据库oracle 数据库oracle 数据库oracle 数据库oracle 数据库oracle 数据库
第十三讲:oracle index管理 第十四讲:oracle Partitioned Tables and Indexes管理 第十五讲:oracle view管理 第十六讲:oracle sequences管理 第十七讲:oracle 触发器管理 第十八讲:oracle 用户管理 第十九讲:...
oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件oracle_课件
Oracle 9i Client (Oracle 9i 客户端) 简化版 (不安装Oracle客户端,也可以使用PLSQL Developer 不用安装Oracle客户端也可以使用PLSQL Developer 绿色! 安全! 轻便! 可靠! 1、本软件可作为简单的Oracle9i客户端...
http://www.oracle.com/technetwork/cn/database/windows/downloads/index-101312-zhs.html 此版本集成了Oracle 11g 11.2.0.1.0中的实用工具tnsping、exp/imp,支持 Object Browser、TOAD等 Oracle 管理工具,并...