CREATE DATABASE

CREATE DATABASE creates a new database.

Conceptual framework

Materialize mimics SQL standard’s namespace hierarchy, which is:

  • Databases (highest level)
  • Schemas
  • Tables, views, sources
  • Columns (lowest level)

Each layer in the hierarchy can contain elements directly beneath it. In this instance, databases can contain schemas.

For more information, see Namespaces.

Syntax

CREATE DATABASE IF NOT EXISTS database_name
Field Use
IF NOT EXISTS If specified, do not generate an error if a database of the same name already exists.

If not specified, throw an error if a database of the same name already exists. (Default)
database_name A name for the database.

Details

For details about databases, see Namespaces: Database details.

Examples

CREATE DATABASE IF NOT EXISTS my_db;
SHOW DATABASES;
materialize
my_db

Privileges

The privileges required to execute this statement are:

  • CREATEDB privileges on the system.
Back to top ↑