何查看session执行的sql语句
老生常谈:
首先要用到上面的四个动态视图。
实验:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> insert into jiajie values(99);
1 row created.
SQL> show user
USER is "JIAJIE"
SQL>
用户名为jiajie的用户执行insert语句
SQL> select username,sql_address,prev_sql_addr from v$session
USERNAME SQL_ADDR PREV_SQL
------------------------------ -------- --------
JIAJIE 00 6875BABC
6B78CF90 00
00 00
SYS 68777D00 68DEF1F4
00 00
6918FD28 00
00 00
JIAJIE 00 687C9EAC
00 00
00 00
6A9E115C 00
SQL> select sql_text from v$sql where address = '6875BABC';
SQL_TEXT
------------------------------------------------------------
insert into jiajie values(99)
这样我们就追踪到了刚才用户为jiajie执行的sql语句