程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> 通過操作系統進程找到top sql信息

通過操作系統進程找到top sql信息

編輯:Oracle教程

通過操作系統進程找到top sql信息


SELECT 'USERNAME :' || s.username || chr(10) || 'SCHEMA:' || s.schemaname ||        chr(10) || 'OSUSER:' || s.osuser || chr(10) || 'SPID:' || p.spid ||        chr(10) || 'SID:' || s.sid || chr(10) || 'SERIAL#:' || s.serial# ||        chr(10) || 'KILL STRING: ' || '''' || s.sid || ',' || s.serial# || '''' ||        chr(10) || 'MACHINE: ' || s.machine || chr(10) || 'TYPE:' || s.type ||        chr(10) || 'SQL_ID:' || q.sql_id || chr(10) || 'SQL_TEXT: ' ||        q.sql_text   FROM v$session s, v$process p, v$sql q  WHERE s.paddr = p.addr    AND p.spid = '&PID_FROM_OS'    AND s.sql_id = q.sql_id(+)   'USERNAME:'||S.USERNAME||CHR(10)||'SCHEMA:'||S.SCHEMANAME||CHR(10)||'OSUSER:'||S -------------------------------------------------------------------------------- USERNAME :RPT SCHEMA:RPT OSUSER:zed SPID:54657092 SID:1854 SERIAL#:35907 KILL STRING: '1854,35907' MACHINE: aix TYPE:USER SQL_ID:4wv8ms79s6m37 SQL_TEXT: SELECT '073000' AS TIMEKEY FROM DUAL 'USERNAME:'||S.USERNAME||CHR(10)||'SCHEMA:'||S.SCHEMANAME||CHR(10)||'OSUSER:'||S     SQL>  select * from table(dbms_xplan.display_cursor(('&sql_id'))); Enter value for sql_id: 4wv8ms79s6m37 old   1:  select * from table(dbms_xplan.display_cursor(('&sql_id'))) new   1:  select * from table(dbms_xplan.display_cursor(('4wv8ms79s6m37')))   PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- SQL_ID  4wv8ms79s6m37, child number 0 ------------------------------------- SELECT '073000' AS TIMEKEY FROM DUAL   Plan hash value: 1546270724   ----------------------------------------------------------------- | Id  | Operation        | Name | Rows  | Cost (%CPU)| Time     | ----------------------------------------------------------------- |   0 | SELECT STATEMENT |      |       |     2 (100)|          | |   1 |  FAST DUAL       |      |     1 |     2   (0)| 00:00:01 |   PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- 13 rows selected.     也可以通過另外一種方式 SQL> conn / as sysdba Connected. SQL> oradebug setospid 54657092 Oracle pid: 45, Unix process pid: 54657092, image: oracle@aix (TNS V1-V3) SQL> oradebug current_sql; SELECT '235959' AS TIMEKEY FROM DUAL

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved