title: "CREATE DATABASE"
description: "CREATE DATABASE
creates a new database."
menu:
main:
parent: 'commands'
CREATE DATABASE
creates a new database.
Materialize mimics SQL standard's namespace hierarchy, which is:
Each layer in the hierarchy can contain elements directly beneath it. In this instance, databases can contain schemas.
For more information, see Namespaces.
{{< diagram "create-database.svg" >}}
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. |
For details about databases, see Namespaces: Database details.
CREATE DATABASE IF NOT EXISTS my_db;
SHOW DATABASES;
materialize
my_db
The privileges required to execute this statement are:
{{< include-md file="shared-content/sql-command-privileges/create-database.md"
}}