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.
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

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

Industry Leaders: 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!

Question has a verified solution.

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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This post first appeared at Oracleinaction  ( Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

739 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