CREATE DATABASE

Creates a database.

Syntax

CREATE DATABASE [IF NOT EXISTS] <database_name> [<sync_options>] [PARTITIONS n]
[<create_specification>]
<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]..

Note

GCS is a preview feature in release 7.6.

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 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.

  • 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.

    See Replication and Durability Concepts for more information.

  • 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.

    See Replication and Durability Concepts for more information.

  • 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. SingleStore gives all databases a default charset of utf8.

  • Node Requirements for SingleStore Commands

  • The ceph_mode flag has been deprecated.

  • Refer to the Permission Matrix for the required permission.

Examples

CREATE DATABASE with Default Options

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

CREATE DATABASE IF NOT EXISTS test;

CREATE DATABASE Using Sync Durability and Sync Replication

The following example creates a local database that uses sync durability and sync replication. The latter is enabled by default.

CREATE DATABASE IF NOT EXISTS test WITH SYNC DURABILITY;

Last modified: August 14, 2024

Was this article helpful?

Verification instructions

Note: You must install cosign to verify the authenticity of the SingleStore file.

Use the following steps to verify the authenticity of singlestoredb-server, singlestoredb-toolbox, singlestoredb-studio, and singlestore-client SingleStore files that have been downloaded.

You may perform the following steps on any computer that can run cosign, such as the main deployment host of the cluster.

  1. (Optional) Run the following command to view the associated signature files.

    curl undefined
  2. Download the signature file from the SingleStore release server.

    • Option 1: Click the Download Signature button next to the SingleStore file.

    • Option 2: Copy and paste the following URL into the address bar of your browser and save the signature file.

    • Option 3: Run the following command to download the signature file.

      curl -O undefined
  3. After the signature file has been downloaded, run the following command to verify the authenticity of the SingleStore file.

    echo -n undefined |
    cosign verify-blob --certificate-oidc-issuer https://oidc.eks.us-east-1.amazonaws.com/id/CCDCDBA1379A5596AB5B2E46DCA385BC \
    --certificate-identity https://kubernetes.io/namespaces/freya-production/serviceaccounts/job-worker \
    --bundle undefined \
    --new-bundle-format -
    Verified OK