您的位置:首页 > 其它

OCP-1Z0-051 第30题 主外键约束,check约束

2014-04-30 17:18 513 查看
一、原题

Evaluate the following CREATE TABLE commands:
CREATE TABLE orders

(ord_no NUMBER(2) CONSTRAINT ord_pk PRIMARY KEY,

ord_date DATE,

cust_id NUMBER(4));

CREATE TABLE ord_items

(ord_no NUMBER(2),

item_no NUMBER(3),

qty NUMBER(3) CHECK (qty BETWEEN 100 AND 200),

expiry_date date CHECK (expiry_date > SYSDATE),

CONSTRAINT it_pk PRIMARY KEY (ord_no,item_no),

CONSTRAINT ord_fk FOREIGN KEY(ord_no) REFERENCES orders(ord_no));
The above command fails when executed. What could be the reason?
A. SYSDATE cannot be used with the CHECK constraint.
B. The BETWEEN clause cannot be used for the CHECK constraint.

C. The CHECK constraint cannot be placed on columns having the DATE data type.

D. ORD_NO and ITEM_NO cannot be used as a composite primary key because ORD_NO is also the FOREIGN KEY.

答案:A

二、题目翻译

评估下面的建表语句:

上面的命令执行失败,原因是什么?

A. SYSDATE不能用于CHECK约束中。

B. BETWEEN子句不能用于CHECK约束中。

C. CHECK约束不能作用在DATE类型的列。

D. ORD_NO和ITEM_NO不能作为组合主键,因为ORD_NO是一个外键。

三、题目解析

BETWEEN可以用于CHECK约束,

CHECK约束可以作用在DATE类型的列,

D选项没有这个限制,即使ORD_NO为一个外键,ORD_NO和ITEM_NO也可以组成组合主键。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息