oracle唯一索引和唯一约束

来源:互联网 发布:淘宝买小样靠谱点推荐 编辑:程序博客网 时间:2024/04/28 16:43

          1、创建唯一约束时会自动创建唯一索引,创建唯一索引时不会创建唯一约束。

           2、删除唯一约束时不会删除对应唯一索引。

           3、可以对非唯一索引建立唯一约束。

           4、用途不同,索引是为了加快检索速度,约束是为了保证数据完整性。

        创建索引:create index metaid_copys on i_copys(metaid,metatable) online;

       创建唯一约束:alter table i_copys add constraint cons_copys unique (metaid,metatable) using index metaid_copys;

       删除唯一约束:alter table i_copys drop constraint cons_copys cascade;