How to get a list of locked accounts / check that account is locked?

As Dba's answer already shows, account status information is accessible via the dba_users view. Connected with a user having the appropriate grants, this can also be used to identify "inactive users":

SELECT username, account_status, created, lock_date, expiry_date
  FROM dba_users
 WHERE account_status != 'OPEN';

tells you for each locked/expired account when it was created, which state it is in (locked, expired, expired and locked, expired(grace)), and what time it was locked or expired. Useful for a "cleanup"; but you should consider that some accounts might just be "data holders" which are never connected to for security reasons, but required either by Oracle itself or your application(s). A good example for those is the system account OUTLN. So take care to only "clean out" accounts you know are not used/needed :)


Use DBA_USERS View.

SELECT username, account_status
FROM dba_users;

Tags:

Oracle