Skip to content

Instantly share code, notes, and snippets.

@ajin
Created November 15, 2015 22:24
Show Gist options
  • Save ajin/5f4b358dbafb8ad38f96 to your computer and use it in GitHub Desktop.
Save ajin/5f4b358dbafb8ad38f96 to your computer and use it in GitHub Desktop.
SQL statement to unlock and unexpire Oracle users
select 'alter user "'||username||'" account unlock;' || chr(10) ||
'alter user "'||username||'" identified by values ''temp'';' || chr(10) ||
'alter user "'||username||'" identified by values '''||extract(xmltype(dbms_metadata.get_xml('USER',username)),'//USER_T/PASSWORD/text()').getStringVal()||''';' old_password
from dba_users
where account_status != 'OPEN';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment