Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • CPU speed on solaris Linux/Unix
  • Korn Shell Arithmatic Linux/Unix
  • Running select from V$ views from remote server Linux/Unix
  • Useful Solaris Commands on 28-SEP-2005 Linux/Unix
  • Adding a new disk and mount it automatically. on VMWARE LINUX Linux/Unix
  • Rman Notes -1 Oracle
  • How to Modify the statistics collection by MMON for AWR repository Oracle
  • Benefits and Usage of RMAN with Standby Databases Oracle
  • Default User Profile Oracle
  • Very Good Oralce Internal Tuning Book Oracle
  • FRA Information. Oracle
  • ORA-3136 Oracle
  • Search and replace pattern Linux/Unix
  • Looping for remote servers and find its database from oratab file. Linux/Unix
  • How to calculate PROCESSES parameter 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

  • Temporary tablespace explaination Oracle
  • UTL_FILE test program Oracle
  • Gather Stats manually using DBMS_STATS after disabling DBMS_SCHEDULER jobs as previous entry Oracle
  • sess_server.sql Oracle
  • Changing unix system clock when Oracle database is running. Oracle
  • On solaris 10, “S” link is not part of $ORACLE_HOME/bin/oracle as default. ( For 9.2.0.8) Oracle

Leave a Reply Cancel reply

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

Categories

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

Recent Posts

  • Trace a SQL session from another session using ORADEBUG30-Sep-2025
  • SQL Server Vs Oracle Architecture difference25-Jul-2025
  • SQL Server: How to see historical transactions25-Jul-2025
  • SQL Server: How to see current transactions or requests25-Jul-2025
  • T-SQL Vs PL/SQL Syntax25-Jul-2025
  • Check SQL Server edition25-Jul-2025
  • Checking SQL Server Version25-Jul-2025
  • Oracle vs MYSQL Architecture differences (For DBAs)24-Jul-2025
  • V$INSTANCE of Oracle in MYSQL24-Jul-2025
  • Day to day MYSQL DBA operations (Compared with Oracle DBA)24-Jul-2025

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Reclaim temp tablespace for oracle 8, 8i Oracle
  • V$transaction notes for finding XID composition. Oracle
  • RAC with RHEL4 and 11g Oracle
  • Finding locked objects Oracle
  • Good notes for shared pool Oracle
  • TNSNAMES entries details Oracle
  • For Search and replace unix command. Linux/Unix
  • Jai Shree Ram Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme