Please see my other blog for Oracle EBusiness Suite Posts - EBMentors

Search This Blog

Note: All the posts are based on practical approach avoiding lengthy theory. All have been tested on some development servers. Please don’t test any post on production servers until you are sure.

Tuesday, October 04, 2011

All Users with Client side Info

Create Or Replace Force View Sys.Av_users_all (Logon_time,
                                               Sid,
                                               Serial#,

                                               Status,
                                               Last_call_et,
                                               Username,
                                               Osuser,
                                               Terminal,
                                               Program,
                                               Rmt_tz,
                                               Rmt_ip,
                                               Rmt_host,
                                               Rmt_un,
                                               Rmt_os,
                                               Rmt_lang,
                                               Client_info,
                                               Command,
                                               Command_decode,
                                               Lockwait,
                                               Blocking_session_status,
                                               Blocking_session,
                                               Event,
                                               State,
                                               Service_name,
                                               Killstmt
                                              )
As
   Select   Logon_time, Sid, Serial#, Status, Last_call_et, Username, Osuser,
            Terminal, Program,
            Substr (Client_identifier,
                    4,
                    Instr (Client_identifier, ')', 1, 1) - 4
                   ) Rmt_tz,
            Substr (Client_identifier,
                    Instr (Client_identifier, '(', 1, 2) + 1,
                      (  Instr (Client_identifier, ')', 1, 2)
                       - Instr (Client_identifier, ')', 1, 1)
                      )
                    - 4
                   ) Rmt_ip,
            Substr (Client_identifier,
                    Instr (Client_identifier, '(', 1, 3) + 1,
                      (  Instr (Client_identifier, ')', 1, 3)
                       - Instr (Client_identifier, ')', 1, 2)
                      )
                    - 4
                   ) Rmt_host,
            Substr (Client_identifier,
                    Instr (Client_identifier, '(', 1, 4) + 1,
                      (  Instr (Client_identifier, ')', 1, 4)
                       - Instr (Client_identifier, ')', 1, 3)
                      )
                    - 4
                   ) Rmt_un,
            Substr (Client_info, 4, Instr (Client_info, ')', 1, 1) - 4)
                                                                       Rmt_os,
            Substr (Client_info,
                    Instr (Client_info, 'LN(', 1, 1) + 3,
                    2
                   ) Rmt_lang,
            Client_info, Command,
            Decode (Command,
                    0, 'BACKGROUND',
                    1, 'Create Table',
                    2, 'INSERT',
                    3, 'SELECT',
                    4, 'CREATE CLUSTER',
                    5, 'ALTER CLUSTER',
                    6, 'UPDATE',
                    7, 'DELETE',
                    8, 'DROP',
                    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 EXTERNAL DATABASE',
                    33, 'DROP EXTERNAL DATABASE',
                    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',
                    87, '-',
                    88, 'ALTER VIEW',
                    89, '-',
                    90, '-',
                    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',
                    Command || ' - ???'
                   ) Command_decode,
            Lockwait, Blocking_session_status, Blocking_session, Event, State,
            Service_name,
               'Alter SYSTEM Kill Session '
            || ''''
            || Sid
            || ','
            || Serial#
            || ''' '
            || 'IMMEDIATE;' Killstmt
       From V$session
      Where (Program Not Like 'ORACLE.EXE%')
        And Program Not Like 'racgimon%'
   Order By Last_call_et Desc

Related Post:  How To Audit Application Username Using Trigger 
 

No comments: