如何在 Oracle DB 中显示正在运行的进程?
是否可以显示 Oracle 数据库上正在进行的其他进程?类似于 Sybases sp_who
Is it possible to show other processes in progress on an Oracle database? Something like Sybases sp_who
推荐答案
我怀疑您只是想从 V$SESSION 中获取几列和从 V$SQL 中获取 SQL 语句.假设要排除Oracle本身正在运行的后台进程
I suspect you would just want to grab a few columns from V$SESSION and the SQL statement from V$SQL. Assuming you want to exclude the background processes that Oracle itself is running
SELECT sess.process, sess.status, sess.username, sess.schemaname, sql.sql_text
FROM v$session sess,
v$sql sql
WHERE sql.sql_id(+) = sess.sql_id
AND sess.type = 'USER'
外连接用于处理当前未激活的会话,假设您需要这些会话.您还可以从 V$SQL 获取 sql_fulltext 列,该列将包含完整的 SQL 语句,而不是前 1000 个字符,但这是一个 CLOB,因此处理起来可能有点复杂.
The outer join is to handle those sessions that aren't currently active, assuming you want those. You could also get the sql_fulltext column from V$SQL which will have the full SQL statement rather than the first 1000 characters, but that is a CLOB and so likely a bit more complicated to deal with.
实际上,您可能希望查看 V$SESSION 中可用的所有内容,因为您可以获得比 SP_WHO 提供的信息多得多的信息.
Realistically, you probably want to look at everything that is available in V$SESSION because it's likely that you can get a lot more information than SP_WHO provides.
相关文章