1Z0-051 QUESTION 28 关于约束

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选项错,约束能是在列级定义,不能在表级定义。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值