Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • age_alert.ksh aging out alert.log Linux/Unix
  • Find all users who have DML privileges Oracle
  • Import and export statements Oracle
  • Unix command for system configuration Linux/Unix
  • Flowers Resize datafiles Oracle
  • Temporary Tablespace Information and restriction. Oracle
  • AWR settings- MMON is not taking snapshot. Oracle
  • backspace in SQL Plus not working then..? Linux/Unix
  • switchover for primary database Oracle
  • Create type and Grant on it. Oracle
  • Find total file sizes Linux/Unix
  • How to see which patches are applied. Oracle
  • DBMS_UTILITY.ANALYZE_SCHEMA Oracle
  • How to find Unix server conguraiton including Server Model number and underlying disk sub-system ( On Solaris) Linux/Unix
  • usnsql.sql Displays information about UNDO segments with sql statements Oracle

GSQ.sql

Posted on 19-May-202325-May-2023 By Admin No Comments on GSQ.sql

This SQL will be used to identify SQL details of given Session. You need to pass SID and INSTANCE_ID as INPUT. This query will provide session details, SQL_ID, SQL_EXEC_START time and other transaction level details.


set echo off feedback off verify off
col Transaction_id format a20
col username format a8
col days format 99.99
col hours1 format 999999
col TX_HRS format 999.9
col USER_HRS format 999.9
col LOCK format a2
column sql_address format a30
column sql_hash_value format 9999999999
column plan_hash_value format 9999999999999
accept v_instid prompt 'Enter Instance ID ->'
accept v_sid prompt 'Enter oracle sid ->'
set lines 168 pages 200
set long 3000
select a.inst_id || ':' || a.sid || ',' || a.serial# sid_info, a.service_name, a.sql_id xsql_id, a.sql_child_number xsql_child_number,
c.plan_hash_value, a.username, a.osuser, a.machine,
a.status sess_status, b.xidusn||'.'||b.xidslot||'.'||b.xidsqn Transaction_id, b.xid,
decode(UBAFIL,0, decode(UBABLK, 0, decode(UBASQN, 0, 'N', 'Y'), 'Y'), 'Y') "LOCK",
c.sql_profile, d.spid "os pid", a.program, a.module, c.sql_fulltext, a.event,
b.start_time "TX Start Time", round((sysdate - to_date(b.start_time, 'MM/DD/YY HH24:MI:SS')) * 24*60,1) "TX_MINS",
to_char(a.logon_time, 'DD-MON-RRRR:HH24:MI') "Logon Time", round((sysdate - a.logon_time) * 24*60,1) "LOGON_MINS",
a.blocking_session||'@'|| a.blocking_instance, a.sql_exec_start,
'alter system kill session ''' || a.sid || ',' || a.serial# || ', @' || a.inst_id || ''';' || chr(10) || lpad('+', 80, '+')
from gv$session a
left outer join gv$transaction b on (a.SADDR = b.SES_ADDR and a.inst_id = b.inst_id)
left outer join gv$sql c on (a.inst_id=c.inst_id and a.sql_id = c.sql_id and a.sql_child_number = c.child_number)
join gv$process d on (a.paddr = d.addr and a.inst_id=d.inst_id)
where a.sid='&v_sid'
and a.inst_id='&v_instid';

Oracle, SQL scripts Tags:data, databases, Get session information, Oracle expert, Oracle wait events, SQL, tuning expert

Post navigation

Previous Post: PHP code to add WordPress posts in bulk programmatically
Next Post: ENQ: KO – FAST OBJECT CHECKPOINT tips

Related Posts

  • proc.sql Oracle
  • oradebug ipcrm ipcs Oracle
  • import-export with multiple files Oracle
  • Is It Recommended To Apply Patch Bundles When PSU Is Available? -ID 743554.1 Oracle
  • find_longsql.sql Oracle
  • create database syntax 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
  • get_vmstat_solaris Oracle
  • currwaitobj.sql SQl_ID and SQL statement you can get from currwaitobj.sql Oracle
  • arch_configUOCIOTTO.ora Oracle
  • get_aix_vmstat.ksh Oracle
  • Search and replace pattern Linux/Unix
  • DBMS_PROFILER for tuning PLSQL programs. Oracle
  • Oracle Support Metalink ID 161818.1 Oracle
  • Oracle Standby Database Library Index from Metalink Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme