How do I show running processes in Oracle DB?

前端 未结 4 604
北荒
北荒 2020-12-12 11:09

Is it possible to show other processes in progress on an Oracle database? Something like Sybases sp_who

4条回答
  •  孤街浪徒
    2020-12-12 11:53

    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'
    

    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.

    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.

提交回复
热议问题