28.Which two statements are true regarding constraints?

来源:互联网 发布:coc地震升级数据 编辑:程序博客网 时间:2024/06/04 19:15
28.Which two statements are true regarding constraints?
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:错误

create table test1(a number constraint un_a unique); insert into test1 values(1);commit;create table test2 (a number,constraint fk_a foreign key(a) references test1(a));insert into test2 values(null);commit;
--可以有null

B:正确

insert into test1 values(null);
1.NOT NULL

create table test1 (a number constraint nu_a not null);create table test2 (a number constraint nu_a null);
2.unique

create table test1 (a number constraint un_q unique);create table test2 (a number, constraint un_q unique(a));
3.primary key
create table test1 (a number constraint pk_a primary key);create table test2 (a number, constraint pk_a primary key(a));
4.foreign key

create table test1 (a number constraint pk_a primary key);create table test2 (a number constraint fk_a references test1(a));create table test3 (a number, constraint fk_a foreign key(a) references test1(a));
5.check

create table test1 (a number constraint ck_a check(a<3));create table test1 (a number,constraint ck_a check(a<3));
5.REF:可以定义在列和表上,下面是个简单例子,这里其实又分3种

create type type_test as object(a number);create table type_table_test of type_test;create table type_table_ref (a number,b ref type_test scope is type_table_test);






0 0
原创粉丝点击