oracle查询执行的sql
⑴ 如何查看oracle最近执行的sql
oracle 查询最近执行过的 SQL语句
selectsql_text,last_load_timefromv$sqlorderbylast_load_timedesc;
SELECTsql_text,last_load_timeFROMv$sqlWHERElast_load_timeISNOTNULLandsql_textlike'select%'ORDERBYlast_load_timeDESC;
SELECTsql_text,last_load_timeFROMv$sqlWHERElast_load_timeISNOTNULLandsql_textlike'update%'ORDERBYlast_load_timeDESC;
SELECTsql_text,last_load_timeFROMv$sqlWHERElast_load_timeISNOTNULLandlast_load_timelike'14-06-09%'ORDERBYlast_load_timeDESC;
⑵ 如何查看oracle某用户近期执行的SQL
oracle 查询最近执行过的 SQL语句
select sql_text,last_load_time from v$sql order by last_load_time desc;SELECT sql_text, last_load_time FROM v$sql WHERE last_load_time IS NOT NULL and sql_text like 'select%' ORDER BY last_load_time DESC;SELECT sql_text, last_load_time FROM v$sql WHERE last_load_time IS NOT NULL and sql_text like 'update%' ORDER BY last_load_time DESC;SELECT sql_text, last_load_time FROM v$sql WHERE last_load_time IS NOT NULL and last_load_time like' 14-06-09%' ORDER BY last_load_time DESC;---正在执行的
select a.username, a.sid,b.SQL_TEXT, b.SQL_FULLTEXTfrom v$session a, v$sqlarea b
where a.sql_address = b.address
---执行过的
select b.SQL_TEXT,b.FIRST_LOAD_TIME,b.SQL_FULLTEXTfrom v$sqlarea b
where b.FIRST_LOAD_TIME between '2009-10-15/09:24:47' and'2009-10-15/09:24:47' order by b.FIRST_LOAD_TIME(此方法好处可以查看某一时间段执行过的sql,并且 SQL_FULLTEXT 包含了完整的 sql 语句)其他
select OSUSER,PROGRAM,USERNAME,SCHEMANAME,B.Cpu_Time,STATUS,B.SQL_TEXTfrom V$SESSION A LEFT JOIN V$SQL B ON A.SQL_ADDRESS=B.ADDRESS AND A.SQL_HASH_VALUE=B.HASH_VALUE order by b.cpu_time descselect address, sql_text, piece
from v$session, v$sqltext
where address = sql_address
-- and machine = < you machine name >
order by address, piece
查找前十条性能差的sql.
SELECT * FROM (select PARSING_USER_ID,EXECUTIONS,SORTS,COMMAND_TYPE,DISK_READS,sql_text FROM v$sqlareaorder BY disk_reads DESC )where ROWNUM<10 ;查看占io较大的正在运行的session
SELECT se.sid,se.serial#,pr.SPID,se.username,se.status,se.terminal,se.program,se.MODULE,、se.sql_address,st.event,st.
p1text,si.physical_reads,
si.block_changes FROM v$session se,v$session_wait st,v$sess_io si,v$process pr WHERE st.sid=se.sid AND st.
sid=si.sid AND se.PADDR=pr.ADDR AND se.sid>6 AND st.
wait_time=0 AND st.event NOT LIKE '%SQL%' ORDER BY physical_reads DESC
⑶ 在ORACLE 中怎么查看SQL 执行日志
1、首先打开oracle sql developer工具,没有此工具的可以去网络浏览器下载安装即可,鼠标点击查看菜单。
⑷ oracle怎么查看sql执行计划
一般需要借助第三方工具来查看执行计划。
工具:PL/SQL
步骤:
1、打开第三方工具PL/SQL,并登录到指定数据库。
⑸ oracle 中怎样查看以前执行过的SQL语句
您好,我来为您解答:
可以通过logminer分析日志文件
查询某时间段执行过的语句。
如果我的回答没能帮助您,请继续追问。
⑹ 求教高手:在oracle中如何查看执行的sql语句
查询Oracle正在执行的sql语句及执行该语句的用户
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 cWHERE a.addr = b.paddr AND b.sql_hash_value = c.hash_value
查看正在执行sql的发起者的发放程序
SELECT OSUSER 电脑登录身份, PROGRAM 发起请求的程序, USERNAME 登录系统的用户名, SCHEMANAME, B.Cpu_Time 花费cpu的时间, STATUS, B.SQL_TEXT 执行的sqlFROM V$SESSION ALEFT JOIN V$SQL B ON A.SQL_ADDRESS = B.ADDRESS AND A.SQL_HASH_VALUE = B.HASH_VALUEORDER BY b.cpu_time DESC
⑺ 如何查看oracle服务器上正在执行的SQL语句
首先,你要以dba身份登陆数据库。 第二,为某个用户开启sql跟踪。那个用户就是你要跟踪的、正在执行sql语句的那个用户。命令如下: execute dbms_system.set_sql_trace_in_session(sid,serial#,true) 其中参数的意义是,sid-会话id,serial#-序列号,这两个参数可以从v$session中得到。 第三,上面的命令执行成功之后数据库就自动对该用户所发出的所有sql语句进行跟踪,并把结果写在用户跟踪文件里。用户跟踪文件存放在数据库服务器上,路径请参考init.ora文件中的ump参数值。文件名为ora_sid_xxxx.trc(for unix)或者oraxxxxx.trc(for NT),其中xxxx文件系统进程编号,这个编号可以从v$process和v$session两个表通过关联的方式查询得到。
⑻ 怎样查看ORACLE执行过的SQL 语句
oracle 查询最近执行过的 SQL语句
select sql_text,last_load_time from v$sql order by last_load_time desc;
SELECT sql_text, last_load_time FROM v$sql WHERE last_load_time IS NOT NULL and sql_text like 'select%' ORDER BY last_load_time DESC;
SELECT sql_text, last_load_time FROM v$sql WHERE last_load_time IS NOT NULL and sql_text like 'update%' ORDER BY last_load_time DESC;
SELECT sql_text, last_load_time FROM v$sql WHERE last_load_time IS NOT NULL and last_load_time like' 14-06-09%' ORDER BY last_load_time DESC;
---正在执行的
select a.username, a.sid,b.SQL_TEXT, b.SQL_FULLTEXT
from v$session a, v$sqlarea b
where a.sql_address = b.address
---执行过的
select b.SQL_TEXT,b.FIRST_LOAD_TIME,b.SQL_FULLTEXT
from v$sqlarea b
where b.FIRST_LOAD_TIME between '2009-10-15/09:24:47' and
'2009-10-15/09:24:47' order by b.FIRST_LOAD_TIME
(此方法好处可以查看某一时间段执行过的sql,并且 SQL_FULLTEXT 包含了完整的 sql 语句)
其他
select OSUSER,PROGRAM,USERNAME,SCHEMANAME,B.Cpu_Time,STATUS,B.SQL_TEXT
from V$SESSION A LEFT JOIN V$SQL B ON A.SQL_ADDRESS=B.ADDRESS AND A.SQL_HASH_VALUE=B.HASH_VALUE order by b.cpu_time desc
select address, sql_text, piece
from v$session, v$sqltext
where address = sql_address
-- and machine = < you machine name >
order by address, piece
查找前十条性能差的sql.
SELECT * FROM (select PARSING_USER_ID,EXECUTIONS,SORTS,
COMMAND_TYPE,DISK_READS,sql_text FROM v$sqlarea
order BY disk_reads DESC )where ROWNUM<10 ;
查看占io较大的正在运行的session
SELECT se.sid,se.serial#,pr.SPID,se.username,se.status,
se.terminal,se.program,se.MODULE,、se.sql_address,st.event,st.
p1text,si.physical_reads,
si.block_changes FROM v$session se,v$session_wait st,
v$sess_io si,v$process pr WHERE st.sid=se.sid AND st.
sid=si.sid AND se.PADDR=pr.ADDR AND se.sid>6 AND st.
wait_time=0 AND st.event NOT LIKE '%SQL%' ORDER BY physical_reads DESC