日期:2014-05-16  浏览次数:20563 次

oracle 唯一约束

/*给创建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);