Kill session in oracle? [duplicate] - oracle

This question already has answers here:
How to kill a running SELECT statement
(6 answers)
Closed 9 years ago.
I have 1000 records on my table,while deleting records using toad, I get a error message as
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
I tried ,
alter system kill session ('214,60347');
but I get invalid for both attributes.In this i declared correct values,
I also tried
alter system kill session ('214,60347#'); as alter system kill session ('sid,serial#');
is first query correct? or are there any other ways to kill session in oracle?

This message means that the transaction was not committed nor rolled back. Event after the error if you are able to do one of both try it.
It would be good to add the "immediate" keyword at the end to force it right away.
ALTER SYSTEM KILL SESSION ('sid,serial#') IMMEDIATE;
ALTER SYSTEM KILL SESSION ('214,60347') IMMEDIATE;
Because killing the session can make a mess try to use the "disconnect" option.
ALTER SYSTEM DISCONNECT SESSION 'sid,serial#' IMMEDIATE;
Details about it can be found here:
http://www.oracle-base.com/articles/misc/killing-oracle-sessions.php

Related

dbms_utility.exec_ddl_statement doesn't work

I want to kill session over dblink however dbms_utility.exec_ddl_statement doesn't work.
Below command doesn't throw any error but also it doesn't kill the session.
exec dbms_utility.exec_ddl_statement#dblink('Alter system kill session ''274,12303,#1'' immediate');
It appears that you want to kill session which resides in a remote database. If that's so,
create a procedure in that (remote) database
it would kill session
one option is to use dynamic SQL to do that (i.e. execute immediate)
which one? The one whose parameters will be passed as procedure's arguments
call the procedure over the database link
I assume that the session with sid=274, serial=12303 on node=1 is running a heavy DML/DDL statement, and that by saying "it doesn't kill session" you mean that the session is seen as ACTIVE in GV$SESSION after the command is run.
That is an expected behavior. As counter-intuitive as it may be, KILL SESSION doesn't really "kill" session - it sends a kill signal which the session will respect after it's current work is done. Not before. So not an option for the assumed scenario.
Two other options:
ALTER SYSTEM DISCONNECT SESSION '274,12303,#1' IMMEDIATE
kill OS process.
ORACLE-BASE article
P.S. dbms_utility.exec_ddl_statement#dblink(q'!Alter system kill session '274,12303,#1' immediate!'); alternative quoting mechanism. No more double-ticks since 10g.

Killing active and inactive sessions in oracledb

I am trying to execute stored procedure package changes from sql developer console and oracle session hangs. For now I am killing the oracledb and launching it again
I checked stackoverflow regarding the issue and came across a similar question How to kill all active and inactive oracle sessions for user which suggests the following queries to kill hanging sessions
SELECT sid, serial#, status FROM v$session;
ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
But on executing them I get
"table or view does not exist"
Can someone help me with queries to fetch all sessions and killing hanging sessions in oracledb ?

How to stop task in oracle sql developer

I ran a script in Oracle sql developer last night which is a quite simple command:
'update TABLE set column A=...'
The table is a large one maybe about 70GB.
The task kept running for the whole night and still running....
Could I just click on the stop button on the window? I'm afraid of locking the session or the rolling back procedure will take longer time.
So what will happen to the database after we click stop? Or is there a more efficient way to kill task...
I would recommend not to stop it from SQL Developer instead you can get the session id from V$SESSION of this connection and kill it
alter system kill session 'sid,serial#';

Killed the sessions, Restarted the Database but not able to delete the user Oracle

There were some uncontrollable front end ODBC/JDBC connections to a user(Eg. ENT) in oracle 11g, I killed the sessions but since the front end was reconnecting, I changed the password of it.
Later i was able to kill all the sessions completely and couldnt see any sessions in V$SESSION.
But still I'm not able to drop the user. I requested a DB restart to the DBA still no luck.
DB restart was done with shutdown immediate command and start respectively
just shut it down and open it up restrict
shutdown immediate
startup restrict
drop user username cascade;
shutdown immediate
startup

How to terminate Oracle procedures which is running

I created an oracle procedure. When i execute it from sqldevoloper in some case i think it is going into an infinite loop. It keeps on generating the log files. How can i terminate this running procedure?
I stopped the oracle service through services.msc . When i start it again , log files are getting generated. I think still that procedure is running.
How can i terminate those procedures.
Identify your session (hung) from v$session using
select sid, serial#, status from v$session where USERNAME='NAME';
And then kill it using
ALTER SYSTEM KILL SESSION 'SID,#SERIAL';
ALTER SYSTEM KILL SESSION
But you have to retrieve session id and have rights.

Resources