Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • All Hints for Oracle Databases Oracle
  • Set Role explaination. Oracle
  • Python class import from different folders Python/PySpark
  • pvmehta.com SQL scripts
    Find which sessions is accessing object that prevent your session to have exclusive locks in Oracle Oracle
  • oracle_env_10g_CADEV Linux/Unix
  • Histogram Overview Oracle
  • Find all users who have DML privileges Oracle
  • How To Transfer Passwords Between Databases (ref note: 199582.1) Oracle
  • How to find where datafile is created dbf_info.sql Oracle
  • ORA-1841 Error Connecting to Upgraded Database After Set PASSWORD_LIFE_TIME Oracle
  • Handling LOB data in Oracle Oracle
  • changing kernel parameter in Oracle Enterpise Linux Linux/Unix
  • Passing from Unix to PLSQL using bind variables Linux/Unix
  • 10g RAC: Troubleshooting CRS Root.sh Problems Oracle
  • SQL Tracker by SID sqltrackerbysid.sql 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

  • Explain Plan Doesn’T Change For Sql After New Statistics Generated Oracle
  • Good RAC & Standby Notes Oracle
  • Wait time tuning research Oracle
  • Create type and Grant on it. Oracle
  • sess_server.sql Oracle
  • sql_plan9i.sql Oracle

Leave a Reply Cancel reply

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

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Django (0)
  • GIT (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (399)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (1)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (150)
  • SQL scripts (347)
  • SQL Server (6)
  • Uncategorized (3)
  • Videos (0)

Recent Posts

  • find_arc.sql09-Apr-2026
  • pvm_pre_change.sql08-Apr-2026
  • find_encr_wallet.sql08-Apr-2026
  • find_pdbs.sql08-Apr-2026
  • Creating a Container Database using dbaascli08-Apr-2026
  • track_autoupgrade_copy_progress.sql01-Apr-2026
  • refre.sql for multitenant01-Apr-2026
  • prepfiles.sh for step by step generating pending statistics files10-Mar-2026
  • tracksqltime.sql05-Mar-2026
  • Complete Git Tutorial for Beginners25-Dec-2025

Archives

  • 2026
  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • how to find VIP from ifconfig Linux/Unix
  • Rman Notes -1 Oracle
  • move_arch_files.ksh Linux/Unix
  • Standby Database Behavior when a Datafile is Resized on the Primary Database Note:123883.1 Oracle
  • Remove DOS CR/LFs (^M) Linux/Unix
  • Pending Transaction Neighbors Script Oracle
  • How can I tell if ASO is installed ? Oracle
  • switchlogfile.sh Linux/Unix

Copyright © 2026 pvmehta.com.

Powered by PressBook News WordPress theme