查看session及其对应运行的sql

select sql_id,machine,last_call_et esca_time,osuser,username ora_user from v$session where  username='scott' ORDER BY 2,1
 
 select * from table(dbms_xplan.display_awr(&SQL_ID));

 
 select sql_id,machine,last_call_et esca_time,osuser,username ora_user,status from v$session where username='scott' and status='ACTIVE'  ORDER BY 2,1

 

 

 

--查询程序进城sid
SELECT b.sql_text, sid, serial#, osuser, machine
  FROM v$session a, v$sqlarea b
 WHERE a.sql_address = b.address;

SELECT *
  FROM v$access
 WHERE owner = 'TAXDEV'
   AND OBJECT LIKE 'SP_%'
 ORDER BY sid;

--查询封杀进城sql
SELECT 'alter system kill session ''' || a.sid || ',' || a.serial# || ''''
  FROM v$session a
 WHERE EXISTS (SELECT 1
          FROM TABLE(fn_str2table('210')) b
         WHERE b.column_value = a.sid);

--查os进程号(服务端cmd运行,杀掉进程)
SELECT 'orakill ' || (SELECT instance_name FROM v$instance) || ' ' || spid os_sid
  FROM v$process
 WHERE addr = (SELECT paddr FROM v$session WHERE sid = '58');

 

你可能感兴趣的:(查看session及其对应运行的sql)