Quantcast
Channel: Doyensys Allappsdba Blog..
Viewing all articles
Browse latest Browse all 1640

Query to find open cursor and to get sequence difference in a database

$
0
0
Please use the below query and change the value 1000 to your requirement as per the need.

select a.value, s.username, s.sid, s.serial#
  from v$sesstat a, v$statname b, v$session s
 where a.statistic# = b.statistic#  and s.sid=a.sid
   and b.name = 'opened cursors current'
   and a.value > 1000
 order by 1;


Please use the below query and change the  value 5000 to your requirement as per the need


SELECT   host_name||':'||instance_name || '   Sequence: '||sequence_owner||'.'|| sequence_name||
 '    Max_Value:'|| max_value || '   Increment_By:'|| increment_by ||'   Diff:'|| to_number(max_value-last_number)||
 '   Last_Number:'||last_number || '   Cycle_Flag:'||cycle_flag
FROM dba_sequences, v$instance
where (max_value-last_number) <=5000
and sequence_owner not in ('SYS','SYSTEM','WKSYS','GSMADMIN_INTERNAL','TOAD','DBSNMP','SYSMAN','ATSDBA')
ORDER BY instance_name desc;



Viewing all articles
Browse latest Browse all 1640

Trending Articles