Solved

How to stop running an Oracle SQL command

Posted on 2006-11-16
3
1,698 Views
Last Modified: 2012-06-27
I am running a Oracle 8i on a windows 2000 environment.
I tried to run a SQL command in the SQL*plus worksheet. When I try to display the contents in a table using "select", I forgot to put in the "where" clause which resulted in the command running for a long long time because it is a huge table. Is there any way I can stop the command before it finishes?

Thanks
0
Comment
Question by:amphastar
3 Comments
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 17957637
i have not worked on sql*plus worksheet, but in sql*plus we can try ctrl + c or esc key something like that.

I think some expert on sql*plus worksheet has to hit this one.

Thanks
0
 
LVL 34

Accepted Solution

by:
Mark Geerlings earned 125 total points
ID: 17958072
I haven't used SQL*Plus Worksheet either.  One option that works for any Oracle program is to start a new SQL*Plus (or TOAD, or SQL*PLUS Worksheet, or any other utility that connects to Oracle and allows you to execute SQL statements) then do a "kill session..." statement for the session you want to kill.  I use this script in SQL*Plus for that:

(Note, you do need to be a DBA or have the "alter system" privilege to do this.)

column sid format 9999;
column serial# format 9999999;
column "Logon" format a13;
set verify off;
select s.sid, s.serial#, nvl((select p.spid from v$process p where p.addr = s.paddr),'  ?') "Spid",
substr(s.terminal,9,5) "Type",substr(s.machine,instr(s.machine,'\') +1,8) "Machine", s.status, s.server,
rpad(substr(decode(s.program,'OraPgm','Windows95 unknown',s.program),greatest(
 (length(decode(s.program,'OraPgm','Windows unknown',s.program)) - 23),1),24),24,' ') "Program",
substr(s.osuser,instr(s.osuser,'\') +1,14) "OsUser", to_char(s.logon_time,'YYMMDD HH24MISS') "Logon"
from v$session s where s.username = upper('&username');
--
Prompt Enter the "SID" and "SERIAL#" values to cancel a session...
alter system kill session '&SID,&SERIAL';
set verify on;
0
 

Author Comment

by:amphastar
ID: 17959578
Great. I killed the process with another connection to the database.

Thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example, show how to take different types of Oracle backups using RMAN.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now