Oracle 用户账号解锁、密码重置、设置密码永不过期

--数据库系统信息
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

--可以看到,用户密码失效日期为空 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值