但是如果变成expired状态, oracle本身是不提供解锁的语句的, 因为账户过期,必须要用户更改密码, 账户才能重新使用. 但有些时候, 因为各种原因, 我们并不知道原密码的明文是什么,这时候就很麻烦了, 经研究发现,有两种方法可以实现:
SQL>conn /as sysdba SQL>select password from dba_users where username='SCOTT'; password ------------------------------ E65E6AF62B2449CF SQL>alter user SCOTT identified by values 'E65E6AF62B2449CF';
这种情况下,虽然我们不知道原密码是什么,但可以用它的密文来更改密码,这样,在不知道原密码的情况下,既保持了密码不改变, 又可以把expired的状态更改掉.
二. 下面这一条语句搞定,不管用户的状态是什么:
UPDATE USER$ SET ASTATUS=0 WHERE NAME='SCOTT';
SQL> select name,ASTATUS,password from user$ where name IN('SYS','SCOTT'); NAME ASTATUS PASSWORD ------------------------------ ---------- ------------------------------ SCOTT 1 E65E6AF62B2449CF SYS 0 8A8F025737A9097A SQL> select username,account_status from dba_users where username in('SYS','SCOTT'); USERNAME ACCOUNT_STATUS ------------------------------ -------------------------------- SYS OPEN SCOTT EXPIRED
SQL> select * from user_astatus_map; STATUS# STATUS ---------- -------------------------------- 0 OPEN 1 EXPIRED 2 EXPIRED(GRACE) 4 LOCKED(TIMED) 8 LOCKED 5 EXPIRED & LOCKED(TIMED) 6 EXPIRED(GRACE) & LOCKED(TIMED) 9 EXPIRED & LOCKED 10 EXPIRED(GRACE) & LOCKED 9 rows selected.
SQL> UPDATE USER$ SET ASTATUS=0 WHERE NAME='SCOTT'; 1 row updated. SQL> COMMIT; Commit complete. SQL> alter system flush shared_pool; System altered.
SQL> select name,ASTATUS,password from user$ where name IN('SYS','SCOTT'); NAME ASTATUS PASSWORD ------------------------------ ---------- ------------------------------ SCOTT 0 E65E6AF62B2449CF SYS 0 8A8F025737A9097A SQL> select username,account_status from dba_users where username in('SYS','SCOTT'); USERNAME ACCOUNT_STATUS ------------------------------ -------------------------------- SCOTT OPEN SYS OPEN