Skip to Main Content
  • Questions
  • Which is default if session is interrupted - COMMIT or ROLLBACK?

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, M.

Asked: June 01, 2018 - 10:14 am UTC

Last updated: December 19, 2022 - 5:10 am UTC

Version: Oracle 11g

Viewed 10K+ times! This question is

You Asked

Hi Tom,

I use Oracle SQL Developer.

I do not use autocommit and in normal situation I always use after some block of SQL commands (INSERT, DELETE etc.) COMMIT, or ROLLBACK.

But what does happen if I do not finish this block of SQL command in actual session with COMMIT or ROLLBACK? For example if the power will be shut off etc.

So which is default behavior in the case of error finishing of session: COMMIT, or ROLLBACK?

And the second question which concerns to the first one: Does exist any timeout for the session, or not?

Thank you very much for advance,

Mirek


and Connor said...

SQL Dev will prompt you if you are exiting *normally*. For example, I performed a delete from a table, and then hit exit, and I see the following:

SQLDEV_COMMIT

If a database session exits *abnormally* then any *uncommitted* changes will be rolled back. So for example, if you did an "kill task" via windows to destroy the SQL Developer session, then uncommitted changes will ultimately be rolled back once the database detects the client for that session is no longer present.

Rating

  (2 ratings)

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

Comments

Thanks

M S, June 06, 2018 - 7:24 am UTC

Thank you Tom for your reply.

So I understand to your answer i this manner:
the default behavior of the session which was terminated in abnormal manner (for example in the case of direct power off for PC etc.) is ROLLBACK.

Mirek
Connor McDonald
June 07, 2018 - 1:24 am UTC

Correct.

The database will "Eventually" rollback when a session is dropped

Don, December 14, 2022 - 8:42 pm UTC

It may take up to two hours and in the mean time the rows in the update will be locked
Connor McDonald
December 19, 2022 - 5:10 am UTC

Check out the max_idle_blocker_time parameter for solutions to this.

If your dead session (which by definition is idle) starts to block people, the database will automatically kill it

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library