当前位置: 数据库>oracle
探讨:Oracle数据库查看一个进程是如何执行相关的实际SQL语句
来源: 互联网 发布时间:2014-09-07
本文导语: Oracle数据库查看一个进程是如何执行相关的实际SQL语句 代码如下:SELECT b.sql_text, sid, serial#, osuser, machine FROM v$session a, v$sqlarea b WHERE a.sql_address = b.address; 查询前台发出的SQL语句. 代码如下:select user_name,sql_text from v$...
Oracle数据库查看一个进程是如何执行相关的实际SQL语句
SELECT b.sql_text, sid, serial#, osuser, machine
FROM v$session a, v$sqlarea b
WHERE a.sql_address = b.address;
查询前台发出的SQL语句.
select user_name,sql_text
from v$open_cursor
where sid in
(select sid from (select sid,serial#,username,program from v$session where status='ACTIVE'));
根据SPID查询session
SELECT * FROM v$session WHERE paddr IN
(SELECT addr FROM v$process WHERE spid=&spid);
根据SID查询process
SELECT * FROM v$process WHERE addr IN
(SELECT paddr FROM v$session WHERE sid=&sid);
DBA如何查询其他用户所进行的操作
SELECT sql_text
FROM v$sql t1, v$session t2
WHERE t1.address = t2.sql_address
AND t2.sid = &sid;
根据process查询sql语句
SELECT sql_text
FROM v$sqltext a
WHERE (a.hash_value, a.address) IN (
SELECT DECODE (sql_hash_value,0, prev_hash_value,sql_hash_value ),
DECODE (sql_hash_value, 0, prev_sql_addr, sql_address)
FROM v$session b
WHERE b.paddr = (SELECT addr
FROM v$process c
WHERE c.spid = '$processID'))
ORDER BY piece ASC;
其他
执行下列命令语句
sqlplus / as sysdba
代码如下:
SELECT b.sql_text, sid, serial#, osuser, machine
FROM v$session a, v$sqlarea b
WHERE a.sql_address = b.address;
查询前台发出的SQL语句.
代码如下:
select user_name,sql_text
from v$open_cursor
where sid in
(select sid from (select sid,serial#,username,program from v$session where status='ACTIVE'));
根据SPID查询session
代码如下:
SELECT * FROM v$session WHERE paddr IN
(SELECT addr FROM v$process WHERE spid=&spid);
根据SID查询process
代码如下:
SELECT * FROM v$process WHERE addr IN
(SELECT paddr FROM v$session WHERE sid=&sid);
DBA如何查询其他用户所进行的操作
代码如下:
SELECT sql_text
FROM v$sql t1, v$session t2
WHERE t1.address = t2.sql_address
AND t2.sid = &sid;
根据process查询sql语句
代码如下:
SELECT sql_text
FROM v$sqltext a
WHERE (a.hash_value, a.address) IN (
SELECT DECODE (sql_hash_value,0, prev_hash_value,sql_hash_value ),
DECODE (sql_hash_value, 0, prev_sql_addr, sql_address)
FROM v$session b
WHERE b.paddr = (SELECT addr
FROM v$process c
WHERE c.spid = '$processID'))
ORDER BY piece ASC;
其他
执行下列命令语句
代码如下:
sqlplus / as sysdba