Oracle用户密码重置

客户反馈Oracle数据库用户密ma会过期,为了避免过期导致应用连接出错,可提前cha找即将过期的用户,重置密ma。步骤如下:

1、查看未来20天内是否会有密ma过期

set lines 200
col username for a20
select USERNAME,to_char(EXPIRY_DATE,'yyyy-mm-dd hh24:mi:ss') expire_time,profile,account_status from dba_users a where   EXPIRY_DATEsysdate and account_status='OPEN';

2、查看过期用户

set lines 200
col profile for a20
col username for a20
select USERNAME,to_char(EXPIRY_DATE,'yyyy-mm-dd hh24:mi:ss'),profile,account_status  from dba_users where account_status='EXPIRED' or account_status='EXPIRED(GRACE)' order by EXPIRY_DATE ;

3、查看open状态用户的过期时间

set lines 200
col profile for a20
col username for a20
select USERNAME,to_char(EXPIRY_DATE,'yyyy-mm-dd hh24:mi:ss'),profile,account_status  from dba_users where account_status='OPEN' order by EXPIRY_DATE ;

4、查看所有用户状态

set lines 200
col profile for a20
col username for a20
select USERNAME,to_char(EXPIRY_DATE,'yyyy-mm-dd hh24:mi:ss'),profile,account_status  from dba_users order by EXPIRY_DATE ;

5、进行密ma重置

   修改profile设置

alter profile PROFILE_NAME limit
password_reuse_time unlimited
password_reuse_max unlimited;

   生成重置命令

select 'alter user '||du.username||' identified by values '||''''||u.password||''''||';' from dba_users du,user$ u
  where du.username=u.name and u.type#=1 
  and du.profile in('PROFILE_NAME') 
and du.username<>'XS$NULL' and du.expiry_date-sysdate<=30;

   修改profile设置

alter profile PROFILE_PRODUCT limit
  password_reuse_time 60
  password_reuse_max 5;
请使用浏览器的分享功能分享到微信等