SurrealDB Docs Logo

Enter a search query

Back to home
SurrealDB

SurrealDB

Database

A database within SurrealDB is contained within a namespace and is the primary unit where data is stored. Databases hold the actual data tables, indexes, and other data structures. Each database can have its own schema, settings, and permissions. The database is where you perform most of the data operations like CRUD (Create, Read, Update, Delete) operations, queries, and transactions.

Database structure

Databases are defined using the DEFINE DATABASE statement in SurrealQL. The statement requires a unique name for the database and can optionally include a comment for additional context. The following is the syntax for defining a database:

SurrealQL Syntax
DEFINE DATABASE [ OVERWRITE | IF NOT EXISTS ] @name [ COMMENT @string ]

You can also view the list of databases in your SurrealDB instance using the INFO statement. This statement provides information about the accesses, analyzers, functions, params, tables and users present in the current database instance.

{
	analyzers: {},
	functions: {},
	models: {},
	params: {},
	scopes: {},
	tables: {},
	tokens: {},
	users: {}
}

Requirements

  • You must be authenticated as a root, namespace, or database user before you can use the DEFINE DATABASE statement.

Learn more

To learn more about databases and how to use them in SurrealDB, refer to the DEFINE DATABASE.

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install