当前位置: 代码迷 >> Oracle认证考试 >> about constraints?的一个小疑点
  详细解决方案

about constraints?的一个小疑点

热度:664   发布时间:2013-02-26 00:00:00.0
about constraints?的一个小问题!
Q: 40 Which two statements are true about constraints? (Choose two.)

A. The UNIQUE constraint does not permit a null value for the column.
B. A UNIQUE index gets created for columns with PRIMARY KEY and UNIQUE constraints.
C. The PRIMARY KEY and FOREIGN KEY constraints create a UNIQUE index.
D. The NOT NULL constraint ensures that null values are not permitted for the column.

Answer: B, D

问下,这里A为什么不对呢,unique约束不允许null值列也是正确的啊。如何不选呢?

------解决方案--------------------------------------------------------
unique允许null列阿

SQL> alter table test add name varchar2(20) unique;

Table altered.

SQL> select * from test;

ID NAME
---------- --------------------
1.2.1
1.1
1.2
1.10
1.12
1.1.2
1.1.1
1.1.12
222

9 rows selected.


------解决方案--------------------------------------------------------
A. The UNIQUE constraint does not permit a null value for the column. 
唯一约束列是允许有空值的,但主键列不能为空;这是唯一约束和主键约束的区别
B. A UNIQUE index gets created for columns with PRIMARY KEY and UNIQUE constraints. 
C. The PRIMARY KEY and FOREIGN KEY constraints create a UNIQUE index. 
主键和外键并没有约束创建唯一索引
D. The NOT NULL constraint ensures that null values are not permitted for the column. 

所以是B和D