Collections:
Transaction Rollback When Session Killed in Oracle
What Happens to the Current Transaction If the Session Is Killed in Oracle?
✍: FYIcenter.com
If a session is killed by the DBA, the current transaction in that session will be rolled back and ended. All the database changes made in the current transaction will be removed. This is called an implicit rollback when session is killed. The following tutorial exercise shows you that the DBA KILL SESSION command forces the current transaction to be rolled back with all the changes uncommitted.
SQL> connect HR/fyicenter SQL> SELECT * FROM fyi_links; ID URL NOTES COUNTS CREATED ------- ---------------- ---------- ---------- --------- 101 FYICENTER.COM 07-MAY-06 110 CENTERFYI.COM 07-MAY-06 112 oracle.com 07-MAY-06 113 sql.com 07-MAY-06 SQL> DELETE FROM fyi_links where id = 112; 1 row deleted. SQL> DELETE FROM fyi_links where id = 113; 1 row deleted. SQL> SELECT * FROM fyi_links; ID URL NOTES COUNTS CREATED ------- ---------------- ---------- ---------- --------- 101 FYICENTER.COM 07-MAY-06 110 CENTERFYI.COM 07-MAY-06
Keep the "HR" SQL*Plus window as is, and open another window to run another instance of SQL*Plus.
>cd (OracleXE home directory) >.\bin\sqlplus /nolog SQL> connect SYSTEM/password Connected. SQL> SELECT sid, serial#, username, status, type 2 FROM V$SESSION WHERE username = 'HR'; SID SERIAL# USERNAME STATUS TYPE ---------- ---------- ------------------ -------- ----- 39 141 HR INACTIVE USER SQL> ALTER SYSTEM KILL SESSION '39,141'; System altered.
Go back to the "HR" SQL*Plus window.
SQL> SELECT * FROM fyi_links; ORA-00028: your session has been killed SQL> connect HR/fyicenter SQL> SELECT * FROM fyi_links; ID URL NOTES COUNTS CREATED ------- ---------------- ---------- ---------- --------- 101 FYICENTER.COM 07-MAY-06 110 CENTERFYI.COM 07-MAY-06 112 oracle.com 07-MAY-06 113 sql.com 07-MAY-06
As you can see, two records were rolled back as the session got killed by another session.
⇒ Read Consistency in Oracle in Oracle
⇐ Transaction Commit When Session Ended in Oracle
2019-08-23, 2241🔥, 0💬
Popular Posts:
What To Do If the StartDB.bat Failed to Start the XE Instance in Oracle? If StartDB.bat failed to st...
How to set database to be READ_ONLY in SQL Server? Databases in SQL Server have two update options: ...
How To Turn on mysql Extension on the PHP Engine in MySQL? The "mysql" API extension is provided as ...
How To Recover a Dropped Index in Oracle? If you have the recycle bin feature turned on, dropped ind...
How To Query Tables and Loop through the Returning Rows in MySQL? The best way to query tables and l...