SELECT osuser, username, sql_text from v$session a, v$sqltext b
where a.sql_address =b.address order by address, piece;
2、查找死锁的语句:
SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username,
l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time
FROM v$locked_object l, all_objects o, v$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid
ORDER BY sid, s.serial#;
3、查看oracle的权限角色:
select * from dba_role_privs; 授予用户和其他角色的角色
select * from dba_sys_privs; 授予用户和其他角色的系统权限
select * from dba_tab_privs; 数据库中对象的所有授权
select * from user_role_privs; 查看当前用户的角色
4、oracle 查看已经执行过的sql 这些是存在共享池中的:
select * from v$sqlarea t order by t.LAST_ACTIVE_TIME desc;
5、【获取oracle前10条最耗资源的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<11;