Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Shuffle an array PHP/MYSQL/Wordpress
  • pvm_pre_change.sql Oracle
  • Rman Notes -1 Oracle
  • How to Use DBMS_STATS to Move Statistics to a Different Database Oracle
  • Pending Distributed Transations Oracle
  • DETERMINING WHICH INSTANCE OWNS WHICH SHARED MEMORY & SEMAPHORE SEGMENTS Oracle
  • Btee and Bitmap Plans in Oracle 9i and higher Oracle
  • tblwopk.sql tablewopk.sql Oracle
  • Processes parameter and its dependencies on OS kernel parameters Linux/Unix
  • 751131.1 New Article Error 2819 While Requesting a Systemstate Dump Oracle
  • Remove DOS CR/LFs (^M) Linux/Unix
  • db_status.sql Oracle
  • Disbaling DBA_SCHEDULER_JOBS Oracle
  • Read CSV File using Python Python/PySpark
  • How to specify 2 arch location to avoid any kind of DB hanging. 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

  • All About Trace Fils Oracle
  • create trigger syntax Oracle
  • find_log_switch.sql Find log switches in graphical manner Oracle
  • Rman Notes -1 Oracle
  • Rename Tablespace Oracle
  • SQLPLUS COPY command Precautions. 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 (392)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • load SPM baseline from cursor cache05-Jun-2025
  • Drop all SPM baselines for SQL handle05-Jun-2025
  • Load SPM baseline from AWR05-Jun-2025
  • Drop specific SQL plan baseline – spm05-Jun-2025
  • 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

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Resolving RMAN Hung Jobs Oracle
  • sbind.sql Find Bind variable from sql_id sqlid Oracle
  • Find average Row Length and other table size calculation. metalink notes Oracle
  • find_pk.sql /* Find Primary Key */ Oracle
  • Goldengate document from Porus Oracle
  • How To Limit The Access To The Database So That Only One User Per Schema Are Connected (One Concurrent User Per Schema) Oracle
  • Pending Transaction Neighbors Script Oracle
  • sid_wise_sql.sql Further explaination Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme