DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Last login

  1. #1
    Join Date
    Jun 2000
    Location
    Maputo, Maputo-Mozambique
    Posts
    96

    Last login

    How can i check the last time that the user logged in, on the oracle
    database?
    I want to delete users that never log to the databse.
    In god i trust

  2. #2
    Join Date
    May 2001
    Posts
    736
    use the following script

    whenever sqlerror exist rollback
    set feed on
    set head on
    set arraysize 1
    set space 1
    set verify on
    set pages 25
    set lines 80
    set termout on
    clear screen

    spool aud_last_logon.lis

    undefine number_of_days

    col username for a10
    col os_username for a10
    col timestamp for a9
    col logoff_time for a9
    col returncode for 9999
    col terminal for a10
    col userhost for a10


    select a.username,
    os_username,
    a.timestamp,
    a.logoff_time,
    a.returncode,
    terminal,
    userhost
    from dba_audit_session a
    where (a.username,a.timestamp) in
    (select b.username,max(b.timestamp)
    from dba_audit_session b
    group by b.username)
    and a.timestamp<(sysdate-&&number_of_days)
    /

    spool off

  3. #3
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    Originally posted by akhadar
    use the following script

    whenever sqlerror exist rollback
    set feed on
    set head on
    set arraysize 1
    set space 1
    set verify on
    set pages 25
    set lines 80
    set termout on
    clear screen

    spool aud_last_logon.lis

    undefine number_of_days

    col username for a10
    col os_username for a10
    col timestamp for a9
    col logoff_time for a9
    col returncode for 9999
    col terminal for a10
    col userhost for a10


    select a.username,
    os_username,
    a.timestamp,
    a.logoff_time,
    a.returncode,
    terminal,
    userhost
    from dba_audit_session a
    where (a.username,a.timestamp) in
    (select b.username,max(b.timestamp)
    from dba_audit_session b
    group by b.username)
    and a.timestamp<(sysdate-&&number_of_days)
    /

    spool off
    dont forget you need to turn auditing on to do that

  4. #4
    Join Date
    May 2001
    Posts
    736

    Thumbs up

    Missed the main thing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width