set events
Starting with Oracle 11g, setting an event systemwide affects all connected
sessions, not only the new ones.
alter system set events '…';
For example: the following command causes the systemstate to be dumped when an ORA-00054 error is thrown:
alter system set events '54 trace name systemstate level 258';
Terminating sessions
Sessions can be ended with the following statements:
alter system disconnect session 'sid,serial' [ immediate | noreplay ];
alter system disconnect session 'sid,serial' post_transaction [ immediate | noreplay ];
alter system kill session 'sid,serial' [ immediate | noreplay ];
alter system kill session 'sid,serial,@instance_id' [ immediate | noreplay ];
23c also comes with the
force
option to terminate a session more forcefully than using
immediately
(i. e. not waiting for transactions to be rolled back, session locks to be released and the session state to be recovered):
alter system kill session 'sid,serial' force;
The values for
sid
and
serial
can be found in
v$session
alter system kill session
performs the following actions:
- Terminates the session
- Rolls back its transaction
- Releases its locks
- Frees its resources
Sessions that perform network I/O (for example because they're waiting for a replay of a remote database) or are rolling back a transaction cannot be immediately terminated.
In such a case, the session that executes alter system kill session
waits up to 60 seconds. If this time period is reached, it receives a messages that indicates that the session is marked to be terminated (MOS Notes 107686.1, 161794.1).
As per MOS Note 1020720.102 (
ALTER SYSTEM KILL Session Marked for Killed Forever), a killed session waits for for a
SQLNet message from client to which it can respond with
ORA-00028: your session has been killed. Only when this message is received, PMON will take ownership of the process and clean up any resources allocated by that process.
Killing one of the background processes DBWR, LGWR, SMON or PMON will crash the instance.