Categories: SQL Complex Queries

How to recover the expired user in Oracle?

In my previous articles i have given idea about the different questions related to oracle. In this article i would like to throw light on most important interview question – How to recover the expired user in Oracle?Think of the situation where you have an expired oracle database account and we have to recover that account on urgent basis.

Real life situation :

Sometimes DBA dont know about the situation of production users and by mistake they used expired account for production application environment and assign that to particular user. We do not have any documented resolution for these kind of situations but we could deal with the situation and follow the following steps :

Step 1 : To create the specific user to implement the scenario

Create User Amit Identified by “Amiet@123456”;

Step 2 : Check the status of the user using following query,

SELECT username, account_status, expiry_date
 FROM dba_users
 WHERE username = ‘Amit’;

USERNAME                       ACCOUNT_STATUS                   EXPIRY_DATE
—————————— ——————————– ———
Amit OPEN                             12-AUG-20

Step 3 : We require to Expire the User using following command

ALTER USER Amit PASSWORD EXPIRE;

Now the account of Amit is Expired. We require to check the status of the account,

SELECT username, account_status, expiry_date
 FROM dba_users
 WHERE username = ‘Amit’;

USERNAME                       ACCOUNT_STATUS                   EXPIRY_DATE
—————————— ——————————– ———
Amit EXPIRED 12-AUG-20

If you can check the account_status it is showing as Expired.

The above scenario will explain about how do we expire the user password and account.

Resolution of this scenario :

Step 1 : We require to fetch the current password of the user Amit as first step. You need to log in with the DBA privilleges,

SELECT username, account_status, expiry_date
 FROM dba_users
 WHERE username = ‘AMIT’; 

You will get the status of the user using above query.

Query to get password in encrypted format :

SELECT DBMS_METADATA.get_ddl (‘USER’, ‘AMIT’) as “User_Info”
FROM DUAL;

You will get the output as below :

User_Info
——————————————————————————–
CREATE USER “Amit” IDENTIFIED BY VALUES ‘S:1256778ASDESADDADDFFFDFDFSFT24FFFASSDFFFBB2;B9C89A643D04449E’
TEMPORARY TABLESPACE “TEMP”
PASSWORD EXPIRE

Step 2 : You will get password in encrypted format and following will be the password :

S:1256778ASDESADDADDFFFDFDFSFT24FFFASSDFFFBB2;B9C89A643D04449E

Step 3 : Alter the specified user

ALTER USER “AMIT”
IDENTIFIED BY VALUES ‘S:1256778ASDESADDADDFFFDFDFSFT24FFFASSDFFFBB2;B9C89A643D04449E‘;

User altered.

Now check the status of the user which will show OPEN.

Step 4 : Other Query to alter the user

                                                      
select name, password from user$ where name=’AMIT’;

NAME                           PASSWORD
—————————— ——————————
AMIT B9C89A643D04449E

alter user AMIT identified by values ‘ B9C89A643D04449E‘;

User altered.

You may test the user status again and it will be now open. So if these kind of situation occurs you may just alter the user and update it to current password in oracle. I hope you understand the answer of the question –How to recover the expired user in Oracle?

Amit S

Oracle Consultant with vast experience in Oracle BI and PL/SQL Development. Amiet is the admin head of this website who contributes by preparing tutorials and articles related to database technologies. He is responsible to manage the content and front-end of the website.

Share
Published by
Amit S

Recent Posts

The Essential Guide to Cryptocurrency Exchange Platform Development for Beginners and Beyond

Introduction Cryptocurrencies took the world by storm, setting up a new financial system and breaking…

5 months ago

Top 20 System Administrator Interview Questions and answers

In my previous article I have given Top 20 technical support interview questions with its…

8 months ago

Desktop Support Scenario Based Interview Questions

In my previous articles I have given 15 most asked desktop support interview questions with…

8 months ago

How Do Business Analysts Use SQL for Their Needs?

A business analyst is someone who is versed in processes of data analysis used for…

8 months ago

Top 15 Control-M Interview Questions with Answers

In my previous article I have already given top questions and answers for Desktop support…

8 months ago

Top 20 SQL Interview Questions for Production Support

In my previous article I have given unix production support interview questions and answers. In…

8 months ago