Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   SQL Statements >

CREATE DATABASE

Use the CREATE DATABASE statement to create a new database.

This statement is an extension to the ANSI/ISO standard for SQL.

Syntax

Read syntax diagramSkip visual syntax diagram>>-CREATE DATABASE--database--+-------------+------------------->
                              '-IN--dbspace-'
 
>--+-----------------------------+-----------------------------><
   '-WITH--+-+----------+--LOG-+-'
           | '-BUFFERED-'      |
           '-LOG MODE ANSI-----'
 
Element Description Restrictions Syntax
database Name that you declare here for the new database that you are creating Must be unique among names of databases of the database server Database Name
dbspace The dbspace to store the data for this database; default is the root dbspace Must already exist Identifier

Usage

This statement is an extension to ANSI-standard syntax. (The ANSI/ISO standard for the SQL language does not specify any syntax for construction of a database, the process by which a database comes into existence.)

The database that CREATE DATABASE specifies becomes the current database.

The database name that you declare must be unique within the database server environment in which you are working. The database server creates the system catalog tables that describe the structure of the new database.

When you create a database, you alone can access it. It remains inaccessible to other users until you, as DBA, grant database privileges. For information on how to grant database privileges, see GRANT.

If a previous CONNECT statement has established an explicit connection to a database, and that connection is still your current connection, you cannot use the CREATE DATABASE statement (nor any SQL statement that creates an implicit connection) until after you use DISCONNECT to close the explicit connection.

In ESQL/C, the CREATE DATABASE statement cannot appear in a multistatement PREPARE operation.

If you do not specify the dbspace, the database server creates the system catalog tables in the root dbspace. The following statement creates the vehicles database in the root dbspace:

CREATE DATABASE vehicles 

The following statement creates the vehicles database in the research dbspace:

CREATE DATABASE vehicles IN research 

In Extended Parallel Server, you can create a database in the dbspace of the primary coserver (coserver 1) only.

Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]