Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

This article will show how to create a Oracle database, known aswell as Oracle Instance, in command line with dbca 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.

Another way to create database is to use CREATE DATABASE sql statement as explained here.

Before starting, you need ...
... Oracle Grid Infrastructure installed (optional but recommanded, see here)
... ASM installed and confgured (only if ASM is used as db storage, see here)
... Oracle 11gR2 RDBMS installed (see here)

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. This is a xml file which can be edited, especially to add or remove database option.
Then we wil create a database named testdb on ASM storage with DATA and FRA diskgroups.

# Edit template
[oracle]$ vi $ORACLE_HOME/assistants/dbca/templates
    <DatabaseTemplate name="New Database" description="" version="11.2.0.0.0">
       <CommonAttributes>
          <option name="OMS" value="false"/>
          <option name="JSERVER" value="false"/>
          <option name="SPATIAL" value="false"/>
          <option name="IMEDIA" value="false"/>
          <option name="ORACLE_TEXT" value="true">
             <tablespace id="SYSAUX"/>
          </option>
          <option name="XDB_PROTOCOLS" value="true">
             <tablespace id="SYSAUX"/>
          </option>
          <option name="CWMLITE" value="false">
             <tablespace id="SYSAUX"/>
          </option>
          <option name="EM_REPOSITORY" value="true">
             <tablespace id="SYSAUX"/>
          </option>
          <option name="SAMPLE_SCHEMA" value="false"/>
          <option name="APEX" value="false"/>
          <option name="OWB" value="false"/>
          <option name="DV" value="false"/>
       </CommonAttributes>
    ...
# Execute dbca with ASM option
[oracle]$ dbca -silent -createDatabase \
-templateName New_Database.dbt \
-gdbName testdb -sid testdb \
-sysPassword ... -systemPassword ... \
-storageType ASM \
-diskGroupName DATA -recoveryGroupName FRA \
-recoveryAreaDestination FRA \
-databaseType MULTIPURPOSE \
-characterSet AL32UTF8 -nationalCharacterSet AL16UTF16 \
-totalMemory 4096 -automaticMemoryManagement true \
-redoLogFileSize 128 \
-listeners LISTENER -registerWithDirService false \
-emConfiguration NONE \
-initparams db_create_file_dest='+DATA' \
-initparams db_create_online_log_dest_1='+DATA' \
-initparams db_create_online_log_dest_2='+FRA' \
-initparams db_recovery_file_dest='+FRA' \
-initparams parallel_max_servers=8 \
-initparams processes=600

    Creating and starting Oracle instance
    1% complete
    2% complete
    3% complete
    8% complete
    Creating database files
    9% complete
    17% complete
    Creating data dictionary views
    20% complete
    22% complete
    25% complete
    26% complete
    27% complete
    28% complete
    29% complete
    30% complete
    31% complete
    32% complete
    33% complete
    38% complete
    41% complete
    43% complete
    44% complete
    46% complete
    Adding Oracle Text
    47% complete
    48% complete
    52% complete
    54% complete
    Adding Oracle XML DB
    58% complete
    59% complete
    60% complete
    61% complete
    62% complete
    63% complete
    71% complete
    72% complete
    Registering database with Oracle Restart
    76% complete
    Completing Database Creation
    79% complete
    81% complete
    84% complete
    92% complete
    100% complete

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.

dbca help

# DBCA help
[oracle]$ dbca -h
    dbca  [-silent | -progressOnly | -customCreate] {<command> <options> }  | { [<command> [options] ] -responseFile  <response file > } [-continueOnNonFatalErrors <true | false>]
    Please refer to the manual for details.
    You can enter one of the following command:

    Create a database by specifying the following parameters:
        -createDatabase
            -templateName <name of an existing  template>
            [-cloneTemplate]
            -gdbName <global database name>
            [-policyManaged | -adminManaged <Policy managed or Admin managed Database, default is Admin managed database>]
                [-createServerPool <To create ServerPool which will be used by the database to be created>]
                [-force <To create serverpool by force when adequate free servers are not available. This may affect already running database>]
                -serverPoolName <One serverPool Name in case of create server pool and comma separated list of serverPool name in case of use serverpool>
                -[cardinality <Specify cardinality for new serverPool to be created, default is the number of qualified nodes>]
            [-sid <database system identifier>]
            [-sysPassword <SYS user password>]
            [-systemPassword <SYSTEM user password>]
            [-emConfiguration <CENTRAL|LOCAL|ALL|NOBACKUP|NOEMAIL|NONE>
                -dbsnmpPassword <DBSNMP user password>
                -sysmanPassword <SYSMAN user password>
                [-hostUserName <Host user name for EM backup job>
                 -hostUserPassword <Host user password for EM backup job>
                 -backupSchedule <Daily backup schedule in the form of hh:mm>]
                [-smtpServer <Outgoing mail (SMTP) server for email notifications>
                 -emailAddress <Email address for email notifications>]
                [-centralAgent <Enterprise Manager central agent home>]]
            [-disableSecurityConfiguration <ALL|AUDIT|PASSWORD_PROFILE|NONE>
            [-datafileDestination <destination directory for all database files> |  -datafileNames <a text file containing database objects such as controlfiles, tablespaces, redo log files and spfile to their corresponding raw device file names mappings in name=value format.>]
            [-redoLogFileSize <size of each redo log file in megabytes>]
            [-recoveryAreaDestination <destination directory for all recovery files>]
            [-datafileJarLocation  <location of the data file jar, used only for clone database creation>]
            [-storageType < FS | ASM >
                [-asmsnmpPassword     <ASMSNMP password for ASM monitoring>]
                 -diskGroupName   <database area disk group name>
                 -recoveryGroupName       <recovery area disk group name>
            [-characterSet <character set for the database>]
            [-nationalCharacterSet  <national character set for the database>]
            [-registerWithDirService <true | false>
                -dirServiceUserName    <user name for directory service>
                -dirServicePassword    <password for directory service >
                -walletPassword    <password for database wallet >]
            [-listeners  <list of listeners to configure the database with>]
            [-variablesFile   <file name for the variable-value pair for variables in the template>]]
            [-variables  <comma seperated list of name=value pairs>]
            [-initParams <comma seperated list of name=value pairs>]
            [-memoryPercentage <percentage of physical memory for Oracle>]
            [-automaticMemoryManagement ]
            [-totalMemory <memory allocated for Oracle in MB>]
            [-databaseType <MULTIPURPOSE|DATA_WAREHOUSING|OLTP>]]

    Configure a database by specifying the following parameters:
        -configureDatabase
            -sourceDB    <source database sid>
            [-sysDBAUserName     <user name  with SYSDBA privileges>
             -sysDBAPassword     <password for sysDBAUserName user name>]
            [-registerWithDirService|-unregisterWithDirService|-regenerateDBPassword <true | false>
                -dirServiceUserName    <user name for directory service>
                -dirServicePassword    <password for directory service >
                -walletPassword    <password for database wallet >]
            [-disableSecurityConfiguration <ALL|AUDIT|PASSWORD_PROFILE|NONE>
            [-enableSecurityConfiguration <true|false>
            [-emConfiguration <CENTRAL|LOCAL|ALL|NOBACKUP|NOEMAIL|NONE>
                -dbsnmpPassword <DBSNMP user password>
                -symanPassword <SYSMAN user password>
                [-hostUserName <Host user name for EM backup job>
                 -hostUserPassword <Host user password for EM backup job>
                 -backupSchedule <Daily backup schedule in the form of hh:mm>]
                [-smtpServer <Outgoing mail (SMTP) server for email notifications>
                 -emailAddress <Email address for email notifications>]
                [-centralAgent <Enterprise Manager central agent home>]]


    Create a template from an existing database by specifying the following parameters:
        -createTemplateFromDB
            -sourceDB    <service in the form of <host>:<port>:<sid>>
            -templateName      <new template name>
            -sysDBAUserName     <user name  with SYSDBA privileges>
            -sysDBAPassword     <password for sysDBAUserName user name>
            [-maintainFileLocations <true | false>]


    Create a clone template from an existing database by specifying the following parameters:
        -createCloneTemplate
            -sourceSID    <source database sid>
            -templateName      <new template name>
            [-sysDBAUserName     <user name  with SYSDBA privileges>
             -sysDBAPassword     <password for sysDBAUserName user name>]
            [-maintainFileLocations <true | false>]
            [-datafileJarLocation       <directory to place the datafiles in a compressed format>]

    Generate scripts to create database by specifying the following parameters:
        -generateScripts
            -templateName <name of an existing  template>
            -gdbName <global database name>
            [-scriptDest       <destination for all the scriptfiles>]

    Delete a database by specifying the following parameters:
        -deleteDatabase
            -sourceDB    <source database sid>
            [-sysDBAUserName     <user name  with SYSDBA privileges>
             -sysDBAPassword     <password for sysDBAUserName user name>]
    Query for help by specifying the following options: -h | -help

Please leave comments and suggestions,
Michel.

Reference
Creating a Database with DBCA (docs.oracle.com)
Manual database 11g creation with sqlplus (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