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.
Related
I have very long time executable proc, and need close it. What is the best way to do this?? Using Oracle 19, cx_oracle 7.2.2. Connection started in SessionPool.
Found several ways, throw ^C forcibly and try
ALTER SYSTEM CANCEL SQL 'SID, SERIAL[, #INST_ID][, SQL_ID]';
Depending on what you want to achieve, you have either the cancel sql statement you pointed to, or the alter system kill session method. The first one will just cancel the current sql (if you specify the sql_id), and then the session continues (depending on how you handle errors in your code). The second method will kill your session, and your program will need to recapture a connection from the pool and try again.
Another comment, you better upgrade your cx_oracle to the newest oracledb provider. 7.2 is fairly old.
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#';
I have accidently executed a procedure and i want o kill the session.
I have tried almost all the options i can search so far for granting access and killing sessions. but each time a SQL Error: ORA-01031: insufficient privileges error is displayed.
Just want to know if there is any possible way I can kill this session.
PS: I am working on a Development environment.
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.
Im having some trouble with an oracle database. Every time i try to connect, i get this message.
ORA-01033: ORACLE initialization or
shutdown in progress
I searched the web, and found that the solution is to execute an alter database open command, but what I dont understand is where should i execute if, since I cant connect to the database.
Am I missing something?
Thanks in advance
You should connect AS SYSDBA:
sqlplus "sys/pwd AS SYSDBA"
An ORA-01033 would also be thrown if the connection attempt were made against a mounted standby database (Oracle Data Guard environment) by a non-sysdba user. Maybe a database role change (switchover or failover) has occurred since your last connection attempt.
Which OS are you using? The database is still shutting down - check the alert log as to the status of where it is at. Sometimes there are sessions hanging around that need to manually be killed off, there should be an indication of this in the alert log. It also depends how the database was shutdown, NORMAL, TRANSACTIONAL, IMMEDIATE. Even with a SHUTDOWN IMMEDIATE the sessions hanging around may still happen. To find the sessions on UNIX use the 'ps' to list all processes on the server ('ps -eaf' on Solaris) command and 'grep' for the ORACLE_SID name.