j.key
j.key

Reputation: 21

How to change user which is connected in SQL Developer for Oracle 12c?

I created a user and granted it privileges but I cannot connect to the database as that user from SQL Developer.

When I enter the code in SQL*Plus it shows that it has connected as in the picture below

picture

However when I try the same thing in Oracle SQL Developer, it shows me SYS user.

enter image description here

How to fix this?

EDIT

picture

Upvotes: 1

Views: 29090

Answers (1)

Alex Poole
Alex Poole

Reputation: 191285

In your SQL Developer screen shot you're looking at the 'Other Users' section of the navigation panel on the left, under your existing connection as SYS.

You can temporarily change to another user in that SQL Worksheet by doing:

connect c##murat/<password>

and then if you run as a script the statements after that will be performed as that user - and it will disconnect and revert to SYS when the script finishes.

But I wouldn't recommend that, except maybe as part of a schema-build script where you might want to switch back and forth. Particularly when you're really connected SYS. It's too easy to accidentally run something as the wrong user.

Really you need to create a new connection. At the top of the 'Connections' panel, click the green plus symbol and find your current connection in the list. Change the connection name (important!), username and password, set the role to 'default', click 'Test' to verify, and then click 'Save'.

You will then have two connections, and you can choose which to connect to and open SQL Worksheets as. As you're hopefully aware, you should not do any normal work as SYS, so you'll rarely need to connect as that again. I'd suggest you make it obvious in the connection name which is which, and that will appear in unsaved worksheet titles; and maybe use the connection colour option to further highlight and give you some visual warning when you are connecting as SYS.

When you are connected as your new user, you will not see their name in the 'Other Users' list. You will see SYS though.

Upvotes: 6

Related Questions