Oracle 唯一 索引 约束 创建 删除
http://www.blogjava.net/lukangping/articles/340683.html/*给创建bitmap index分配的内存空间参数,以加速建索引*/
show parameter create_bit;
/*改变索引的存储参数*/
alter index index_name pctfree 30 storage(initial 200k next 200k);
/*给索引手工分配一个分区*/
alter index index_name allocate extent (size 200k datafile ‘$ORACLE/oradata/..‘);
/*释放索引中没用的空间*/
alter index index_name deallocate unused;
/*索引重建*/
alter index index_name rebuild tablespace tablespace_name;
/*普通索引和反转索引的互换*/
alter index index_name rebuild tablespace tablespace_name reverse;
/*重建索引时,不锁表*/
alter index index_name rebuild online;
/*给索引整理碎片*/
alter index index_name COALESCE;
/*分析索引,事实上是更新统计的过程*/
analyze index index_name validate structure;
desc index_state;
drop index index_name;
alter index index_name monitoring usage;-----监视索引是否被用到
alter index index_name nomonitoring usage;----取消监视
/*有关索引信息的视图*/
select * from dba_indexes/dba_ind_columns/dbs_ind_eXPressions/v$object_usage;
########## 数据完整性的治理(Maintaining data integrity) ##########
alter table table_name drop constraint constraint_name;----drop 约束
alter table table_name add constraint constraint_name primary key(column_name1,column_name2);-----创建主键
alter table table_name add constraint constraint_name unique(column_name1,column_name2);---创建唯一约束
/*创建外键约束*/
alter table table_name add constraint constraint_name foreign key(column_name1) references table_name(column_name1);
/*不效验老数据,只约束新的数据[enable/disable:约束/不约束新数据;novalidate/validate:不对/对老数据进行验证]*/
alter table table_name add constraint constraint_name check(column_name like ‘B%‘) enable/disable novalidate/validate;
/*修改约束条件,延时验证,commit时验证*/
alter table table_name modify constraint constraint_name initially deferred;
/*修改约束条件,立即验证*/
alter table table_name modify constraint constraint_name initially immediate;
alter session set constraints=deferred/immediate;
/*drop一个有外键的主键表,带cascade constraints参数级联删除*/
drop table table_name cascade constraints;
/*当truncate外键表时,先将外键设为无效,再truncate;*/
truncate table table_name;
/*设约束条件无效*/
alter table table_name disable constraint constraint_name;
alter table table_name enable novalidate constraint constraint_name;
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。