Skip to content

Database

Create Database

CREATE DATABASE [IF NOT EXISTS] {db_name | '[path/]db_name'} [db_option] ...

db_option:
    ENGINE = {MMAP | MEMORY}
  | LOCKMODE = {THREAD | PROCESS | NOLOCK}
LOCKMODE Lock used Description
THREAD [default] high-performance thread read-write lock For single process multiple threads access.
PROCESS file read-write lock For multiple processes multiple threads access.
NOLOCK no lock For test/diag purpose only.

Note

'[path]/db_name' is only valid for embedded database. db_options are default values for new created tables and you can use table_options to overwrite these default values.

Open Database

OPEN DATABASE {db_name | '[path/]db_name'} [dbg_option] ...

dbg_option:
    FLUSHMODE = {ASYNC | SYNC | NOSYNC}
  | LOCKMODE = {THREAD | PROCESS | NOLOCK}

Note

This command can only be used for embedded database. dbg_option is only valid for current session and only for debug purpose.

Close Database

CLOSE DATABASE [IF EXISTS] db_name

Note

This command can only be used for embedded database.

Drop Database

DROP DATABASE [IF EXISTS] db_name

Use Database

USE db_name

Show Databases

SHOW DATABASES [WHERE expr]
XDB> show DATABASES ;
+----------+--------+-----------+
| database | engine | data_path |
+----------+--------+-----------+
| system   |        |           |
| memory   |        |           |
+----------+--------+-----------+
2 rows in set (0.012 ms)

Comments