Create Container database (CDB) in silent mode

create cdb in silent mode

Oracle has introduced new Multitenant Option from Oracle 12cR1 and this option enables an Oracle database to function as a container database(CDB). A CDB includes zero, one, or many pluggable databases. A PDB is a portable collection of schemas, schema objects, and nonschema objects that appears to an Oracle Net client as a non-CDB. All Oracle databases before Oracle Database 12c were non-CDBs.

Refer here for more details on Oracle Multitenant option.

Refer here to create the database using DBCA in graphical mode.

In this article I will demonstrate an overview of creating a CDB and PDB database using DBCA in silent mode

1. Set the environmental variables

export ORACLE_SID=cdb2
export ORACLE_HOME=/u01/app/oracle/product/12.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin

2. Run dbca in silent mode

dbca -silent -createDatabase -templateName General_Purpose.dbc  -gdbname  cdb2 -sid cdb2 -characterSet AL32UTF8 -sysPassword Oracle_#123 -systemPassword Oracle_#123 -storageType FS -datafileDestination "/u01/app/oracle/oradata" -createAsContainerDatabase true -numberOfPDBs 1 -pdbName pdb1 -pdbAdminPassword Oracle_#123 -databaseType MULTIPURPOSE -memoryMgmtType auto_sga -memoryPercentage 20 -redoLogFileSize 50 -emConfiguration NONE

Output:

[oracle@cdb12c /]$ dbca -silent -createDatabase -templateName General_Purpose.dbc  -gdbname  cdb2 -sid cdb2 -characterSet AL32UTF8 -sysPassword Oracle_#123 -systemPassword Oracle_#123 -storageType FS -datafileDestination "/u01/app/oracle/oradata" -createAsContainerDatabase true -numberOfPDBs 1 -pdbName pdb1 -pdbAdminPassword Oracle_#123 -databaseType MULTIPURPOSE -memoryMgmtType auto_sga -memoryPercentage 20 -redoLogFileSize 50 -emConfiguration NONE
Copying database files
1% complete
13% complete
25% complete
Creating and starting Oracle instance
26% complete
30% complete
31% complete
35% complete
38% complete
39% complete
41% complete
Completing Database Creation
42% complete
43% complete
44% complete
46% complete
49% complete
50% complete
Creating Pluggable Databases
55% complete
75% complete
Executing Post Configuration Actions
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb2/cdb2.log" for further details.

3. Check the cdb and pdb status

[oracle@cdb12c oradata]$ . oraenv
ORACLE_SID = [cdbdev] ? cdb2
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@cdb12c oradata]$ sqlplus
Enter user-name: /as sysdba

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>
SQL> select name, open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
CDB2      READ WRITE
SQL>
SQL> select name, open_mode from v$pdbs;

NAME            OPEN_MODE
--------------- ----------
PDB$SEED        READ ONLY
PDB1            READ WRITE

SQL>
SQL> select name, pdb from v$services;

NAME            PDB
--------------- ---------------
SYS$BACKGROUND  CDB$ROOT
SYS$USERS       CDB$ROOT
cdb2            CDB$ROOT
pdb1            PDB1
cdb2XDB         CDB$ROOT

SQL>

Hope this helps…