Using PL/SQL Developer by AllRound Automations, is there a way, during a long-running query, to disconnect yet allow the query to continue to completion, when running on an Oracle database?
Dmitry says:
It is impossible. You can try to kill process of PLSQL Developer using
windows task manager. Sometimes session stays active, but nobody
guarantees the result
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 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.
Is there any way to execute a procedure in SQL Developer and have the procedure continue to run even in SQL Developer is closed?
Yes, here's an Oracle doc that will guide you through defining a scheduler job. You can use this method (or DBMS_SCHEDULER, or OEM) to schedule a job that will execute a procedure without needing to maintain database connectivity.
Would recommend reading the entire doc, but you can skip ahead to "Schedule SQL Scripts Using SQL Developer" to view the relevant info.
https://docs.oracle.com/database/sql-developer-17.2/DMRIG/generating-deploying-sql-scripts.htm#DMRIG260
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#';
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.