zoukankan      html  css  js  c++  java
  • OCP-1Z0-051-V9.02-47题

    47. View the Exhibit and examine the structure of ORD and ORD_ITEMS tables.
    The ORD_NO column is PRIMARY KEY in the ORD table and the ORD_NO and ITEM_NO columns are
    composite PRIMARY KEY in the ORD_ITEMS table.
    Which two CREATE INDEX statements are valid? (Choose two.) 
    A. CREATE INDEX ord_idx1 
    ON ord(ord_no);
    B. CREATE INDEX ord_idx2 
    ON ord_items(ord_no);
    C. CREATE INDEX ord_idx3 
    ON ord_items(item_no);
    D. CREATE INDEX ord_idx4 
    ON ord,ord_items(ord_no, ord_date,qty);
    Answer: BC
    答案解析:
    实验验证:
    1、创建两张表
    创建ord表
    sh@TESTDB> create table ord
      2  (ord_no number(2) not null,
      3  ord_date date,
      4  cust_id number(4));
     
    Table created.
    创建ord_items表
    sh@TESTDB> create table ord_items
      2  (ord_no number(2) not null,
      3  item_no number(3) not null,
      4  qty number(8,2));
     
    Table created.
     2、增加约束,使其满足题意
     
    sh@TESTDB> alter table ord add constraint pk_ord primary key(ord_no);
     
    Table altered.
     
    sh@TESTDB> alter table ord_items add constraint pk_ord_item primary key(ord_no,item_no);
     
    Table altered.
     
    A错误,因为ord_no是主键,已经自动创建了一个唯一的索引,故不能再创建索引。
    sh@TESTDB> create index ord_idx1 on ord(ord_no);
    create index ord_idx1 on ord(ord_no)
                                 *
    ERROR at line 1:
    ORA-01408: such column list already indexed

     
    B,C正确,虽然在两列创建了主键约束,即自动创建的唯一索引是按照两列的组合来创建的,所以单列是可以创建索引的,
    sh@TESTDB> CREATE INDEX ord_idx2 
      2  ON ord_items(ord_no);
     
    Index created.


    sh@TESTDB> CREATE INDEX ord_idx3 
      2  ON ord_items(item_no);
     
    Index created.
     

     
    D错误,属于语法错误,不能两张表同时建立索引
     
    sh@TESTDB> CREATE INDEX ord_idx4 
      2  ON ord,ord_items(ord_no, ord_date,qty);
    ON ord,ord_items(ord_no, ord_date,qty)
          *
    ERROR at line 2:
    ORA-00906: missing left parenthesis
  • 相关阅读:
    第五,六章
    第三,四章
    第一,二章
    20131019作业 2 分支、循环结构
    20131016课堂实验4
    20131014课堂实验3
    20131007国庆作业例7-11,7-12,7-13,7-14
    20131006国庆作业例7-7,7-8,7-9
    20131006国庆作业例7-4,7-5,7-6
    20131006国庆作业第七章例7-1,7-2,7-3
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13316933.html
Copyright © 2011-2022 走看看