User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

This article will show how to create a Oracle 12c container database (CDB), with one pluggable database (PDB), in command line with dbca and silent option.

DBCA is for DataBase Configuration Assistant, this is a tool to create/delete Oracle databases.
It can be used as GUI or as command line.

Before starting, you need ...
... Oracle Grid Infrastructure installed (optional but recommanded)
    (check Silent install of Oracle Grid Infrastructure 12c)
... Oracle 12c RDBMS installed (check Silent install of Oracle 12c RDBMS)

Create Oracle database/instance

dbca needs a template file to create a database. These template can be found in $ORACLE_HOME/assistants/dbca/templates.
We will use here the default New_Database.dbt template file to create a container database named UXOCDB with one PDB on ASM storage with DATA and FRA diskgroups.
DBCA will install all database components when it is created as container database.

# Execute dbca with ASM option
[oracle]$ dbca -silent -createDatabase \
 -templateName New_Database.dbt      \
 -gdbName UXOCDB                     \
 -sid UXOCDB                         \
 -databaseType MULTIPURPOSE          \
 -createAsContainerDatabase true     \
   -numberofPDBs 1                   \
   -pdbName UXOPDB                   \
   -pdbAdminUserName pdba            \
   -pdbAdminPassword OraPdba_pw0     \
 -characterSet AL32UTF8              \
 -nationalCharacterSet AL16UTF16     \
 -memoryMgmtType AUTO_SGA            \
 -totalMemory 2048                   \
 -redoLogFileSize 384                \
 -enableArchive true                 \
 -storageType ASM                    \
   -datafileDestination +DATA        \
   -asmsnmpPassword OraAsmSnmp_pw0   \
 -recoveryAreaDestination +FRA       \
 -SysPassword OraSys_pw0             \
 -SystemPassword OraSystem_pw0       \
 -emConfiguration none               \
 -registerWithDirService false       \
 -sampleSchema  true                 \
 -initparams parallel_max_servers=8  \
   ,processes=384

    Registering database with Oracle Restart
    1% complete
    Creating and starting Oracle instance
    2% complete
    3% complete
    5% complete
    Creating database files
    8% complete
    Creating data dictionary views
    9% complete
    12% complete
    14% complete
    15% complete
    16% complete
    17% complete
    19% complete
    Adding Oracle JVM
    24% complete
    29% complete
    35% complete
    36% complete
    Adding Oracle Text
    37% complete
    38% complete
    40% complete
    Adding Oracle Multimedia
    41% complete
    50% complete
    Adding Oracle OLAP
    54% complete
    Adding Oracle Spatial
    55% complete
    61% complete
    Adding Oracle Application Express
    64% complete
    68% complete
    Creating cluster database views
    69% complete
    75% complete
    Completing Database Creation
    76% complete
    77% complete
    78% complete
    Creating Pluggable Databases
    81% complete
    89% complete
    Executing Post Configuration Actions
    100% complete
    Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/UXOCDB/UXOCDB1.log" for further details.

Others

Delete database

Be careful
This command may cause you data loss, so use it with caution.

You may want for some reason to delete a Oracle database. As oracle user, use the following command to properly delete database from host:

# Delete database
[oracle]$ dbca -silent -deleteDatabase -sourceDB testdb
    ASM with SID +ASM deleted successfully. Check /u01/app/grid/base/cfgtoollogs/asmca/asmca-150713AM012406.log for details.

Sample schemas install in 12c multitenant

When you create multitenant database with command line with -sampleSchema true parameter, sample schema doesn't seems to be installed.
You may need to do it manually on PDB :

# Connect to oracle instance
[oracle]$ sqlplus / as sysdba

    SQL*Plus: Release 12.2.0.1.0 Production on Sun Oct 1 

    Copyright (c) 1982, 2016, Oracle.  All rights reserved.


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

-- List pluggable database
SQL> show pdbs

        CON_ID CON_NAME    OPEN MODE  RESTRICTED
    ---------- ----------- ---------- ----------
             2 PDB$SEED    READ ONLY  NO
             3 UXOPDB      READ WRITE NO

-- Connect to a pluggable database 
SQL> alter session set container = uxopdb ;

    Session altered.

-- Create HR sample schema
SQL> @?/demo/schema/human_resources/hr_main.sql

    specify password for HR as parameter 1:
    Enter value for 1: OraHr_pw0

    specify default tablespeace for HR as parameter 2:
    Enter value for 2: users

    specify temporary tablespace for HR as parameter 3:
    Enter value for 3: temp

    specify log path as parameter 4:
    Enter value for 4: $ORACLE_HOME/demo/schema/log/


    PL/SQL procedure successfully completed.

dbca createDatabase help

# DBCA help
[oracle]$ dbca -createDatabase -help
        -createDatabase - Command to Create a database.
                -responseFile | (-gdbName,-templateName)
                -responseFile - <Fully qualified path for a response file>
                -gdbName <Global database name>
                -templateName <Name of an existing template in default location or the complete template path>
                [-characterSet <Character set for the database>]
                [-createAsContainerDatabase <true | false>]
                        [-numberOfPDBs <Number of pluggable databases to be created, default is 0>]
                        [-pdbAdminPassword <PDB Administrator user Password, required only while creating new PDB>]
                        [-pdbName <Pluggable database name>]
                        [-pdbOptions <A comma separated list of name:value pairs with database options to enable/disable. For example JSERVER:true,DV:false>]
                        [-pdbStorageMAXSizeInMB <value>]
                        [-pdbStorageMAXTempSizeInMB <value>]
                        [-useLocalUndoForPDBs <true | false>  Specify false to disable local undo tablespace for PDBs.]
                [-createListener <Create a new listener to register your database. Specify in format, LISTENER_NAME:PORT>]
                [-customScripts <A comma separated list of SQL scripts which needs to be run post db creation.The scripts are run in order they are listed>]
                [-databaseConfigType <SINGLE | RAC | RACONENODE>]
                        [-RACOneNodeServiceName <Service name for the service to be created for RAC One Node database. This option is mandatory when the databaseConfigType is RACONENODE>]
                [-databaseType <MULTIPURPOSE | DATA_WAREHOUSING | OLTP>]
                [-datafileDestination <Destination directory for all database files>]
                [-datafileJarLocation <Directory to place the datafiles in compressed format>]
                [-dbOptions <A comma separated list of name:value pairs with database options to enable/disable. For example JSERVER:true,DV:false>]
                [-dvConfiguration <true | false> Specify true to configure and enable database vault.]
                        -dvUserName <Specify database vault owner user name>
                        -dvUserPassword <Specify database vault owner password>
                        [-dvAccountManagerName <Specify separate database vault account manager>]
                        [-dvAccountManagerPassword <Specify database vault account manager password>]
                [-emConfiguration <DBEXPRESS | CENTRAL | BOTH | NONE>]
                        [-dbsnmpPassword <DBSNMP user password>]
                        [-emExpressPort <EM database express port number. Generally used during createDatabase>]
                        [-emPassword <EM Admin user password>]
                        [-emUser <EM Admin username to add or modify targets>]
                        [-omsHost <EM management server host name>]
                        [-omsPort <EM management server port number>]
                [-enableArchive <true | false> Specify true to enable archive>]
                        [-archiveLogDest <Specify archive log destinations separated by comma. If archive log destination is not specified, fast recovery area location will be used for archive log files.>]
                        [-archiveLogMode <AUTO|MANUAL , the default is Automatic archiving>]
                [-initParams <Comma separated list of name=value pairs>]
                        [-initParamsEscapeChar <Specify escape character for comma when a specific initParam has multiple values.If the escape character is not specified backslash is the default escape character>]
                [-listeners <A comma separated list of listeners that the database can be configured with>]
                [-memoryMgmtType <AUTO|AUTO_SGA|CUSTOM_SGA>]
                [-memoryPercentage | -totalMemory]
                [-memoryPercentage <Percentage of physical memory for oracle database>]
                [-totalMemory <Memory allocated for Oracle in MB>]
                [-nationalCharacterSet <National character set for the database>]
                [-nodelist <Node names separated by comma for the database>]
                [-olsConfiguration <true | false> Specify true to configure and enable Oracle Label Security.]
                        [-configureWithOID This flag configures Oracle Label Security with OID.]
                [-oracleHomeUserName <Specify Oracle Home User Name>]
                [-oracleHomeUserPassword <Specify Oracle Home User Password>]
                [-policyManaged | -adminManaged]
                [-policyManaged <Policy managed database, default option is Admin managed database>]
                        -serverPoolName <Specify the single server pool name in case of create server pool or comma separated list in case of existing server pools>
                        [-createServerPool <Create a new server pool, which will be used by the database>]
                                [-cardinality <Specify the cardinality of the new server pool that is to be created, default is the number of qualified nodes>]
                                [-force <To create server pool by force when adequate free servers are not available. This may affect the database which is already in running mode>]
                                [-pqCardinality <value>]
                                [-pqPoolName <value>]
                        [-pqPoolName <value>]
                [-adminManaged <Admin managed database, this is default option>]
                [-recoveryAreaDestination <Destination directory for all recovery files. Specify "NONE" for disabling Fast Recovery Area>]
                        [-recoveryAreaSize <Fast Recovery Area Size in MB>]
                [-redoLogFileSize <Size of each redo log file in MB>]
                [-registerWithDirService <true | false>]
                        -dirServiceUserName <User name for directory service>
                        [-databaseCN <Database common name>]
                        [-dirServicePassword <Password for directory service>]
                        [-walletPassword <Password for database wallet>]
                [-runCVUChecks <Specify "true" in order to run Cluster Verification Utility checks periodically for RAC databases.>]
                [-sampleSchema <true | false>]
                [-sid <Database system identifier>]
                [-storageType < FS | ASM >]
                        -datafileDestination <Destination directory for all database files>
                        [-asmsnmpPassword <ASMSNMP password for ASM monitoring>]
                [-sysPassword <SYS user password>]
                [-systemPassword <SYSTEM user password>]
                [-useOMF <true | false> Specify true to use Oracle-Managed Files.]
                [-useWalletForDBCredentials <true | false> Specify true to load database credentials from wallet]
                        -dbCredentialsWalletLocation <Path of the directory containing the wallet files>
                        [-dbCredentialsWalletPassword <Password to open wallet with auto login disabled>]
                [-variables <Comma separated list of name=value pairs>]
                [-variablesFile <File name of the variable-value pair for variables in the template>]

HTH,
Michel.

Reference
Creating and Configuring an Oracle Database (docs.oracle.com)
Silent database 11g creation with dbca (uxora.com)

Enjoyed this article? Please like it or share it.

Add comment

Please connect with one of social login below (or fill up name and email)

     


Security code
Refresh

Comments   

Soila
# Silent database 12c creation with dbcaSoila 2016-05-28 17:13
This actually answered my problem, thank you!
Reply | Reply with quote | Quote