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.
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 SyntaxDEFINE 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: {} }
DEFINE DATABASE
statement.To learn more about databases and how to use them in SurrealDB, refer to the DEFINE DATABASE
.