[Reposted] Commonly used monitoring statements of Dameng database

Dream up a database used to monitor statements
original myth8860 finally released on 2019-09-10 16:38:47 read 475 the number of collections
launched


--Query the number of active sessions
select count (*) from v $ sessions where state = 'ACTIVE'; --End

session
sp_close_session (sessid); --session id found in v $ session


-Find out activities that have been executed for more than 2 seconds SQL
select * from (
SELECT sess_id, sql_text, datediff (ss, last_recv_time, sysdate) Y_EXETIME,
SF_GET_SESSION_SQL (SESS_ID) fullsql, clnt_ip
FROM V $ SESSIONS WHERE STATE = 'ACTIVE')
where Y_EXETIME> = 2;


--锁查询
select o.name,l.* from v$lock l,sysobjects o where l.table_id=o.id and blocked=1


--阻塞查询
with locks as(
select o.name,l.*,s.sess_id,s.sql_text,s.clnt_ip,s.last_send_time from v$lock l,sysobjects o,v$sessions s
where l.table_id=o.id and l.trx_id=s.trx_id ),
lock_tr as ( select trx_id wt_trxid,row_idx blk_trxid from locks where blocked=1),
res as( select sysdate stattime,t1.name,t1.sess_id wt_sessid,s.wt_trxid,
t2.sess_id blk_sessid,s.blk_trxid,t2.clnt_ip,SF_GET_SESSION_SQL(t1.sess_id) fulsql,
datediff(ss,t1.last_send_time,sysdate) ss,t1.sql_text wt_sql from lock_tr s,locks t1,locks t2
where t1.ltype='OBJECT' and t1.table_id<>0 and t2.ltype='OBJECT' and t2.table_id<>0
and s.wt_trxid=t1.trx_id and s.blk_trxid=t2.trx_id)
select distinct wt_sql,clnt_ip,ss,wt_trxid,blk_trxid from res;
————————————————
Copyright Statement: This article is an original article of CSDN blogger "myth8860", following the CC 4.0 BY-SA copyright agreement, please attach the original source link and this statement for reprint .
Original link: https://blog.csdn.net/myth8860/article/details/100703735

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/12714192.html