Last logon for an Oracle user

Posted on 2014-04-29
Last Modified: 2014-06-05
I need to pull out a report for the all users in the database  with their last logoff time.
I already tried dba_audit_session....
There are some users who login and log out serveral times, I need only their last log off info...
Need help with the query from sys.aud $ table....
Oracle version -
thank you
Question by:gyans
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40029690
you want to start with this:
select userid, max(ntimestamp)
from sys.aud$
where action# in (100,101,102)
group by userid
LVL 77

Accepted Solution

slightwv (䄆 Netminder) earned 500 total points
ID: 40029710
Assuming you are currently auditing logoffs, another way

select username, max(logoff_time) from dba_audit_trail group by username;

Author Comment

ID: 40029730
hi Hengel,
It gives me an error with the timestamp being an invalid identifier.

Slightwv- cannot get the info from this view.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40029771
>>Slightwv- cannot get the info from this view.

Log in as a privileged user.

If that doesn't work, what version of Oracle are you using (all 4 numbers please).

Author Comment

ID: 40029780
slightwv - we only store audit for 1 week and move the rest to the archive table.
The archive table is identical to aud$ table, so I can only query from this table.
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40029816
>>so I can only query from this table. thanks

Then you don't really want the LAST logoff?  Just the last logoff you can see?

I'm not an Expert on auditing but the archive table you have should have similar columns to what Guy posted above.

Just describe the table and then check the online docs for your version and see what columns and audit actions are what you need.

Author Closing Comment

ID: 40115929
i wrote a query to get the last log off from the archive table .

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to recover a database from a user managed backup

761 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question