CREATE DATABASE
Create a database.
Syntax
CREATE [ OR REPLACE ] DATABASE [ IF NOT EXISTS ] <database_name>
[ OPTIONS (
DEFAULT_STORAGE_CONNECTION = '<connection_name>',
DEFAULT_STORAGE_PATH = '<path>'
) ]
Parameters
Access control requirements
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 TiDB Cloud Lake.
CREATE CONNECTION my_s3
STORAGE_TYPE = 's3'
ROLE_ARN = 'arn:aws:iam::987654321987:role/lake-test';
CREATE DATABASE analytics OPTIONS (
DEFAULT_STORAGE_CONNECTION = 'my_s3',
DEFAULT_STORAGE_PATH = 's3://mybucket/analytics/'
);