Search This Blog

Monday, July 11, 2011

How to change an Oracle Database password temporarily.

Lets unlock the hr user and give it a password.
SQL> alter user hr identified by hr account unlock;

User altered.


Retrieve the hash based password value of the hr user.
SQL> select username, password from dba_users where username = 'HR';
select username, password fro dba_users where username = 'HR'


USERNAME                       PASSWORD                                         
------------------------------ ------------------------------                   
HR                             4C6D73C3E8B0F0DA                                 

Now alter the hr user password to something else.
SQL> alter user hr identified by mynewpassword;

User altered.

SQL> connect hr/mynewpassword;
Connected.

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID                               
------------------------------ ------- ----------                               
REGIONS                        TABLE                                            
COUNTRIES                      TABLE                                            
LOCATIONS                      TABLE                                            
DEPARTMENTS                    TABLE                                            
JOBS                           TABLE                                            
EMPLOYEES                      TABLE                                            
JOB_HISTORY                    TABLE                                            
EMP_DETAILS_VIEW               VIEW                                             

8 rows selected.

Now we will create a new table and insert a value in that.
SQL> create table test (id int);

Table created.

SQL> insert into test values (88);

1 row created.

SQL> commit;

Commit complete.

Connect back to the sys user.
SQL> connect / as sysdba
Connected.

Reset the password to it's original value using the hash value.
SQL> alter user hr identified by values '4C6D73C3E8B0F0DA';

User altered.

SQL> connect hr/hr;
Connected.

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID                               
------------------------------ ------- ----------                               
REGIONS                        TABLE                                            
COUNTRIES                      TABLE                                            
LOCATIONS                      TABLE                                            
DEPARTMENTS                    TABLE                                            
JOBS                           TABLE                                            
EMPLOYEES                      TABLE                                            
JOB_HISTORY                    TABLE                                            
EMP_DETAILS_VIEW               VIEW                                             
TEST                           TABLE                                            

9 rows selected.

SQL> select * from test;

        ID                                                                      
----------                                                                      
        88                                                                      

0 comments:

Post a Comment