calculating oracle users average session time [closed]
How to write a PL/SQL program to calculate and display the username 开发者_开发问答and average session time for all database users in oracle 11g ? kindly help
By default Oracle does not audit things like user access. There are built-in options, but they are switched off by default.
To enable Oracle's audit trail, we need to set the AUDIT_TRAIL parameter. Set it to DB
to have records written to a table; this is more convenient for querying than an OS file (unless your grep
is better than your SQL). Find out more.
To monitor user connections and disconnections, ask a DBA to issue the following statement:
AUDIT SESSION;
Then you can write your query off the DBA_AUDIT_SESSION view. Something like:
select USERNAME
, avg(LOGOFF_TIME - TIMESTAMP)
from DBA_AUDIT_SESSION
group by USERNAME;
Note that this is on;y going to give you meaningful information if you have an application with Old Skool named user accounts. Web applications with connection pooling will all be audited as the same user, so you will need to write a bespoke logging tool.
精彩评论