一、oracle中查找某段时间执行的操作记录
select sql_text,module, first_load_time
from v$sqlarea
where first_load_time > '2019-02-02/02:02:02' and first_load_time < '2019-02-02/02:02:02'
order by first_load_time
二、查看某一时间的执行过的所有sql
select t.SQL_TEXT, t.FIRST_LOAD_TIME
from v$sqlarea t
where t.FIRST_LOAD_TIME like '2019-01-28%'
order by t.FIRST_LOAD_TIME desc
三、查询当前执行sql的机器信息
SELECT SID, OSUSER, USERNAME, MACHINE, PROCESS
FROM V$SESSION
WHERE audsid = userenv( 'SESSIONID' );
四、查询执行某一时间,某台机器,执行的sql
方法1、
select b.sql_text,a.osuser,a.sid,a.machine
from v$session a ,v$sqlarea b
where a.sql_hash_value = b.hash_value ;
方法2、
select b.sql_text,a.osuser,a.sid,a.machine ,b.first_load_time
from v$session a ,v$sqlarea b
where a.sql_hash_value = b.hash_value and b.first_load_time like '2019-01-29%'
order by b.first_load_time desc ;
方法3、
SELECT b.sid oracleID, b.username Oracle用户, b.serial#, spid 操作系统ID, paddr, sql_text 正在执行的SQL, b.machine 计算机名
FROM v$process a, v$session b, v$sqlarea c
WHERE a.addr = b.paddr AND b.sql_hash_value = c.hash_value;
五、oracle中查找某用户执行某张表的操作操作记录
1,首先查找表的操作记录
select * from v$sqlarea a where a.SQL_TEXT like '%TB_ACCT_SYSDATE%';
2,从上面的记录中找到update语句对应的sql_id
select * from v$sqltext a,v$sqlarea b where a.SQL_ID=b.SQL_ID and b.SQL_ID in('cq53826tk4u3c','afftnrfhu5utk') order by b.LAST_ACTIVE_TIME desc;
3,从上面的记录中找到最新的sql操作记录,然后找到用户名和主机
select * from sys.v$session l,sys.v$sql s where s.SQL_ID='cq53826tk4u3c' and l.USERNAME is not null;
posted @
2023-10-22 17:25
yclizq
阅读(
368)
评论()
编辑
收藏
举报