Implicit commit caused by DDL in Oracle PL/SQL

Source: Internet
Author: User
Tags dname

1. If the DDL syntax is correct, implicit commit will occur even if the execution fails:

Duzz $ Scott @ orcl> Create Table T1 as select * from Dept;

 

Table created.

 

Elapsed: 00:00:00. 03

Duzz $ Scott @ orcl> Update T1 set loc = 'xx' where deptno = 10;

 

1 row updated.

 

Elapsed: 00:00:00. 03

Duzz $ Scott @ orcl> drop table xx;

Drop table xx

*

Error at line 1:

ORA-00942: Table or view does not exist

 

 

Elapsed: 00:00:00. 01

 

++ ++

 

Duzz $ sys @ orcl> select * from Scott. T1;

 

Deptno dname Loc

-------------------------------------------------------------------------------------------

10 Accounting xx

20 research Dallas

30 sales Chicago

40 operations Boston

 

Elapsed: 00:00:00. 01

 

 

2. If the DDL syntax is incorrect, it will not cause implicit commit or automatic rollback of transactions:

 

Duzz $ Scott @ orcl> Update T1 set loc = 'yy' where deptno = 20;

 

1 row updated.

 

Elapsed: 00:00:00. 00

Duzz $ Scott @ orcl> drop table Col xx;

Drop table Col xx

*

Error at line 1:

ORA-00933: SQL command not properly ended

 

 

Elapsed: 00:00:00. 00

 

++ ++

 

Duzz $ sys @ orcl> select * from Scott. T1;

 

Deptno dname Loc

-------------------------------------------------------------------------------------------

10 Accounting xx

20 research Dallas

30 sales Chicago

40 operations Boston

 

Elapsed: 00:00:00. 00

 

Summary:

DDL pseudocode:

Begin

Parse DDL;

Commit;

Do DDL;

Exception

When others then

NULL;

End;

 

Ref:

Http://www.cublog.cn/u/25770/showart_2222436.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.