Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • How to know current SID Oracle
  • usnsql.sql Displays information about UNDO segments with sql statements Oracle
  • Sort with ASCII order and Numeric Order Linux/Unix
  • Goldengate document from Porus Oracle
  • Oracle Release Explaination Oracle
  • Kernel Parameters for Solaris Linux/Unix
  • restarting network in linux Linux/Unix
  • create a folder in multiple places Linux/Unix
  • Monitor and Trace Unix processes using truss Linux/Unix
  • switchover for primary database Oracle
  • Oracle 11g RAC on OEL 5 and Vmware 2 Oracle
  • TOP-N Sql to find Nth max or Top N rows Oracle
  • Is It Recommended To Apply Patch Bundles When PSU Is Available? -ID 743554.1 Oracle
  • Good links for x$ tables in oracle. Oracle
  • SQL Server Vs Oracle Architecture difference SQL Server

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

  • eplan9i.sql Oracle
  • Proc Compilation Oracle
  • ORA-00064: object is too large to allocate on this O/S during startup Oracle
  • How to set Processes Parameter Oracle
  • Mutating Table Error while using database trigger Oracle
  • create trigger syntax 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 (403)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (1)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (18)
  • rman-dataguard (26)
  • shell (150)
  • SQL scripts (350)
  • SQL Server (6)
  • Uncategorized (5)
  • Videos (0)

Recent Posts

  • Key Management in Oracle: The Core Issue: Missing Master Key12-May-2026
  • SAT Mathematics 10 questions and answer at the end.30-Apr-2026
  • top 10 AI news today30-Apr-2026
  • runon_allpdbs_show_conname.sh23-Apr-2026
  • runon_allcdbs_find_pdbs.sql23-Apr-2026
  • Running PDB on single node in RAC09-Apr-2026
  • find_arc.sql09-Apr-2026
  • pvm_pre_change.sql08-Apr-2026
  • find_encr_wallet.sql08-Apr-2026
  • find_pdbs.sql08-Apr-2026

Archives

  • 2026
  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • sesswait.sql Oracle
  • How to choose Driver table in SQL statement Oracle
  • Finding Oracle Patches with opatch Oracle
  • Oracle 11g Environment Setup Oracle
  • find_arc.sql Oracle
  • USER_TABLES.Freelists Oracle
  • CTAS with LONG Column for 7.x and 8 and 8i Oracle
  • moving lob object to other tablespace lob_mvmt.sql Oracle

Copyright © 2026 pvmehta.com.

Powered by PressBook News WordPress theme