제가 다른 게시판에는 write 권한이 없어서 자꾸 이쪽에만 글을 올리게 되네여..ㅋㅋ
이번에는 informix 관리 시 유용하게 사용할 수 있는 쿼리 몇개를 올려드립니다.
How long has the user been connected
select sid, username,
dbinfo('UTC_TO_DATETIME',connected) conection_time,
current - dbinfo('UTC_TO_DATETIME',connected)
connected_since
from syssessions
order by 2,3;
How long has the user been idle
SELECT s.sid, s.username, q.odb_dbname database,
dbinfo('UTC_TO_DATETIME',s.connected) conection_time,
dbinfo('UTC_TO_DATETIME',t.run_time) last_run_time,
current - dbinfo('UTC_TO_DATETIME',t.run_time) idle_time
FROM syssessions s, systcblst t, sysrstcb r, sysopendb q
WHERE t.tid = r.tid AND s.sid = r.sid AND s.sid = q.odb_sessionid
ORDER BY 6 DESC;
How to link a session to a transaction
select tx_id
from systrans
where tx_addr = select us_txp
from sysuserthreads
where us_sid = SESSIONID);
How to find the busy tables
select systabnames.tabname,
sysptntab.pf_isread,
sysptntab.pf_iswrite,
sysptntab.pf_isrwrite,
sysptntab.pf_isdelete,
sysptntab.pf_seqscans
from systabnames, sysptntab
where systabnames.partnum = sysptntab.partnum;
How long has the database engine been running
select dbinfo('UTC_TO_DATETIME', sh_curtime)
- dbinfo('UTC_TO_DATETIME', sh_boottime)
from sysshmvals;
How to find the current SQL statement
select sqs_statement
from syssqlstat
where sqs_statement;
or
select sqx_sessionid,
sqx_conbno,
sqx_sqlstatement
from syssqexplain,
sysscblst
where sqx_sessionid = sid
order by 1,2 ;
|