QUESTION 28
Which two statements are true regarding constraints? (Choose two.)
A. A foreign key cannot contain NULL values.B. A column with the UNIQUE constraint can contain NULL values.
C. A constraint is enforced only for the INSERT operation on a table.
D. A constraint can be disabled even if the constraint column contains data.
E. All constraints can be defined at the column level as well as the table level.
答案:BD
A选项错,外键可以是空。
SQL> create table test1(
2 t1 varchar(10) null);
Table created.
SQL> insert into test1 values('')
2 ;
1 row created.
SQL> select * from test1;
T1
--------------------
SQL> create table test2(id2 varchar2(10));
Table created.
SQL> alter table test2 add constraint pk primary key (id2)
2 ;
Table altered.
SQL> alter table test1 add constraint fk_test foreign key (t1) references test2(
id2);
Table altered.
B选项对,唯一约束可以是null值。
SQL> create table test (t1 varchar2(10) null)
2 ;
Table created.
SQL> alter table test add constraint qk_test unique(t1);
Table altered.
C选项错,约束可以作用于INSERT,UPDATE,DELETE语句。
D选项对,disabled只是暂时的,和数据无关。
E选项错,约束能是在列级定义,不能在表级定义。