Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Composite Index creation tip from Vivek Oracle
  • Monitor and Trace Unix processes using truss Linux/Unix
  • Paste command syntax Linux/Unix
  • Read CSV File using Python Python/PySpark
  • Distributed Transaction Troubleshooting. Oracle
  • DBMS_SQL for alter session. Oracle
  • Vivek Tuning for Row Locks. Oracle
  • Getting started with notebook Python/PySpark
  • Oracle 10g for solaris 10 Oracle
  • Passing from Unix to PLSQL using bind variables Linux/Unix
  • chk_space_SID.ksh Linux/Unix
  • switchover for primary database Oracle
  • oracle_env_10g_CADEV Linux/Unix
  • Generate SSH without password authentication. Linux/Unix
  • PLSQL Table Syntax 1 Oracle

Kill a session dynanically using execute immediate

Posted on 04-Jan-2009 By Admin No Comments on Kill a session dynanically using execute immediate

In this Document

Goal

Solution

References

Applies to:

PL/SQL – Version: 8.1.7.4 to 10.1.0.2

Information in this document applies to any platform.

Goal

This article presents one suggested way of killing a session using an “ALTER SYSTEM KILL SESSION ‘sid,serial#’ ” statement in PL/SQL dynamically where the sid and serial# are values being passed in determined at runtime via additional SQL commands.

Solution

The Sid and serial values can be obtained from associated queries against the V$SESSION view.

For example, if a single user SCOTT was logged in and that is the session to kill, the following SQL can be used to obtain the required information:

SQL> select sid, serial# from v$session where username = ‘SCOTT’;

SID SERIAL#

—- ———-

26 10654

The SID (26) and Serial# (10654) are used within the following anonymous block to kill SCOTT’s session.

declare

sid number := 26;

serial number := 10654;

str varchar2(1000);

killstr varchar2(20);

begin

killstr := sid||’,’||serial;

str:=’alter system kill session ”’||killstr||””;

dbms_output.put_line(‘Kill String is ‘||killstr);

execute immediate str;

end;

/

Oracle, SQL scripts

Post navigation

Previous Post: How to start CRS manually
Next Post: 276434.1 Modifying the VIP or VIP Hostname of a 10g or 11g Oracle Clusterware Node

Related Posts

  • Display the top 5 salaries for each department using single SQL Oracle
  • sql_plan9i.sql Oracle
  • cur_sql.sql Oracle
  • How to find the real execution plan and binds used in that explain plan in Oracle 10g?? Oracle
  • OPENING A STANDBY DATABASE IN READ-ONLY MODE Oracle
  • Import and export statements Oracle

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • Oracle (392)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • load SPM baseline from cursor cache05-Jun-2025
  • Drop all SPM baselines for SQL handle05-Jun-2025
  • Load SPM baseline from AWR05-Jun-2025
  • Drop specific SQL plan baseline – spm05-Jun-2025
  • findinfo.sql (SQL for getting CPU and Active session info)27-May-2025
  • SQL Tracker by SID sqltrackerbysid.sql22-Apr-2025
  • How to connect to Oracle Database with Wallet with Python.21-Mar-2025
  • JSON/XML Types in Oracle18-Mar-2025
  • CPU Core related projections12-Mar-2025
  • Exadata Basics10-Dec-2024

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • reset Sequence Oracle
  • CPU Core related projections AWS
  • 339939.1 Running Cluster Verification Utility to Diagnose Install Problems Oracle
  • to see when crontab is changed. Linux/Unix
  • Disbaling DBA_SCHEDULER_JOBS Oracle
  • check_copy_progress.sh Linux/Unix
  • Good Oracle Architecture In Short and point to point Oracle
  • Rollback force for distributed transactions Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme