Creates a database in a Lindorm instance. Use the WITH clause to set data lifecycle attributes such as time to live (TTL) and cold storage boundaries.
Applicable engines and versions
| Engine | Supported versions |
|---|---|
| LindormTable | 2.2.16 and later |
| LindormTSDB | All versions |
LindormTable versions earlier than 2.2.16 support onlyCREATE SCHEMA [ IF NOT EXISTS ] schema_identifier. LindormTable 2.2.16 and later versions also support the equivalent syntaxCREATE SCHEMA [ IF NOT EXISTS ] schema_identifier.SCHEMAandDATABASEare equivalent. After you create a database, it is identified by theDATABASEkeyword.
Syntax
CREATE DATABASE [ IF NOT EXISTS ] database_identifier
[ WITH ( attribute_definition [, attribute_definition]* ) ]
attribute_definition ::= attr_identifier = attr_valSupported parameters
| Parameter | LindormTable | LindormTSDB |
|---|---|---|
| Database name (database_identifier) | Supported | Supported |
| Database attributes (attribute_definition) | Not supported | Supported |
Parameters
database_identifier
The database name must meet the following requirements:
Length: 4–16 characters
Allowed characters: letters, digits, hyphens (
-), and underscores (_)Reserved words not allowed as names:
lindorm,default,global
attribute_definition
Supported only by LindormTSDB. Use the WITH keyword to set one or more attributes.
| Attribute | Type | Mandatory | Default | Description |
|---|---|---|---|---|
cold_boundary | BIGINT | No | 0 (cold storage disabled) | Number of days after which data moves to cold storage. To use this attribute, first enable cold storage in the Lindorm console. If set alongside ttl, cold_boundary must be less than ttl. |
partition_interval | BIGINT | No | See note below | Number of days per data partition. Data and indexes within the same interval are stored together. |
ttl | BIGINT | No | 0 (data kept indefinitely) | Number of days before data is automatically deleted. If set alongside cold_boundary, ttl must be greater than cold_boundary. |
Default values for partition_interval by LindormTable version:
| LindormTable version | Default value |
|---|---|
| 3.4.19 and later | 30 |
| Earlier than 3.4.19 | 0 |
Examples
Create a database
CREATE DATABASE DB1;Run SHOW DATABASES; to confirm the database was created.
Create a database with data lifecycle attributes
Create a database where data moves to cold storage after 30 days and is deleted after 60 days:
CREATE DATABASE DB1 WITH (cold_boundary=30, ttl=60);To verify:
Run
SHOW DATABASES;to confirm the database was created.Run
DESCRIBE DATABASE DB1;to confirm the attribute values.