Skip to main content
Version: 1.0.2

DEFINE NAMESPACE

DEFINE NAMESPACE statement

SurrealDB has a multi-tenancy model which allows you to scope databases to a namespace. There is no limit to the number of databases that can be in a namespace, nor is there a limit to the number of namespaces allowed. Only users with root access are authorized to create namespaces.

Let's say that you're using SurrealDB to create a multi-tenant SaaS application. You can guarantee that the data of each tenant will be kept separate from other tenants if you put each tenant's databases into separate namespaces. In other words, this will ensure that information will remain siloed so user will only have access the information in the namespace they are a member of.

Requirements

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

Statement syntax

SurrealQL Syntax
DEFINE NAMESPACE @name

Example usage

Below shows how you can create a namespace using the DEFINE NAMESPACE statement.

-- Namespace for Abcum Ltd.
DEFINE NAMESPACE abcum;