This method uses OMF (Oracle Managed Files):
1. Create directory on host:
mkdir -p /u02/oradata/cdbveg/pdbveg2
2. Set session parameter to enable OMF:
alter session set db_create_file_Dest='/u02/oradata/cdbveg/pdbveg2';
3. Create a pluggable database with a new and local PDBA:
create PLUGGABLE database PDBVEG2 admin user VEGARD identified by "MySecretPassword" roles=(DBA);
The statement above copies data files from the seed PDB to the target directory specified in step 2.
It will also grant the local role PDB_DBA to the new PDBA, Vegard.
4. Check the status of the newly created PDB:
select pdb_name,status,con_id from CDB_PDBS;
PDB_NAME | STATUS | CON_ID |
---|---|---|
PDBVEG1 | NORMAL | 3 |
PDB$SEED | NORMAL | 2 |
PDBVEG2 | NEW | 4 |
5. Open the pluggable database:
alter pluggable database pdbveg2 open;
6. Check status again:
select pdb_name,status,con_id from CDB_PDBS;
PDB_NAME | STATUS | CON_ID |
---|---|---|
PDBVEG1 | NORMAL | 3 |
PDB$SEED | NORMAL | 2 |
PDBVEG2 | NORMAL | 4 |
To drop a pluggable database, perform the following steps:
alter pluggable database PDB1 close; -- Unplug the database. If you try to drop it before unplugging it, Oracle report -- ORA-65179: cannot keep datafiles for a pluggable database that is not unplugged alter pluggable database PDB1 unplug into '/tmp/PDB1.xml'; drop pluggable database PDB1;If you want Oracle to remove the physical files from disk for you in the same operation, use the following syntax:
drop pluggable database PDB1 including datafiles;