Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Search and replace pattern Linux/Unix
  • Goldengate Tutorial Oracle
  • refre.sql Oracle
  • 284785.1 How to check RAC Option is currently linked into the Oracle Binary Oracle
  • Sort with ASCII order and Numeric Order Linux/Unix
  • How to see which patches are applied. Oracle
  • Sequence Resetting Oracle
  • Read CSV File using Python Python/PySpark
  • How to hide author name in WordPress BLOG PHP/MYSQL/Wordpress
  • Renaming Oracle Instance Name Oracle
  • Sample WW22 listener.ora Oracle
  • Processes parameter and its dependencies on OS kernel parameters Linux/Unix
  • Roles and Stored Object behaviour Oracle
  • get_vmstat_linux Oracle
  • My FTP Job Scheduling for www.pvmehta.com PHP/MYSQL/Wordpress

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

  • eplan.sql Oracle
  • cache buffer chain latch Oracle
  • executing Function from SQLPLUS prompt Oracle
  • reset Sequence Oracle
  • Oracle 11g RAC on OEL 5 and Vmware 2 Oracle
  • DBMS_STATS Metalinks Notes 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 (388)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (337)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • 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
  • Reading config file from other folder inside class24-Sep-2024
  • Python class import from different folders22-Sep-2024
  • Transfer SQL Profiles from One database to other database.05-Sep-2024
  • Load testing on Oracle 19C RAC with HammerDB18-Jan-2024

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Read CSV file using PySpark Python/PySpark
  • OEM-Commnds Oracle
  • tblwopk.sql tablewopk.sql Oracle
  • sid_wise_sql.sql Further explaination Oracle
  • How to change hostname in Linux Linux/Unix
  • get_ratio.sql get the ratio of users from v$session and this uses CASE-WHEN-THEN clause Oracle
  • Drop tempfiles from database Oracle
  • 284785.1 How to check RAC Option is currently linked into the Oracle Binary Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme