Create a Pluggable Database (PDB)
Manually
To create a new pluggable database from the seed database, all we have
to do is tell Oracle where the file should be placed. We can do this using one
of two methods. The first method uses theFILE_NAME_CONVERT clause in the CREATE PLUGGABLE DATABASE statement.
CONN / AS SYSDBA
CREATE PLUGGABLE DATABASE pdb2 ADMIN USER pdb_adm
IDENTIFIED BY Password1
FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb1/pdbseed/','/u01/app/oracle/oradata/cdb1/pdb2/');
Alternatively, we can specify the PDB_FILE_NAME_CONVERT initialization
parameter before calling the command without using the FILE_NAME_CONVERT clause.
CONN / AS SYSDBA
ALTER SESSION SET
PDB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/cdb1/pdbseed/','/u01/app/oracle/oradata/cdb1/pdb3/';
CREATE PLUGGABLE DATABASE pdb3 ADMIN USER pdb_adm
IDENTIFIED BY Password1;
Every time there is a need to convert file locations, either of these
two methods will work. For the remainder of the article I will stick to using
the FILE_NAME_CONVERT method to cut down on the variations I have to display.
We can see the PDBs are present by querying the DBA_PDBS and V$PDBS views.
COLUMN pdb_name FORMAT A20
SELECT pdb_name, status
FROM
dba_pdbs
ORDER BY pdb_name;
PDB_NAME STATUS
-------------------- -------------
PDB$SEED NORMAL
PDB1 NORMAL
PDB2 NEW
PDB3 NEW
SQL>
SELECT name, open_mode
FROM v$pdbs
ORDER BY name;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 MOUNTED
PDB2 MOUNTED
PDB3 MOUNTED
SQL>
The PDBs are created with the status of 'NEW'. They must be opened in READ WRITE mode at least
once for the integration of the PDB into the CDB to be complete.
ALTER PLUGGABLE DATABASE pdb2 OPEN READ WRITE;
ALTER PLUGGABLE DATABASE pdb3 OPEN READ WRITE;
SELECT pdb_name, status
FROM
dba_pdbs
ORDER BY pdb_name;
PDB_NAME STATUS
-------------------- -------------
PDB$SEED NORMAL
PDB1 NORMAL
PDB2 NORMAL
PDB3 NORMAL
SQL>
SELECT name, open_mode
FROM v$pdbs
ORDER BY name;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 MOUNTED
PDB2 READ WRITE
PDB3 READ WRITE
SQL>
Note. Depending on
the syntax used, you may need to grant the PDB_DBA role to the local admin
users for the PDB.
No comments:
Post a Comment