CREATE DATABASE

Creates a database.

Syntax

Note

The following syntax block contains lines which are intentionally left blank.

CREATE DATABASE [IF NOT EXISTS] <database_name> [<sync_options>] [PARTITIONS n]
[<create_specification>]
[ON WORKSPACE <workspace_name>]
<sync_options>:
WITH {SYNC | ASYNC} DURABILITY
| WITH {SYNC | ASYNC} REPLICATION
| WITH SYNC DURABILITY SYNC REPLICATION | WITH ASYNC DURABILITY ASYNC REPLICATION
<create_specification>:
[DEFAULT] CHARACTER SET [=] charset_name
-- "schema" is an alias for "database"
CREATE SCHEMA [IF NOT EXISTS]..

Remarks

  • database_name is the name to assign to this new SingleStore database. Do not use the _XX suffix (such as test_database_01) while naming a SingleStore Helios database as it may cause a mismatch with the database partition ordinals (sharded databases on each leaf node).

  • Database names are case-sensitive. Databases named DB and db are not the same objects and will be treated as such when granting permissions to users.

  • CONFIG '{"verify_ssl":false|true}' allows you to connect to an unverified SSL certificate in S3 when using the option verify_ssl:false

  • SYNC REPLICATION is enabled by default thereby ensuring durability against all single-node failures. SYNC DURABILITY is enabled also by default but only for reference databases.

  • SingleStore recommends to leave the default settings for durability and replication when creating a database. If you specify SYNC DURABILITY with the CREATE DATABASE command you will get it on all the partitions as well. This will have a non-trivial performance impact since it has to wait for Amazon Elastic Block Store (EBS). If you specify ASYNC REPLICATION, it can result in occasional data loss.

  • WITH {SYNC | ASYNC} REPLICATION specifies whether high availability, redundancy-2 replication will be done synchronously or asynchronously. Synchronous replication from the master partitions will complete on all replicas before the commit of the transaction is acknowledged to the client application. If WITH {SYNC | ASYNC} REPLICATION is not specified, synchronous replication is used.

  • High availability, redundancy-2 replication will always be done synchronously. The WITH SYNC REPLICATION clause can be optionally specified, but specifying it has no effect on replication behavior.

  • WITH {SYNC | ASYNC} DURABILITY specifies whether in-memory database updates you make using DDL and DML commands are also saved to the log on disk synchronously or asynchronously. Synchronous updates to the log on disk will complete before the commit of the transaction is acknowledged to the client application. If WITH {SYNC | ASYNC} DURABILITY is not specified, async durability is used.

    Note

    SYNC DURABILITY cannot be disabled once a database is created.

  • This command causes implicit commits. Refer to COMMIT for more information.

  • You cannot specify WITH SYNC DURABILITY ASYNC REPLICATION.

  • PARTITIONS n allows you to set the total number of partitions that the data will be split into. By default this is controlled by the default_partitions_per_leaf variable. Note that n refers to the total number of partitions across all leaves.

  • The CREATE DATABASE ... DEFAULT CHARSET= syntax is accepted by SingleStore for compatibility with MySQL, but it has no effect. . Character set and collation defaults can be set during table creation. See CREATE TABLE for more information.

  • The CREATE DATABASE ... ON WORKSPACE <workspace_name>; syntax is used to create a read/write database within a workspace that has already been created. See Creating and Using Workspaces for more information.

  • The ceph_mode flag has been deprecated.

  • Refer to the Permission Matrix for the required permission.

Examples

The following example creates a local database that uses all of the default options.

CREATE DATABASE IF NOT EXISTS test;

The following example creates a database on an existing workspace.

CREATE DATABASE IF NOT EXISTS test1 ON WORKSPACE `test-wkspc-1`;

Last modified: March 8, 2024

Was this article helpful?