--数据库系统信息
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
SQL> select sysdate from dual;
SYSDATE
---------
26-JUN-17
--查看用户状态
SQL> set linesize 100
SQL> col username for a30
SQL> alter user sean password expire;
SQL> alter user sean account lock;
SQL> select USERNAME,ACCOUNT_STATUS,LOCK_DATE,EXPIRY_DATE,PROFILE from dba_users where username in ('SEAN');
USERNAME ACCOUNT_STATUS LOCK_DATE EXPIRY_DA PROFILE
---------- -------------------- --------- --------- -------
SEAN EXPIRED & LOCKED 26-JUN-17 26-JUN-17 DEFAULT
--解锁用户
SQL> alter user sean account unlock;
--重新设置密码
SQL> alter user sean password unexpire;
alter user sean password unexpire
*
ERROR at line 1:
ORA-02000: missing EXPIRE keyword
--报错,只能重置设置密码(可以和老密码相同)
SQL> alter user sean identified by sean;
SQL> select USERNAME,ACCOUNT_STATUS,LOCK_DATE,EXPIRY_DATE,PROFILE from dba_users where username in ('SEAN');
USERNAME ACCOUNT_STATUS LOCK_DATE EXPIRY_DA PROFILE
---------- -------------------- --------- --------- --------------------
SEAN OPEN 23-DEC-17 DEFAULT
--可以看到新设置的密码180天后失效,其实是用户sean对应的profile中的属性PASSWORD_LIFE_TIME值控制的
SQL> select * from dba_profiles where profile='DEFAULT';
PROFILE RESOURCE_NAME RESOURCE LIMIT
-------------------- -------------------------------- -------- ----------------------------------------
DEFAULT COMPOSITE_LIMIT KERNEL UNLIMITED
DEFAULT SESSIONS_PER_USER KERNEL UNLIMITED
DEFAULT CPU_PER_SESSION KERNEL UNLIMITED
DEFAULT CPU_PER_CALL KERNEL UNLIMITED
DEFAULT LOGICAL_READS_PER_SESSION KERNEL UNLIMITED
DEFAULT LOGICAL_READS_PER_CALL KERNEL UNLIMITED
DEFAULT IDLE_TIME KERNEL UNLIMITED
DEFAULT CONNECT_TIME KERNEL UNLIMITED
DEFAULT PRIVATE_SGA KERNEL UNLIMITED
DEFAULT FAILED_LOGIN_ATTEMPTS PASSWORD 10
DEFAULT PASSWORD_LIFE_TIME PASSWORD 180
DEFAULT PASSWORD_REUSE_TIME PASSWORD UNLIMITED
DEFAULT PASSWORD_REUSE_MAX PASSWORD UNLIMITED
DEFAULT PASSWORD_VERIFY_FUNCTION PASSWORD NULL
DEFAULT PASSWORD_LOCK_TIME PASSWORD 1
DEFAULT PASSWORD_GRACE_TIME PASSWORD 7
--如果想设置用户密码永不过期,那么设置用户对应的profile的PASSWORD_LIFE_TIME为unlimited
SQL> alter profile default LIMIT PASSWORD_LIFE_TIME unlimited;
SQL> select * from dba_profiles where profile='DEFAULT' and RESOURCE_NAME='PASSWORD_LIFE_TIME';
PROFILE RESOURCE_NAME RESOURCE LIMIT
-------------------- -------------------------------- -------- ----------------------------------------
DEFAULT PASSWORD_LIFE_TIME PASSWORD UNLIMITED
SQL> select USERNAME,ACCOUNT_STATUS,LOCK_DATE,EXPIRY_DATE,PROFILE from dba_users where username in ('SEAN');
USERNAME ACCOUNT_STATUS LOCK_DATE EXPIRY_DA PROFILE
---------- -------------------- --------- --------- --------------------
SEAN OPEN DEFAULT
--可以看到,用户密码失效日期为空
Oracle 用户账号解锁、密码重置、设置密码永不过期
最新推荐文章于 2024-09-19 08:54:35 发布