oracle管理

--查找事物锁

select * from v$lock where type='TX';

--查找 session

select * from v$session where sid=3016;

--查按时间段查找执行的sqlID

select count(1) from V$ACTIVE_SESSION_HISTORY t1 where t1.SESSION_ID=3016 and t1.SAMPLE_TIME>to_date('2011-06-02 08:50:00','yyyy-mm-dd hh24:mi:ss') and t1.SAMPLE_TIME<=to_date('2011-06-02 09:10:00','yyyy-mm-dd hh24:mi:ss');

--按时间段根据sessionID查找执行的SQL

select to_char(t.SAMPLE_TIME,'yyyy-mm-dd hh24:mi:ss'),t1.sql_text,t1.sql_fulltext,t1.sql_id from V$ACTIVE_SESSION_HISTORY t,v$sql t1 where t.SESSION_ID=3016 and t.sql_id=t1.SQL_ID and t.SAMPLE_TIME>to_date('2011-06-02 08:50:00','yyyy-mm-dd hh24:mi:ss') and t.SAMPLE_TIME<=to_date('2011-06-02 09:20:00','yyyy-mm-dd hh24:mi:ss');

你可能感兴趣的:(oracle,sql,Date,session)