CREATE DATABASE

Syntax

CREATE DATABASE database_name [KEY encryption_key] [ENCODING encoding_value] [PAGESIZE pagesize_value] [IF NOT EXISTS]

Privileges

CREATE_DATABASE

Description

The CREATE DATABASE command physically creates a new SQLite database using the name specified in the database_name parameter. OK is returned if another database with the same name exists, and the clause IF NOT EXISTS is specified. Otherwise, the correct error is generated.

You can supply additional optional parameters to the command:

  • The KEY parameter creates a new AES-256 encrypted database with the encryption key specified in encryption_key.
  • The ENCODING parameter can specify the encoding of the newly created database (default is UTF-8). Allowed values are UTF-8, UTF-16, UTF-16le or UTF-16be. Once an encoding is set for a database, it cannot be changed.
  • The PAGESIZE parameter specifies the page size of the newly created database (at the time of writing, the default value is 4096). The page size must be a power of two between 512 and 65536 inclusive.

Return

OK string or error value (see SCSP protocol).

Example

> CREATE DATABASE test.sqlite
OK

> USE DATABASE test.sqlite
OK