OCP 1Z0 051 28

来源:互联网 发布:梦想网络活跃ip查询器 编辑:程序博客网 时间:2024/05/24 15:42
SQL> alter table emp modify ename null;Table altered

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. 

A.不对
SQL> SELECT c.table_name, c.constraint_name, c.r_constraint_name  2    FROM user_constraints c  3   WHERE constraint_type = 'R';TABLE_NAME                     CONSTRAINT_NAME                R_CONSTRAINT_NAME------------------------------ ------------------------------ ------------------------------EMP                            FK_DEPTNO                      PK_DEPT1 row selectedSQL> insert into emp(empno,deptno) values(9999,null);1 row inserted

B 对
SQL> create unique index idx_emp_ename on emp(ename);Index createdSQL> insert into emp (empno,ename) values(9998,null);1 row inserted

C不对
SQL> alter table emp modify ename not null;Table alteredSQL> update emp set ename = null where empno = 7788;update emp set ename = null where empno = 7788ORA-01407: 无法更新 ("SCOTT"."EMP"."ENAME") 为 NULL

D 对
SQL> alter table emp modify ename null;Table altered

E不对
SQL> alter table emp add constraints ch_sal check(sal >= (case when comm > 0 then 1 else 0 end));Table altered


Answer: BD
0 0