Suppose  you want to do some activity under another user, But you don’t know the password of that user. Then how you will do it?

There is a way you can do it.  See the below demo.

Suppose a user TEST1 wants to connect to TEST2 user and create a table and we don’t know the password of TEST2.

For this TEST1 user need one privilege i.e grant connect through

Conn / as sysdba
SQL >alter user TEST2 grant connect through TEST1;
 
User altered.
 
SQL >conn TEST1[TEST2]
Enter password:< Give password for TEST1>

SQL >show user
USER is "TEST2"
SQL >create table emp_test as select * from emp;

Table created.

SQL > conn / as sysdba
connected
SQL > select owner from dba_tables where table_name='EMP_TEST';

OWNER
------
TEST2

 

This method is usually helpful, when you want to drop/create a private db_link and you don’t know the password of that db_link owner.

Once activity is done, revoke the privilege as below.

SQL >conn / as sysdba
Connected.
SQL> alter user TEST2 revoke  connect through TEST1;
 
User altered.