PDB tests: Creating, switching, deleting
-----------------------
The concept of CDB and PDB presented in ORACLE12C
They can be understood separately as containers and Plug-ins (PDB inserts in CDB)
There is little difference between CDB management and traditional databases
--Confirm Current CDB
Sql> select name,cdb from V$database;
NAME CDB
--------- ---
ZARADB YES
--Querying the current PDB basic information
Col Pdb_name for A30
Select Pdb_id,pdb_name,dbid,status,creation_scn from Dba_pdbs;
Select Con_id,dbid,name,open_mode from V$pdbs;
pdb_id pdb_name DBID status CREATION_SCN
---------------------------------------------- -----------------------------
3 pdb1 3337485269 normal 1909544
2 pdb$seed 4072348290 normal 1720741
sql>
con_id DBID name open_mode
------------------------------------------------------------
2 4072348290 pdb$seed READ only
3 3337485269 pdb1 READ WRITE
--Creating a PDB
--1 Direct Creation
CREATE Pluggable DATABASE PDB2
ADMIN USER PDB2DBA identified by Anbaisheng
STORAGE (MAXSIZE 2G max_shared_temp_size 100M)
DEFAULT tablespace tbs_pdb2 datafile '/opt/oracle/oradata/zaradb/datafile/pdb2_001.dbf ' SIZE 25M autoextend on;
--2 with existing PDB for template creation
--The existing PDB must be created in read only mode, otherwise the error
--Create PDB2 with PDB1 as template
Drop pluggable database pdb2 including datafiles;
Alter pluggable database PDB1 close;
Alter pluggable database PDB1 open Read only;
Create pluggable Database Pdb2
From PDB1
File_name_convert = ('/opt/oracle/oradata/zaradb/e98beb85b1a80c56e0439a02a8c05841/datafile/', '/opt/oracle/ Oradata/zaradb/datafile/pdb2 ');
--Turn off PDB
Alter pluggable database PDB2 close;
Alter pluggable database all close;
Alter pluggable database PDB2 close immediate;
Alter pluggable database PDB2 open;
Alter pluggable database all open;
--Removing the PDB
--Similar to deleting a table space, you can cascade data files
Drop pluggable database pdb2;
Drop pluggable database pdb2 including datafiles;
--unplug
--unplug after the PDB can only mount cannot open
Alter pluggable database PDB2 unplug into '/tmp/pdb2.xml ';
Remove the PDB after--unplug, then add back to the PDB using the XML file
Drop pluggable database pdb2;
Create pluggable database pdb2 using '/tmp/pdb2.xml ' nocopy;