How to find admin user of pluggable database in Oracle 12c up

oracleoracle-12cusers

I'm creating a script and I need to know what is the admin user of pluggable database. I don't find nothing about it in documentation.

Other question is, what happen if I drop a admin user of the pluggable database? is there some problem?

Best Answer

CREATE PLUGGABLE DATABASE

ADMIN USER

Use this clause to create an administrative user who can be granted the privileges required to perform administrative tasks on the PDB. For admin_user_name, specify name of the user to be created. Use the IDENTIFIED BY clause to specify the password for admin_user_name. Oracle Database creates a local user in the PDB and grants the PDB_DBA local role to that user.

The admin user is just a local user with the PDB_DBA role. Example:

SQL> CREATE PLUGGABLE DATABASE mypdb ADMIN USER balazs IDENTIFIED BY Oracle123 FILE_NAME_CONVERT=('pdbseed','mypdb');

Pluggable database created.

SQL> alter pluggable database mypdb open;

Pluggable database altered.

SQL> select grantee from cdb_role_privs where con_id = (select con_id from cdb_pdbs where pdb_name = 'MYPDB') and granted_role = 'PDB_DBA';

GRANTEE
--------------------
BALAZS
SYS