Oracle OCP 042题库解析(5)
A constraint in a table is defined with the INITIALLY IMMEDIATE clause. You executed the ALTER TABLE command with the ENABLE VALIDATE option to enable the constraint that was disabled. What are the two effects of this command? (Choose two.)A) It fails if any existing row violates the constraint.B) It does not validate the existing data in the table.C) It enables the constraint to be enforced at the end of each transaction.D) It prevents insert, update, and delete operations on the table while the constraint is in the process of being enabled. Answer: A,D为了更好地处理数据可能暂时违反约束条件的情况,可将约束条件指定为不同的状态。可以启用(ENABLE) 或禁用(DISABLE) 完整性约束条件。如果启用约束条件,在数据库中输入或更新数据时就会检查数据。此时,禁止输入不符合约束条件规则的数据。如果禁用约束条件,则可以在数据库中输入不符合规则的数据。完整性约束条件可处于下列其中一种状态:DISABLE NOVALIDATE:不检查新数据和现有数据,因此这些数据可能不符合约束条件。当数据来自验证过的源,而且表是只读表时,通常会使用此状态。因此,不会将新数据输入表中。DISABLE VALIDATE:如果约束条件处于此状态,则不允许对有约束条件的列进行任何修改。因为如果在验证现有数据后,又允许将未经检查的数据输入表中,就会出现不一致的情况。当必须验证现有数据,但不需要修改数据,而且不需要另外为性能而建立索引时,通常会使用此状态。ENABLE NOVALIDATE:新数据符合约束条件,但现有数据处于未知状态。当可以更正现有的约束条件违规情况,同时又不允许将新的违规数据输入系统时,常常会使用此状态。ENABLE VALIDATE:新数据与现有数据均符合约束条件。这是约束条件的典型状态和默认状态。实验:建测试表,先将约束条件设为disable novalidate,方便插入数据SQL> create table cons_test1 (2x int constraint x_check check(x>0) disable novalidate);SQL> insert into cons_test1 values (1);SQL> insert into cons_test1 values (-1); SQL> insert into cons_test1 values (2);SQL> select * from cons_test1; X---------- 1 -1 2SQL> alter table cons_test1 modify constraint x_check enable validate;alter table cons_test1 modify constraint x_check enable validate *ERROR at line 1:ORA-02293: cannot validate (TEST.X_CHECK) - check constraint violated所以A正确SQL> delete from cons_test1 where x<0;SQL> alter table cons_test1 modify constraint x_check enable validate; Table altered. SQL> insert into cons_test1 values (-1);insert into cons_test1 values (-1)*ERROR at line 1:ORA-02290: check constraint (TEST.X_CHECK) violated所以D正确关于C,INITIALLY IMMEDIATE 是立即检查约束,而INITIALLY DEFERRED才是到事务提交时候检查约束。实验:SQL> create table cons_test2(x int constraint check_x check (x>0) deferrable initially immediate,3y int constraint check_y check (y>0) deferrable initially deferred)Table created.两个约束同时满足时,能正确无误的插入SQL> insert into cons_test values (1,1);1 row created.SQL> commit;Commit complete. 当违反CHECK_X约束,则系统会立即检验约束SQL> insert into cons_test values (-1,1);insert into cons_test values (-1,1)*ERROR at line 1:ORA-02290: check constraint (TEST.CHECK_X) violated 当违反CHECK_Y时,则在事务结束时检验约束SQL> insert into cons_test values (1,-1);1 row created.SQL> commit;commit*ERROR at line 1:ORA-02091: transaction rolled backORA-02290: check constraint (TEST.CHECK_Y) violated所以本题选A,D{:6_267:}{:6_267:}{:6_267:}
..................
一起关注下.....看看什么情况。。。。。 (*^__^*) 嘻嘻…… 感謝您熱心的教學! 支持你大侠 {:6_290:}{:6_290:} 问一下,oracle数据是不是可以进银行工作啊。 学习学习
页:
[1]