Querying session info

A query of the session information with a decode of the command being executed.

Here is a query of the session information with a decode of the command being executed. WHERE clauses can be added to target specific commands.

SELECT status, 
       sid, 
       serial#, 
       TYPE, 
       username, 
       osuser, 
       server, 
       machine, 
       terminal, 
       program, 
       DECODE(command,1,'CREATE TABLE', 
                      2,'INSERT', 
                      3,'SELECT', 
                      4,'CREATE CLUSTER', 
                      5,'ALTER CLUSTER', 
                      6,'UPDATE', 
                      7,'DELETE', 
                      8,'DROP CLUSTER', 
                      9,'CREATE INDEX', 
                     10,'DROP INDEX', 
                     11,'ALTER INDEX', 
                     12,'DROP TABLE', 
                     13,'CREATE SEQUENCE', 
                     14,'ALTER SEQUENCE', 
                     15,'ALTER TABLE', 
                     16,'DROP SEQUENCE', 
                     17,'GRANT', 
                     18,'REVOKE', 
                     19,'CREATE SYNONYM', 
                     20,'DROP SYNONYM', 
                     21,'CREATE VIEW', 
                     22,'DROP VIEW', 
                     23,'VALIDATE INDEX', 
                     24,'CREATE PROCEDURE', 
                     25,'ALTER PROCEDURE', 
                     26,'LOCK TABLE', 
                     27,'NO OPERATION', 
                     28,'RENAME', 
                     29,'COMMENT', 
                     30,'AUDIT', 
                     31,'NOAUDIT', 
                     32,'CREATE DATABASE LINK', 
                     33,'DROP DATABASE LINK', 
                     34,'CREATE DATABASE', 
                     35,'ALTER DATABASE', 
                     36,'CREATE ROLLBACK SEGMENT', 
                     37,'ALTER ROLLBACK SEGMENT', 
                     38,'DROP ROLLBACK SEGMENT', 
                     39,'CREATE TABLESPACE', 
                     40,'ALTER TABLESPACE', 
                     41,'DROP TABLESPACE', 
                     42,'ALTER SESSION', 
                     43,'ALTER USER', 
                     44,'COMMIT', 
                     45,'ROLLBACK', 
                     46,'SAVEPOINT', 
                     47,'PL/SQL EXECUTE', 
                     48,'SET TRANSACTION', 
                     49,'ALTER SYSTEM SWITCH LOG', 
                     50,'EXPLAIN', 
                     51,'CREATE USER', 
                     52,'CREATE ROLE', 
                     53,'DROP USER', 
                     54,'DROP ROLE', 
                     55,'SET ROLE', 
                     56,'CREATE SCHEMA', 
                     57,'CREATE CONTROL FILE', 
                     58,'ALTER TRACING', 
                     59,'CREATE TRIGGER', 
                     60,'ALTER TRIGGER', 
                     61,'DROP TRIGGER', 
                     62,'ANALYZE TABLE', 
                     63,'ANALYZE INDEX', 
                     64,'ANALYZE CLUSTER', 
                     65,'CREATE PROFILE', 
                     66,'DROP PROFILE', 
                     67,'ALTER PROFILE', 
                     68,'DROP PROCEDURE', 
                     69,'DROP PROCEDURE', 
                     70,'ALTER RESOURCE COST', 
                     71,'CREATE SNAPSHOT LOG', 
                     72,'ALTER SNAPSHOT LOG', 
                     73,'DROP SNAPSHOT LOG', 
                     74,'CREATE SNAPSHOT', 
                     75,'ALTER SNAPSHOT', 
                     76,'DROP SNAPSHOT', 
                     79,'ALTER ROLE', 
                     85,'TRUNCATE TABLE', 
                     86,'TRUNCATE CLUSTER', 
                     88,'ALTER VIEW', 
                     91,'CREATE FUNCTION', 
                     92,'ALTER FUNCTION', 
                     93,'DROP FUNCTION', 
                     94,'CREATE PACKAGE', 
                     95,'ALTER PACKAGE', 
                     96,'DROP PACKAGE', 
                     97,'CREATE PACKAGE BODY', 
                     98,'ALTER PACKAGE BODY', 
                     99,'DROP PACKAGE BODY', 
                        'Unknown') 
      Command 
FROM V$SESSION 
ORDER BY 5,11; 

For More Information

  • What do you think about this tip? E-mail the Editor at tdichiara@techtarget.com with your feedback.
  • The Best Oracle Web Links: tips, tutorials, scripts, and more.
  • Have an Oracle tip to offer your fellow DBA's and developers? The best tips submitted will receive a cool prize--submit your tip today!
  • Ask your technical Oracle questions--or help out your peers by answering them--in our live discussion forums.
  • Check out our Ask the Experts feature: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.

This was first published in December 2001

Dig deeper on Oracle and SQL

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close