HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

how login other account by sysdba in oracle?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
oracleloginaccounthowsysdbaother

Problem

I forget hr's password, but I have sysdba role.

Can I use su hr like in linux.

I don't hope alter hr's password.

Solution

It is really easy to log in as another user, just use the proxy user feature that is available since 8i. Unfortunately it does not work with SYS, but works with any other user. Basically you can grant the privilege to users to connect as another user.

SQL> alter user system identified by Oracle123;

User altered.

SQL> alter user hr identified by password account unlock;

User altered.


So the password of SYSTEM is Oracle123, and the password of HR is password. Now allow SYSTEM to connect as HR:

SQL> alter user hr grant connect through system;

User altered.


Finally, connect with SYSTEM and its password, providing HR in the brackets:

SQL> connect system[hr]/Oracle123
Connected.
SQL> show user
USER is "HR"


You can use any user for this, except SYS:

SQL> alter user hr grant connect through sys;
alter user hr grant connect through sys
                                    *
ERROR at line 1:
ORA-28154: Proxy user may not act as client 'SYS'

Code Snippets

SQL> alter user system identified by Oracle123;

User altered.

SQL> alter user hr identified by password account unlock;

User altered.
SQL> alter user hr grant connect through system;

User altered.
SQL> connect system[hr]/Oracle123
Connected.
SQL> show user
USER is "HR"
SQL> alter user hr grant connect through sys;
alter user hr grant connect through sys
                                    *
ERROR at line 1:
ORA-28154: Proxy user may not act as client 'SYS'

Context

StackExchange Database Administrators Q#127628, answer score: 7

Revisions (0)

No revisions yet.