Hi
From 12cR2 and 18c, you can cancel the session instead of killing it which is long running and consuming time and resources.
The following is the syntax for cancelling a SQL statement:
ALTER SYSTEM CANCEL SQL 'SID, SERIAL, @INST_ID, SQL_ID';
If @INST_ID is not specified, the instance ID of the current session is used.
If SQL_ID is not specified, the currently running SQL statement in the specified session is terminated.
-Suresh
Good to know this . How does it different from killing session.
We are killing the SQL not the session, so the session remain intact, if that SQL is DML then they will be rolled back.
-Suresh
Thanks for making it clear .
What will happen in case of I’m running SQL script which contains multiple SQLs
As you see, the command itself contain a sql_id, if you omit all SQL will be cancelled for that Session, however at any point of time a session can run one given sql id not multiple though.