22

I can use following statement to unlock an account:

ALTER USER username ACCOUNT UNLOCK

But which statement can I use to verify that account is currently locked out?

Mike
  • 747
  • 8
  • 14
  • 25

3 Answers3

31

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 :)

Izzy
  • 498
  • 1
  • 6
  • 14
6

Use DBA_USERS View.

SELECT username, account_status
FROM dba_users;
Dba
  • 196
  • 5
1

You can query this by specifying the username also:

select username, account_status
from dba_users
where username = 'your_user_name';
ypercubeᵀᴹ
  • 99,450
  • 13
  • 217
  • 306