Create Database   «Prev  Next»

Lesson 2 Writing the CREATE DATABASE command
Objective The correct command to create a database in Oracle AI Database 26ai

Writing the CREATE DATABASE Command in Oracle AI Database 26ai

In real-world environments you will usually use Database Configuration Assistant (DBCA) or cloud automation to create Oracle databases. However, every architect and DBA should understand the CREATE DATABASE command itself, because it defines the physical and logical structure of a new database and explains what DBCA is doing behind the scenes.

There's one point worth being precise about before anything else: in Oracle AI Database 26ai, multitenant isn't a recommended architecture you're choosing among alternatives — it's the only one. Since Oracle Database 21c, every database is a Container Database (CDB); there is no non-CDB option anymore. Every CREATE DATABASE statement you run creates a CDB, and you then create one or more Pluggable Databases (PDBs) inside it with a separate statement. This lesson covers the correct form of the CREATE DATABASE command for a 26ai CDB, and the steps that surround it.

High-Level Steps to Create a Database

Oracle's own documentation lays this process out in considerably more granular detail than most courses cover — worth knowing if you ever need to troubleshoot a failed creation. Condensed to what matters for understanding the architecture:

  1. Choose an instance identifier (SID) and set the required environment variables.
  2. Create the initialization parameter file (SPFILE) with DB_NAME and related settings.
  3. Connect as SYSDBA and start the instance in NOMOUNT mode.
  4. Issue the CREATE DATABASE statement, including ENABLE PLUGGABLE DATABASE.
  5. Run catcdb.sql to build the CDB's data dictionary views and PL/SQL packages.
  6. Run Datapatch to bring the database to the correct patch level.
  7. Create and open one or more PDBs.
  8. Take a full backup.

Step 1 – Prepare Initialization Parameters

Before you can issue CREATE DATABASE, you must define basic initialization parameters such as:

In modern setups you store these in an SPFILE, not a legacy init.ora text file — PFILE-based configuration is still fully supported, it's just less convenient than SPFILE for making changes that persist across restarts. You then start the instance using those parameters.

Step 2 – Start the Instance in NOMOUNT Mode

Connect as SYSDBA and start the instance:


SQL> STARTUP NOMOUNT;

In NOMOUNT mode, Oracle has allocated memory and started background processes, but control files and data files do not yet exist. They are created when you run CREATE DATABASE.


Step 3 – Correct CREATE DATABASE Command for an Oracle AI Database 26ai CDB

The following example creates the COIN CDB with explicit files, so you can see exactly what gets created. It's adapted directly from Oracle's own multitenant creation reference, including the ENABLE PLUGGABLE DATABASE SEED FILE_NAME_CONVERT clause — a piece the previous version of this lesson left out entirely, even though it's what actually generates the PDB seed's file names.


CREATE DATABASE coin
   USER SYS IDENTIFIED BY StrongSysPassword1
   USER SYSTEM IDENTIFIED BY StrongSysPassword2
   LOGFILE
      GROUP 1 ('/u01/app/oracle/oradata/coin/redo01.log') SIZE 200M,
      GROUP 2 ('/u01/app/oracle/oradata/coin/redo02.log') SIZE 200M,
      GROUP 3 ('/u01/app/oracle/oradata/coin/redo03.log') SIZE 200M
   MAXLOGFILES 16
   MAXLOGMEMBERS 3
   MAXLOGHISTORY 1
   MAXDATAFILES 1024
   CHARACTER SET AL32UTF8
   NATIONAL CHARACTER SET AL16UTF16
   EXTENT MANAGEMENT LOCAL
   DATAFILE
      '/u01/app/oracle/oradata/coin/system01.dbf'
        SIZE 700M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
   SYSAUX DATAFILE
      '/u01/app/oracle/oradata/coin/sysaux01.dbf'
        SIZE 500M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
   DEFAULT TABLESPACE users
      DATAFILE '/u01/app/oracle/oradata/coin/users01.dbf'
        SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
   DEFAULT TEMPORARY TABLESPACE temp
      TEMPFILE '/u01/app/oracle/oradata/coin/temp01.dbf'
        SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
   UNDO TABLESPACE undotbs1
      DATAFILE '/u01/app/oracle/oradata/coin/undotbs01.dbf'
        SIZE 200M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
   ENABLE PLUGGABLE DATABASE
      SEED
      FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/coin/',
                           '/u01/app/oracle/oradata/pdbseed/')
      SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
      SYSAUX DATAFILES SIZE 100M
   LOCAL UNDO ON;

Oracle Cloud DBA

Key Clauses in the Command

Optional: Using Oracle Managed Files (OMF)

