OCP 1Z0 052 169
来源:互联网 发布:贵阳大数据会议 编辑:程序博客网 时间:2024/04/29 08:42
child table first because it is going to be a long transaction and data for the parent table will be available in
a later stage, which can be inserted as part of the same transaction.
View the Exhibit to examine the commands used to create tables.
Which action would you take to delay the referential integrity checking until the end of the transaction?
A.Set the constraint to deferred before starting the transaction.
B.Alter the constraint to NOVALIDATE state before starting the transaction.
C.Enable the resumable mode for the session before starting the transaction.
D.Set the COMMIT_WAIT parameter to FORCE_WAIT for the session before starting the transaction.
Answer: A
http://docs.oracle.com/cd/E11882_01/server.112/e41084/clauses002.htm#SQLRF52217
Restriction on [NOT] DEFERRABLE You cannot specify either of these parameters for a view constraint.
INITIALLY Clause The INITIALLY
clause establishes the default checking behavior for constraints that are DEFERRABLE
. TheINITIALLY
setting can be overridden by a SET
CONSTRAINT
(S
) statement in a subsequent transaction.
Specify
INITIALLY
IMMEDIATE
to indicate that Oracle should check this constraint at the end of each subsequent SQL statement. If you do not specifyINITIALLY
at all, then the default isINITIALLY
IMMEDIATE
.If you declare a new constraint
INITIALLY
IMMEDIATE
, then it must be valid at the time theCREATE
TABLE
orALTER
TABLE
statement is committed or the statement will fail.Specify
INITIALLY
DEFERRED
to indicate that Oracle should check this constraint at the end of subsequent transactions.
Set All Constraints Deferred
Within the application being used to manipulate the data,you must set all constraints deferred before you actually begin processing any data. Use the following DML statement to set all deferrable constraints deferred:
SET CONSTRAINTS ALL DEFERRED;
Note:
TheSET CONSTRAINTS
statement applies only to the current transaction. The defaults specified when you create a constraint remain as long as the constraint exists. The ALTER SESSION SET CONSTRAINTS
statement applies for the current session only.SQL> CREATE TABLE items 2 (item_code NUMBER(4) CONSTRAINT pk PRIMARY KEY 3 DEFERRABLE INITIALLY IMMEDIATE, 4 item_desc VARCHAR2(40), 5 qoh NUMBER(3), 6 price NUMBER(10,2) 7 );Table createdSQL> CREATE TABLE orders( 2 ord_id CHAR(5) NOT NULL, 3 item_code NUMBER(4) REFERENCES items(item_code) 4 ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE, 5 qty NUMBER(3) CONSTRAINT ch_qty CHECK(qty > 0), 6 ord_dt DATE 7 );Table created
SQL> SET CONSTRAINTS ALL DEFERRED;Constraints set
未设置DEFERRABLE属性的约束不能使用此特性,如:
SQL> insert into orders(ord_id,item_code,qty) values('1',2,0);insert into orders(ord_id,item_code,qty) values('1',2,0)ORA-02290: check constraint (TEST.CH_QTY) violated
当提交时,数据不符合约束将回滚
SQL> insert into orders(ord_id,item_code,qty) values('1',2,3);1 row insertedSQL> commit;commitORA-02091: transaction rolled backORA-02291: integrity constraint (TEST.SYS_C0014489) violated - parent key not found
SQL> SET CONSTRAINTS ALL DEFERRED;Constraints setSQL> insert into orders(ord_id,item_code,qty) values('1',2,3);1 row insertedSQL> insert into items(item_code) values(2);1 row insertedSQL> commit;Commit complete
- OCP 1Z0 052 169
- OCP 1Z0 051 169
- OCP 1Z0 053 169
- OCP 1Z0 052 1
- OCP 1Z0 052 2
- OCP 1Z0 052 3
- OCP 1Z0 052 4
- OCP 1Z0 052 5
- OCP 1Z0 052 6
- OCP 1Z0 052 7
- OCP 1Z0 052 8
- OCP 1Z0 052 9
- OCP 1Z0 052 10
- OCP 1Z0 052 11
- OCP 1Z0 052 12
- OCP 1Z0 052 13
- OCP 1Z0 052 14
- OCP 1Z0 052 15
- 证明斯托尔兹定理及其一些有趣的应用
- jQuery基础---Ajax基础
- Android中RelativeLayout各个属性的含义
- RPC专题-Thrift与Protobuf比较2
- 单片机发展前景
- OCP 1Z0 052 169
- Oracle三种备份方法
- Android 开发之---bootloader(lk)
- 【C语言复习(二十四)】C语言程序内存结构总结
- Tomcat 利用server.xml进行项目映射的部署
- FlashBuilder的安装破解+常见问题+小应用
- 解决在浏览器中打开java文件jnlp报错“该文件没有程序与之关联来执行该操作...”
- Android开发执行adb 命令行命令
- IE双击无法打开,进程中也无,通过管理员账户也无法打开