SQL*Plus Commit on Exit
by Frank Kim on Aug.25, 2009, under Oracle
I was always doing a commit before exiting SQL*Plus when it occurred to me today that maybe I didn’t need to do that. Doing a Google search quickly answered that for me.
If you issue a graceful exit (via the “exit” or “quit” command), sqlplus will always issue a commit. However, if you were to be ungracefully disconnected, for example by closing your terminal window, then PMON will issue a rollback like it does with any other disconnected session.
Therefore there is no need to do a commit before you exit.
You can also set autocommit on, it is off by default, but I would not recommend doing this.
During interactive usage with sqlplus, Oracle also supports an AUTOCOMMIT option. With this option set to ON each individual SQL statement is treated as a transaction an will be automatically commited right after it is executed. A user can change the AUTOCOMMIT option by typing
SET AUTOCOMMIT ONor
SET AUTOCOMMIT OFFwhereas by typing
SHOW ALLa user can see the current setting for the option (including other ones).
Related posts:
