Skip to main content

CREATE DATABASE

Introduced or updated: v1.2.866

Create a database.

Syntax

CREATE [ OR REPLACE ] DATABASE [ IF NOT EXISTS ] <database_name>
[ OPTIONS (
DEFAULT_STORAGE_CONNECTION = '<connection_name>',
DEFAULT_STORAGE_PATH = '<path>'
) ]

Parameters

ParameterDescription
DEFAULT_STORAGE_CONNECTIONThe name of an existing connection (created via CREATE CONNECTION) to use as the default storage connection for tables in this database.
DEFAULT_STORAGE_PATHThe default storage path URI (e.g., s3://bucket/path/) for tables in this database. Must end with / and match the connection's storage type.
note
  • DEFAULT_STORAGE_CONNECTION and DEFAULT_STORAGE_PATH must be specified together. Specifying only one is an error.
  • When both options are set, Databend validates that the connection exists, the path URI is well-formed, and the storage location is accessible.

Access control requirements

PrivilegeObject TypeDescription
CREATE DATABASEGlobalCreates a database.

To create a database, the user performing the operation or the current_role must have the CREATE DATABASE privilege.

Examples

Creating a Basic Database

The following example creates a database named test:

CREATE DATABASE test;

Creating a Database with a Default Storage Connection

The following example creates a connection using an AWS IAM role and then creates a database that uses this connection as its default storage. Using an IAM role is more secure than access keys because it doesn't require storing credentials in Databend.

CREATE CONNECTION my_s3
STORAGE_TYPE = 's3'
ROLE_ARN = 'arn:aws:iam::987654321987:role/databend-test';

CREATE DATABASE analytics OPTIONS (
DEFAULT_STORAGE_CONNECTION = 'my_s3',
DEFAULT_STORAGE_PATH = 's3://mybucket/analytics/'
);
info

To use IAM roles with Databend Cloud, you need to set up a trust relationship between your AWS account and Databend Cloud. See Authenticate with AWS IAM Role for detailed instructions.

Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today