Skip to Main Content
  • Questions
  • Uncommitted transactions are committed after running DDL

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Sreenivasa.

Asked: February 21, 2017 - 9:34 am UTC

Last updated: February 21, 2017 - 5:46 pm UTC

Version: Oracle 11g

Viewed 1000+ times

You Asked

Hi Tom,

Why uncommitted DML transactions are committing after DDL transaction in oracle? Please help me to understand.

and Chris said...

Because DDL commits!

An implicit COMMIT occurs immediately before the database executes a DDL statement and a COMMIT or ROLLBACK occurs immediately afterward

http://docs.oracle.com/database/122/CNCPT/sql.htm#GUID-C25B548B-363A-4FE5-B4EE-784502BAAD08__CHDHBIGA

Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

More details...

J. Laurindo Chiappa, February 21, 2017 - 4:56 pm UTC

Could be important to say something about the timeframe and the reasons of implicit commiting in DDLs... Regarding timeframe, since many moons ago it is true : in https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:7072180788422 (2002) it was this way, and years before....

Speaking for reasons, the most important one is multi-user consistency : without the implicit commit by definition a ROLLBACK must be possible - what if one user A could create a table, another user B could create an index, what happens to B´s index ? Or what about two users creating the same table(s) with a delayed commit? And what about DROP TABLE statements? Should they be roll backed ?

One could argument for making non-commited DDLs to be "local" only, visible only from the creating session : in this case, how to meaningfully monitor the system and explain SQL as the "noncommitted" table would not exist from the perspective of any other user (or even any other SESSION for the creating user) ??

Complex things to manage... So, to avoid all of this, Oracle wisely opted for implicit commiting on DDLs....

Regards,

J. Laurindo Chiappa
Chris Saxon
February 21, 2017 - 5:46 pm UTC

Yes, thanks for sharing.

Manuals do not say this - But heres words of wisdom

A reader, February 21, 2017 - 8:43 pm UTC

Manuals do not say this - But here's words of wisdom :-

An implicit COMMIT occurs immediately before the database executes a DDL statement
Even if the DDL fails
Even if the DDL fails
Even if the DDL fails

Enjoy !!!

To "A reader" : yes, manuals says...

J. Laurindo Chiappa, February 21, 2017 - 9:59 pm UTC

Hi - sorry but the Doc (follow the link provided above) says :

"An implicit COMMIT occurs immediately before the database executes a DDL statement..."

The key word is BEFORE : see, the DDL was NOT executed yet but the COMMIT already was done : so, logically don´t matter if the DDL fails or succeed, the COMMIT (implicit and BEFORE DDL execution) already was done.....

Regards,

J. Laurindo Chiappa