Solved

How to stop running an Oracle SQL command

Posted on 2006-11-16
3
1,705 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 35

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
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.
Suggested Courses

630 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