When DB_CREATE_FILE_DEST is set, Oracle can automatically create and manage file names and locations. This greatly simplifies the command and is common in Oracle Cloud and ASM-based deployments:


-- Example with OMF (files placed under DB_CREATE_FILE_DEST)
CREATE DATABASE coin
   USER SYS IDENTIFIED BY StrongSysPassword1
   USER SYSTEM IDENTIFIED BY StrongSysPassword2
   EXTENT MANAGEMENT LOCAL
   DEFAULT TABLESPACE users
   DEFAULT TEMPORARY TABLESPACE temp
   UNDO TABLESPACE undotbs1
   ENABLE PLUGGABLE DATABASE
      SEED
      SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
      SYSAUX DATAFILES SIZE 100M;

Because this example still customizes the PDB seed's SYSTEM and SYSAUX file sizes, the SEED keyword stays required even under OMF. Oracle chooses the actual file names and locations based on your DB_CREATE_FILE_DEST setting. Using OMF is often the best practice for new deployments, since it removes manual file naming as a source of error — though Oracle recommends reviewing the resulting configuration afterward, since the defaults it chooses may not fit every production environment.

Step 4 – Post-Creation Scripts

This is the step where older training material — including the previous version of this lesson — tends to fall out of date fastest. You'll still see references to running catalog.sql, catproc.sql, and pupbld.sql separately; that was accurate for a non-CDB, but a CDB in 26ai is built with a single consolidated script instead:


-- As SYS, connected to the CDB root
@?/rdbms/admin/catcdb.sql

catcdb.sql installs everything a CDB root requires — data dictionary views, synonyms, and PL/SQL packages — in one pass. It prompts interactively for the SYS and SYSTEM passwords and a temporary tablespace name, or you can set the CATCDB_SYS_PASSWD, CATCDB_SYSTEM_PASSWD, and CATCDB_TEMP environment variables beforehand to skip the prompts. It also asks for a log directory and log file name so you can review exactly what it did afterward.

Once catcdb.sql finishes, run Datapatch to bring the database up to the correct patch level — a step that has no equivalent in the older three-script sequence, and is easy to forget:


$ ./datapatch -verbose

Step 5 – Creating a Pluggable Database (PDB)

Once the CDB is open, you can create a PDB that applications will actually connect to. The following is a typical 26ai example using explicit file conversion:


-- Connect as SYSDBA to the root container
CONNECT SYS/StrongSysPassword1@coin AS SYSDBA;

CREATE PLUGGABLE DATABASE pdb_custom
   ADMIN USER pdbadmin IDENTIFIED BY StrongPDBAdminPwd1
   FILE_NAME_CONVERT = (
      '/u01/app/oracle/oradata/coin/pdbseed/',
      '/u01/app/oracle/oradata/coin/pdb_custom/'
   );

ALTER PLUGGABLE DATABASE pdb_custom OPEN;
ALTER PLUGGABLE DATABASE pdb_custom SAVE STATE;

If you use OMF and DB_CREATE_FILE_DEST, you can omit FILE_NAME_CONVERT and let Oracle generate the file layout automatically.

Parameters Commonly Used with CREATE DATABASE

The full CREATE DATABASE syntax supports many clauses. For an introductory architecture lesson, you should be able to name and classify the most important groups of parameters rather than memorize every option:

Parameter / Clause Category Notes
LOGFILE, GROUP, SIZE Redo Controls redo log groups, file names, and sizes.
DATAFILE, SYSAUX, UNDO Tablespaces Defines core tablespaces and their datafiles.
DEFAULT TABLESPACE, DEFAULT TEMPORARY TABLESPACE Defaults Controls where user objects and temporary segments are stored by default.
CHARACTER SET, NATIONAL CHARACTER SET Globalization Choose AL32UTF8 and AL16UTF16 for new deployments.
ENABLE PLUGGABLE DATABASE, SEED, LOCAL UNDO ON Architecture Creates the CDB root and PDB seed together; LOCAL UNDO ON is best practice, not the default.
MAXDATAFILES, MAXLOGFILES, MAXLOGMEMBERS, MAXLOGHISTORY Capacity Fixed at creation time — changing any of these later means recreating the control file.

In earlier releases you might see more emphasis on low-level initialization parameters stored in init.ora. In modern 26ai deployments you typically:

Best Practices for Students and New DBAs

Write CREATE DATABASE – Exercise

Now click the Exercise link to write the CREATE DATABASE statement for your COIN database, applying the multitenant and best-practice patterns introduced in this lesson.

Write Create Database - Exercise


SEMrush Software 2 SEMrush Banner 2