您的位置:首页 > 其它

34.You created an ORDERS table with the following description:

2016-01-26 15:33 531 查看
34.You created an ORDERS table with the following description:

name Null Type

ORD_ID NOT NULL NUMBER(2)

CUST_ID NOT NULL NUMBER(3)

ORD_DATE NOT NULL DATE

ORD_AMOUNT NOT NULL NUMBER (10,2)

You inserted some rows in the table. After some time, you want to alter the table by creating the

PRIMARY KEY constraint on the ORD_ID column. Which statement is true in this scenario?

A.You cannot have two constraints on one column.

B.You cannot add a primary key constraint if data exists in the column.

C.The primary key constraint can be created only at the time of table creation .

D.You can add the primary key constraint even if data exists, provided that there are no duplicate values.

答案:D

解析:

A:不能在一个列上创建2个约束,显然不对,not null + unique ==primary key

B:如果一个列上已经有数据了,那么不能增加主键约束,这个也是错误的,主键相当于not nul和unique ,只要数据不违反这两种那么就可以增加

C:主键只能在创建表的时候增加,这个也是错误的

D:正确
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: