I'm quite new to Oracle. I created a CDB like cdb1 and then a PDB within like pdb1. Now I can connect to my PDB using something like:
But can't I have two PDBs with the same name in different CDBs? If that happened,
sqlplus wouldn't know which PDB I wanted to connect to. Does the listener have some robust way to map the PDB passed in the connection to an actual PDB within a CDB on the machine where the listener is running?
EDIT: I found out that when I write
pdb1 in the
sqlplus connection identifier, that is actually not the name of the PDB, but the name of the service, which just happens to be the same as the name of the PDB.
As far as I understand, I can map the service name to PDB name using
select name, pdb from v$services;.
It seems to map services to CDBs I need to type
lsnrctl service. And then I get output like:
Service "pdb1" has 1 instance(s). Instance "cdb1", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER
So I guess the instance
cdb1 is referring to the CDB
cdb1? Or does it also just happen to have the same name?
Then again, surely the service stating that it has 1 instance, means it could have 2 instances and these could point to separate CDBs, which brings me back to my original question of how to differentiate different PDBs with the same name.