有疑问可以去itpub讨论:http://www.itpub.net/thread-1802421-1-1.html


[每日一题] OCP1z0-047 :2013-07-16  主键与唯一索引.............................................................5_OCP1z0


主键包括非空和唯一约束,它会自动创建唯一索引(注:唯一约束也会自动创建唯一索引),测试如下:

1、 创建一个表products

gyj@OCM> Create table products(

 2  product_id number(6) constraintprod_id_pk PRIMARY KEY,

 3  product_name varchar2(15)

 4  );

 

Table created.

 

2、 查表products的索引

gyj@OCM> select INDEX_NAME,INDEX_TYPE,UNIQUENESS fromuser_indexes where TABLE_NAME='PRODUCTS';

 

INDEX_NAME               INDEX_TYPE     UNIQUENES

------------------------------  ---------------------------   ---------

PROD_ID_PK               NORMAL         UNIQUE

 

 答案:B


补充:唯一约束也会自动创建唯一索引


gyj@OCM> create table t10 (id int unique,name varchar2(10));


Table created.


gyj@OCM> select INDEX_NAME,INDEX_TYPE,UNIQUENESS from user_indexes where TABLE_NAME='T10';


INDEX_NAME                     INDEX_TYPE                  UNIQUENES
------------------------------ --------------------------- ---------
SYS_C0011336                   NORMAL                      UNIQUE




 

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