OCP-1Z0-051-2015-36题

Which CREATE TABLE statement is valid? 找出创建表的格式正确的语句
A.
CREATE TABLE ord_details
(ord_no NUMBER(2) PRIMARY KEY,
item_no NUMBER(3) PRIMARY KEY,
ord_date DATE NOT NULL);
B.
CREATE TABLE ord_details
(ord_no NUMBER(2) UNIQUE, NOT NULL,
item_no NUMBER(3),
ord_date DATE DEFAULT SYSDATE NOT NULL);
C.
CREATE TABLE ord_details
(ord_no NUMBER(2) ,
item_no NUMBER(3),
ord_date DATE DEFAULT NOT NULL,
CONSTRAINT ord_uq UNIQUE (ord_no),
CONSTRAINT ord_pk PRIMARY KEY (ord_no));
D.
CREATE TABLE ord_details
(ord_no NUMBER(2),
item_no NUMBER(3),
ord_date DATE DEFAULT SYSDATE NOT NULL,
CONSTRAINT ord_pk PRIMARY KEY (ord_no, item_no));
Answer: D

Explanation:

A PRIMARY KEY constraint creates a primary key for the table. Only one primary key can be created for each table. 

一个表只有一个主键。A错。UNIQUE, NOT NULL之间不要逗号,列级约束不要逗号,B错

一个DEFAULT 后面没有指定默认值,C错

The PRIMARY KEY constraint is a column or a set of columns that uniquely identifies each row in a table. 

This constraint enforces the uniqueness of the column or column combination and ensures that no column that is part of the primary key can contain a null  value.

Note: Because uniqueness is part of the primary key constraint definition, 

the Oracle server enforces the uniqueness by implicitly (隐含的唯一性)creating a unique index on the primary key column or columns.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值