Search code examples
oracle-databaseoracle12cpluggable-database

Oracle 12c default pluggable DB in sqlplus


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?


Solution

  • 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.