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.
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

627 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