Oracle 12c default pluggable DB in sqlplus

417 Views Asked by At

I have a pluggable database in Oracle 12c named PDBORCL. After a server restart something changed in how to connect to it.

I created a user in that pluggable DB, for the example the user is PETER and the password is also PETER. Before the restart I used to be able to open a Command Prompt, run sqlplus, which would in turn ask for my username and then its password, and it would sign in. Now this does not work, it says invalid username/password. When I log in with SYS and check:

SELECT * FROM dba_users WHERE username = 'PETER';

I get no results.

However, if I sign in using the following from a command prompt, it works:

sqlplus PETER/PETER@PDBORCL

So, the DB is up and running, but it seems to be connecting by default to the wrong pluggable DB. I need to change it to the way it was before the restart, so that it connects by default to that specific pluggable DB.

How can I achieve this?

2

There are 2 best solutions below

0
On BEST ANSWER

I found the solution. Change or create the environment variable LOCAL (in Windows) to PDBORCL. I think I read in linux the variable is TWO_TASK. After changing it, the following works:

sqlplus PETER/PETER

Also, just calling sqlplus and waiting to be prompted for username and password works.

0
On

You have created a user in pluggableDB and this user is not visible beyond the pluggable DB hence the reason you dont see user PETER when running the above query as sys.. If you want to connect to your pluggable DB directly what you have done above is right else you to connect to sys and the use CONNECT command.