Sunday, March 15, 2015

Oops ... drop pdb via root container and reinstall via DBCA

My next test/example went slightly astray, as I didn't have a valid backup for PDB1 (oops!):

[oracle@ora12c66 CDBORCL]$ rm /u01/oradata/cdborcl/pdb1/SAMPLE_SCHEMA_users01.dbf

So I initially offline the datafile and was able to open the database:

SQL> ALTER PLUGGABLE DATABASE pdb1 DATAFILE '/u01/oradata/cdborcl/pdb1/SAMPLE_SCHEMA_users01.dbf' OFFLINE;
Pluggable database altered.

SQL> ALTER PLUGGABLE DATABASE pdb1 open;
Pluggable database altered.

But then I thought lets close and drop the pluggable database (a small gotcha with the container)

SQL> ALTER PLUGGABLE DATABASE pdb1 close;
Pluggable database altered.

SQL> DROP PLUGGABLE DATABASE pdb1;
DROP PLUGGABLE DATABASE pdb1
*
ERROR at line 1:
ORA-01109: database not open

SQL> show con_name
CON_NAME
------------------------------
PDB1

SQL> conn / as sysdba
Connected.

SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT

SQL> DROP PLUGGABLE DATABASE pdb1;
Pluggable database dropped.

and installed a new PDB4 database via DBCA:

[oracle@ora12c66 CDBORCL]$ dbca -silent -createPluggableDatabase -sourceDB cdborcl  -pdbName pdb4 -createPDBFrom default  -pdbAdminUserName pdb4  -pdbAdminPassword qwe123 -createUserTableSpace true -sampleSchema true -TEMPLATENAME General_Purpose.dbc
Creating Pluggable Database
4% complete
12% complete
21% complete
38% complete
85% complete
Completing Pluggable Database Creation
100% complete
Look at the log file "/u01/cfgtoollogs/dbca/cdborcl/pdb4/cdborcl0.log" for further details.


No comments:

Post a Comment