CREATE DATABASE

Creates a database.

Syntax

CREATE DATABASE [IF NOT EXISTS] db_name [WITH {SYNC | ASYNC} REPLICATION] [PARTITIONS n]
    [create_specification] ...

create_specification:
    [DEFAULT] CHARACTER SET [=] charset_name


-- "schema" is an alias for "database"
CREATE SCHEMA [IF NOT EXISTS]...

Remarks

  • db_name is the name to assign to this new MemSQL database.
  • WITH {SYNC | ASYNC} REPLICATION controls whether replication in high availability will be done synchronously or asynchronously. The default mode is ASYNC (default mode can be changed using system variable replication_sync). Partitions replicated synchronously will ensure commits have reached all slaves before acknowledging the transaction to the user client. While providing stronger consistency guarantees, this can negatively impact write performance. For more information, see Managing High Availability.
  • 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 MemSQL for compatibility with MySQL, but it has no effect. MemSQL gives all databases a default charset of utf8.
  • This command must be run on the master aggregator node (see Node Requirements for MemSQL Commands).

Example

memsql> CREATE DATABASE IF NOT EXISTS test;
Query OK, 1 row affected (0.18 sec)
Was this article useful?