OCP-1Z0-051-題目解析-第34題

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? 
(Orders表的結構如上,你已經插入了一些數據在表中,一段時間後,你想更新這個表,在表中把Ord_ID設置爲主鍵約束,關於這個方案哪個語句是正確的?)
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.
 
Answer: D 



A: 你不能在以個字段上添加兩個約束(錯誤,可以添加。如非空和唯一可以定義在一個字段上,前幾題中有ord_no NUMBER(2) UNIQUE NOT NULL)
B:如果字段上有數據,你不能添加主鍵 (錯誤,只要該字段符合主鍵的要求(即主鍵必須非空和唯一),就可以)
C:主鍵約束只能在建表的時候穿件( 錯誤,參照B)
D:你可以添加主鍵,即使有數據,條件是沒有重複值(正確:ORD_ID原先是非空約束,再加上無重複值,符合主鍵的要求)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章