Initializes a new database with an optional user-defined collating sequence, creates the three initial table spaces, creates the system tables, and allocates the recovery log.
This command is not valid on a client.
Scope
In a multi-node environment, this command affects all nodes that are listed in the db2nodes.cfg file.
The node from which this command is issued becomes the catalog node for the new database.
Authorization
One of the following:
Required Connection
Instance. To create a database at another (remote) node, it is necessary to first attach to that node. A database connection is temporarily established by this command during processing.
Command Syntax
>>-CREATE----+-DATABASE-+--database-name------------------------> '-DB-------' >-----+------------------------------+------------------------->< +-AT NODE----------------------+ '-| Create Database options |--' Create Database options |---+----------------+---+------------------------+-------------> '-ON--+-path--+--' '-ALIAS--database-alias--' '-drive-' >-----+-----------------------------------------------+---------> '-USING CODESET--codeset--TERRITORY--territory--' >-----+-----------------------------------+---------------------> | .-SYSTEM--------. | '-COLLATE USING--+-COMPATIBILITY-+--' '-IDENTITY------' >-----+-------------------+-------------------------------------> '-NUMSEGS--numsegs--' >-----+--------------------------------+------------------------> '-DFT_EXTENT_SZ--dft_extentsize--' >-----+----------------------------------------+----------------> '-CATALOG TABLESPACE--| tblspace-defn |--' >-----+-------------------------------------+-------------------> '-USER TABLESPACE--| tblspace-defn |--' >-----+------------------------------------------+--------------> '-TEMPORARY TABLESPACE--| tblspace-defn |--' >-----+-------------------------+-------------------------------| '-WITH--"comment-string"--' tblspace-defn |---MANAGED BY--------------------------------------------------> .-,--------------------. V | >-----+-SYSTEM USING--(-----'container-string'--+---)-------------------------------------+> | .-,-----------------------------------------------------. | | V | | '-DATABASE USING--(------+-FILE---+---'container-string'---number-of-pages---+---)--' '-DEVICE-' >-----+------------------------------+--------------------------> '-EXTENTSIZE--number-of-pages--' >-----+--------------------------------+------------------------> '-PREFETCHSIZE--number-of-pages--' >-----+-----------------------------------+---------------------> '-OVERHEAD--number-of-milliseconds--' >-----+---------------------------------------+-----------------| '-TRANSFERRATE--number-of-milliseconds--'
Notes:
When defining containers for table spaces, $N can be used. $N will be replaced by the node number when the container is actually created. This is required if the user wants to specify containers in a multiple logical node database.
Command Parameters
Note: | If this parameter is used to recreate a database partition that was dropped (because it was damaged), the database at this node will be in the restore-pending state. After recreating the database partition, the database must immediately be restored on this node. |
Note: | For MPP systems, a database should not be created in an NFS-mounted directory. If a path is not specified, ensure that the dftdbpath database manager configuration parameter is not set to an NFS-mounted path (for example, on UNIX based systems, it should not specify the $HOME directory of the instance owner). The path specified for this command in an MPP system cannot be a relative path. |
For information about how the database collating sequence is used, see the SQL Reference.
/u/smith/smith/NODE0000/SQL00001/SQLT0000.0 /u/smith/smith/NODE0000/SQL00001/SQLT0000.1 /u/smith/smith/NODE0000/SQL00001/SQLT0000.2 /u/smith/smith/NODE0000/SQL00001/SQLT0000.3 /u/smith/smith/NODE0000/SQL00001/SQLT0000.4
In an MPP system, the catalog table space is only created on the catalog node (the node on which the CREATE DATABASE command is issued).
/u/smith/smith/NODE0000/SQL00001/SQLT0001.0 /u/smith/smith/NODE0000/SQL00001/SQLT0001.1 /u/smith/smith/NODE0000/SQL00001/SQLT0001.2 /u/smith/smith/NODE0000/SQL00001/SQLT0001.3 /u/smith/smith/NODE0000/SQL00001/SQLT0001.4
/u/smith/smith/NODE0000/SQL00001/SQLT0002.0 /u/smith/smith/NODE0000/SQL00001/SQLT0002.1 /u/smith/smith/NODE0000/SQL00001/SQLT0002.2 /u/smith/smith/NODE0000/SQL00001/SQLT0002.3 /u/smith/smith/NODE0000/SQL00001/SQLT0002.4
Usage Notes
CREATE DATABASE:
If the command was issued from a remote client, the client's system database directory is also updated with the database name and an alias.
Creates a system or a local database directory if neither exists. If specified, the comment and code set values are placed in both directories.
Note: | The utilities bind file list contains two bind files that cannot be bound
against down-level servers:
If db2ubind.lst is bound against a down-level server, warnings pertaining to these two files are returned, and can be disregarded. |
With dbadm authority, one can grant these privileges to (and revoke them from) other users or PUBLIC. If another administrator with sysadm or dbadm authority over the database revokes these privileges, the database creator nevertheless retains them.
In an MPP environment, the database manager creates a subdirectory, $DB2INSTANCE/NODExxxx, under the specified or default path on all nodes. The xxxx is the node number as defined in the db2nodes.cfg file (that is, node 0 becomes NODE0000). Subdirectories SQL00001 through SQLnnnnn will reside on this path. This ensures that the database objects associated with different nodes are stored in different directories (even if the subdirectory $DB2INSTANCE under the specified or default path is shared by all nodes).
If LDAP (Lightweight Directory Access Protocol) support is enabled on the current machine, the database will be automatically registered in the LDAP directory. If a database object of the same name already exists in the LDAP directory, the database is still created on the local machine, but a warning message is returned, indicating that there is a naming conflict. In this case, the user can manually catalog an LDAP database entry by using CATALOG LDAP DATABASE.
CREATE DATABASE will fail if the application is already connected to a database.
Use CATALOG DATABASE to define different alias names for the new database.
See Also