[每日一题] OCP1z0-047 :2013-08-14 如何理解USING INDEX?...................................41

转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/9972521




正确答案:B


一、USING INDEX的实验:

1USING INDEX可以让你在创建主键、唯一性约束的时候使用指定的索引或创建索引、或修改索引的存储结构。

OK,我先不用USING INDEX,创建主键时Oracle自动创建唯一索引。


gyj@MYDB> alter table emp add constraint emp_id_pk primary key(employee_id);

Table altered.

gyj@MYDB> select INDEX_NAME from user_constraints where CONSTRAINT_NAME='EMP_ID_PK';

INDEX_NAME
------------------------------
EMP_ID_PK

gyj@MYDB> select UNIQUENESS from user_indexes where index_name='EMP_ID_PK';

UNIQUENES
---------
UNIQUE


2、这时我想把主键删除,但我想保留唯一索引EMP_ID_PK,即约束可以被独立drop,而索引可以保留。

gyj@MYDB> ALTER TABLE emp DROP PRIMARY KEY KEEP INDEX;

Table altered.

gyj@MYDB> select UNIQUENESS from user_indexes where index_name='EMP_ID_PK';

UNIQUENES
---------
UNIQUE

gyj@MYDB>  select INDEX_NAME from user_constraints where CONSTRAINT_NAME='EMP_ID_PK';

no rows selected

3、然后我又想创建主键,但我想直接用刚刚创建的唯一索引EMP_ID_PK。此时我就要用USING INDEX

gyj@MYDB> alter table emp add constraint emp_id_pk primary key(employee_id) using index EMP_ID_PK;

Table altered.


二、      USING INDEX在官方文的解释:

Using Indexes to Enforce Constraints

When defining the state of a unique or primary key constraint, you can specify an index for Oracle to use to enforce the constraint, or you can instruct Oracle to create the index used to enforce the constraint.

using_index_clauseYou can specify theusing_index_clause only when enabling unique or primary key constraints. You can specify the clauses of theusing_index_clause in any order, but you can specify each clause only once.

  • If you specify schema.index, then Oracle attempts to enforce the constraint using the specified index. If Oracle cannot find the index or cannot use the index to enforce the constraint, then Oracle returns an error.

  • If you specify the create_index_statement, then Oracle attempts to create the index and use it to enforce the constraint. If Oracle cannot create the index or cannot use the index to enforce the constraint, then Oracle returns an error.

  • If you neither specify an existing index nor create a new index, then Oracle creates the index. In this case:

    • The index receives the same name as the constraint.

    • If table is partitioned, then you can specify a locally or globally partitioned index for the unique or primary key constraint.

Restrictions on theusing_index_clauseThe following restrictions apply to theusing_index_clause:

  • You cannot specify this clause for a view constraint.

  • You cannot specify this clause for a NOT NULL, foreign key, or check constraint.

  • You cannot specify an index (schema.index) or create an index (create_index_statement) when enabling the primary key of an index-organized table.

  • You cannot specify the domain_index_clause of index_properties or theparallel_clause ofindex_attributes.

QQ:252803295

学习交流QQ群:
DSI&Core Search  Ⅰ 群:127149411(技术:已满)
DSI&Core Search  Ⅱ 群:177089463(技术:未满)
DSI&Core Search  Ⅲ 群:284596437(技术:未满)
DSI&Core Search  Ⅳ 群:192136702(技术:未满)
DSI&Core Search  Ⅴ 群:285030382(闲聊:未满)



MAIL:oracledba_cn@hotmail.com

BLOG: http://blog.csdn.net/guoyjoe

WEIBO:http://weibo.com/guoyJoe0218

ITPUB: http://www.itpub.net/space-uid-28460966.html

OCM:   http://education.oracle.com/education/otn/YGuo.HTM


  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MySQL 8 OCP (Oracle Certified Professional)1Z0-908是一套关于MySQL数据库的考试题库。MySQL是一种流行的开源关系型数据库管理系统。此考试题库旨在评估考生对MySQL数据库的知识、技能和能力。 MySQL 8 OCP 1Z0-908题库包含了多个主题,涵盖了MySQL数据库的各个方面。主要的考题包括: 1. MySQL 8的新功能和改进:考核考生对于MySQL8版本中新增的新功能和改进的理解和应用。 2. 数据库设计和建模:考核考生在设计和建模数据库时的能力,包括定义和优化表、索引、视图、存储过程和触发器等数据库对象。 3. 查询和数据操作:考核考生编写和优化SQL查询和数据操作的能力,包括基本查询、多表联接、子查询、聚合函数和事务处理等。 4. 数据库安全和性能优化:考核考生在数据库安全性和性能优化方面的知识和实践,包括用户和权限管理、备份和恢复、性能调优和查询优化等。 5. 数据库监控和维护:考核考生对于数据库监控和维护的能力,包括定期备份、日志分析、故障排除和性能调优等。 通过MySQL 8 OCP 1Z0-908的考试,考生可以证明自己在MySQL数据库管理方面的专业能力和水平。对于数据库管理员、开发人员和其他与数据库相关工作的人员来说,持有MySQL OCP认证可以提升职业竞争力,获得更好的工作机会。因此,掌握和熟悉MySQL 8 OCP 1Z0-908题库中的内容对于有意考取MySQL OCP认证的人来说是非常重要的。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值