V$CONTAINERS only shows CDB root

Viewed 257

I have created a common user c##user and it has been assigned the following permissions:

  GRANT CREATE SESSION TO c##user CONTAINER=ALL;
  GRANT SET CONTAINER TO c##user CONTAINER=ALL;
  GRANT SELECT ON V_\$DATABASE TO c##user CONTAINER=ALL;
  GRANT FLASHBACK ANY TABLE TO c##user CONTAINER=ALL;
  GRANT SELECT ANY TABLE TO c##user CONTAINER=ALL;
  GRANT SELECT_CATALOG_ROLE TO c##user CONTAINER=ALL;
  GRANT EXECUTE_CATALOG_ROLE TO c##user CONTAINER=ALL;
  GRANT SELECT ANY TRANSACTION TO c##user CONTAINER=ALL;
  GRANT SELECT ANY DICTIONARY TO c##user CONTAINER=ALL;
  GRANT LOGMINING TO c##user CONTAINER=ALL;
  GRANT CREATE TABLE TO c##user CONTAINER=ALL;
  GRANT ALTER ANY TABLE TO c##user CONTAINER=ALL;
  GRANT LOCK ANY TABLE TO c##user CONTAINER=ALL;
  GRANT CREATE SEQUENCE TO c##user CONTAINER=ALL;
  GRANT EXECUTE ON DBMS_LOGMNR TO c##user CONTAINER=ALL;
  GRANT EXECUTE ON DBMS_LOGMNR_D TO c##user CONTAINER=ALL;
  GRANT SELECT ON V_\$LOGMNR_LOGS TO c##user CONTAINER=ALL;
  GRANT SELECT ON V_\$LOGMNR_CONTENTS TO c##user CONTAINER=ALL;
  GRANT SELECT ON V_\$LOGFILE TO c##user CONTAINER=ALL;
  GRANT SELECT ON V_\$ARCHIVED_LOG TO c##user CONTAINER=ALL;
  GRANT SELECT ON V_\$ARCHIVE_DEST_STATUS TO c##user CONTAINER=ALL;

But yet when I connect with this user to the CDB$ROOT and run SELECT * FROM V$CONTAINERS the only row that is returned is the one for the CDB$ROOT but there is an ORCLPDB1 that is open and available. If I execute:

ALTER SESSION SET CONTAINER=ORCLPDB1;
SELECT * FROM V$CONTAINERS;

Then the query only returns information for ORCLPDB1 as the documentation says it should. But why when I am connected to the CDB root and I run the same query against V$CONTAINERS do I not see any PDBs?

It's my understaning that the common user should see ORCLPDB1 in the V$CONTAINERS view only when I am connected to the CDB$ROOT but that's not happening. Is there a permission problem here that I don't see?

UPDATE

It looks like the common user must be explicitly given access to container data using the following executed by an administrator for the V$CONTAINERS view to return results besides the current container.

ALTER USER c##user SET CONTAINER_DATA=(CDB$ROOT,ORCLPDB1) CONTAINER=CURRENT;

Is that the expected way to handle this?

1 Answers

Yes, this is expected behavior of the system.

As per Oracle documentation:

Extended data-linked Oracle-supplied data dictionary objects

This type of object stores data pertaining to the CDB root, as well as data pertaining to individual PDBs.

When this type of object is queried from the CDB root, only data pertaining to the CDB root is returned.

So v$container is an extended data objects as it contains data about both root as well as other PDBs and hence by default it will only show data about the root.

ALTER USER c##user SET CONTAINER_DATA=(CDB$ROOT,ORCLPDB1) CONTAINER=CURRENT;

Above alter will enable system to show data about ORCLPDB1 PDB as well and if you again alter it as below it will show data of ROOT only

ALTER USER c##user SET CONTAINER_DATA=(CDB$ROOT) CONTAINER=CURRENT;
Related