[每日一题] OCP1z0-047 :2013-08-14 如何理解USING INDEX?...................................41
正确答案:B
一、USING INDEX的实验:
、USING 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
、这时我想把主键删除,但我想保留唯一索引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
、然后我又想创建主键,但我想直接用刚刚创建的唯一索引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 the using_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
tableis partitioned, then you can specify a locally or globally partitioned index for the unique or primary key constraint.
Restrictions on theusing_index_clause The following restrictions apply to theusing_index_clause:
You cannot specify this clause for a view constraint.
You cannot specify this clause for a
NOTNULL, 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_clauseofindex_propertiesor theparallel_clauseofindex_attributes.
[每日一题] OCP1z0-047 :2013-08-14 如何理解USING INDEX?...................................41的更多相关文章
- Cheatsheet: 2013 08.14 ~ 08.19
.NET Lucene.Net ultra fast search for MVC or WebForms site => made easy! C# State Machines HttpCl ...
- CISP/CISA 每日一题 14
CISA 每日一题(答) 自动无人值守运行(LIGHTS-OUT)优势:1.信息系统运行成本的遏制/减少:2.持续运行(24/7):3.减少系统错误和中断次数. I/O 控制人员负责保证:1.批处理信 ...
- 老男孩IT教育-每日一题汇总
老男孩IT教育-每日一题汇总 第几天 第几周 日期 快速访问链接 第123天 第二十五周 2017年8月25日 出现Swap file….already exists以下错误如何解决? 第122天 2 ...
- PL/SQL Challenge 每日一题:2014-3-14 11gR2中带RELIES_ON子句的RESULT_CACHE函数
PL/SQL Challenge 每日一题:2014-3-14 11gR2中带RELIES_ON子句的RESULT_CACHE函数 最先答对且答案未经编辑的puber将获得纪念章一枚(答案不可编辑但可 ...
- CISP/CISA 每日一题 五
CISA 每日一题(答) 信息系统审计师要确认系统变更程序中的: 1.变更需求应有授权.优先排序及跟踪机制: 2.日常工作手册中,明确指出紧急变更程序: 3.变更控制程序应同时为用户及项目开发组认可: ...
- [每日一题]面试官问:谈谈你对ES6的proxy的理解?
[每日一题]面试官问:谈谈你对ES6的proxy的理解? 关注「松宝写代码」,精选好文,每日一题 作者:saucxs | songEagle 一.前言 2020.12.23 日刚立的 flag,每日一 ...
- 【JavaScript】Leetcode每日一题-在D天内送包裹的能力
[JavaScript]Leetcode每日一题-在D天内送包裹的能力 [题目描述] 传送带上的包裹必须在 D 天内从一个港口运送到另一个港口. 传送带上的第 i 个包裹的重量为 weights[i] ...
- 【python】Leetcode每日一题-寻找旋转排序数组中的最小元素
[python]Leetcode每日一题-寻找旋转排序数组中的最小元素 [题目描述] 已知一个长度为 n 的数组,预先按照升序排列,经由 1 到 n 次 旋转 后,得到输入数组.例如,原数组nums ...
- 【JavaScript】【dp】Leetcode每日一题-解码方法
[JavaScript]Leetcode每日一题-解码方法 [题目描述] 一条包含字母 A-Z 的消息通过以下映射进行了 编码 : 'A' -> 1 'B' -> 2 ... 'Z' -& ...
随机推荐
- Excel等外部程序点击链接会带上IE信息的bug
今天碰到一个问题,在Excel内点击链接到默认浏览器Chrome打开,奇怪的是服务端收到的Session一直对不上. 查了很久发现这个Excel到Chrome的跳转竟然带上了IE的Cookie 和 U ...
- php实现返回上一页的功能的3种有效方法
php实现返回上一页的功能的3种有效方法 header(location:你的上一页的路径); // 注意这个函数前不能有输出 header(location:.getenv("HT ...
- you need to be root to perform this command linux
获得root权限如何获得:打开终端,输入su回车 然后输入密码回车就行了
- django访问sqlserver中的坑
首先不用说先安装django-sqlserver pip install django-sqlserver 然后在settings.py中修改'ENGINE': 'sqlserver_ado', ...
- test知识
内部测试SIT ——system integration testcase 用户测试UAT——user acceptance test SIT是集成测试UAT是验收测试从时间上看,UAT要在SIT后面 ...
- (转载)50个c/c++源代码网站
C/C++是最主要的编程语言.这里列出了50名优秀网站和网页清单,这些网站提供c/c++源代码.这份清单提供了源代码的链接以及它们的小说明.我已 尽力包括最佳的C/C++源代码的网站.这不是一个完整的 ...
- OpenCV 2.4.3在VS2010上的应用
一.下载和安装: 1.OpenCV 2.4.3下载:http://www.opencv.org.cn/index.php/Download#Version_2.4.3 2.下载完成后,解压 ...
- POJ-3693-Maximum repetition substring(后缀数组-重复次数最多的连续重复子串)
题意: 给出一个串,求重复次数最多的连续重复子串 分析: 比较容易理解的部分就是枚举长度为L,然后看长度为L的字符串最多连续出现几次. 既然长度为L的串重复出现,那么str[0],str[l],str ...
- 1B. Spreadsheets
题目大意: 行和列的两种方式. A是1, B是2,....Z是26, AA是27, AB是28........... 如: BC23代表55列23行 还有一种表示方法:R23C55, 代表23行,55 ...
- linux(ubuntu)下分区和格式化sd卡
我的手机sd卡需要分成两个分区,在windowxp下面死活搞不成.主要的问题是,window只认识sd卡的第一个分区.有人用修改驱动程序,让windows把sd卡认成日立的microdisk,分区和格 ...