Ai
1 Star 1 Fork 0

冯际成/Oracle_SQL_Scripts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
sess_users_sql_active.sql 1.75 KB
一键复制 编辑 原始数据 按行查看 历史
Abdul mohammed 提交于 2016-02-06 08:58 +08:00 . Fri Feb 5 18:58:16 CST 2016
-- | PURPOSE : List all currently connected and active users and the SQL that |
-- | they are running. |
-- | NOTE : As with any code, ensure to test this script in a development |
-- | environment before attempting to run it in production. |
-- +----------------------------------------------------------------------------+
SET PAGESIZE 9999
COLUMN sid FORMAT 99999 HEADING 'SID'
COLUMN session_status FORMAT a9 HEADING 'Status' JUSTIFY right
COLUMN oracle_username FORMAT a14 HEADING 'Oracle User' JUSTIFY right
COLUMN os_username FORMAT a12 HEADING 'O/S User' JUSTIFY right
COLUMN os_pid FORMAT 9999999 HEADING 'O/S PID' JUSTIFY right
COLUMN session_program FORMAT a26 HEADING 'Session Program' TRUNC
COLUMN current_sql FORMAT a45 HEADING 'Current SQL' WRAP
prompt
prompt +----------------------------------------------------+
prompt | All Active User Sessions and Current SQL |
prompt +----------------------------------------------------+
SELECT
s.sid sid
, lpad(s.status,9) session_status
, lpad(s.username,14) oracle_username
, lpad(s.osuser,12) os_username
, lpad(p.spid,7) os_pid
, s.program session_program
, SUBSTR(sa.sql_text, 1, 600) current_sql
FROM
v$process p
, v$session s
, v$sqlarea sa
WHERE
p.addr (+) = s.paddr
AND s.sql_address = sa.address(+)
AND s.sql_hash_value = sa.hash_value(+)
AND s.audsid <> userenv('SESSIONID')
AND s.username IS NOT NULL
AND s.status = 'ACTIVE'
ORDER BY sid
/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sapall/Oracle_SQL_Scripts.git
git@gitee.com:sapall/Oracle_SQL_Scripts.git
sapall
Oracle_SQL_Scripts
Oracle_SQL_Scripts
master

搜索帮助