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.
- You must be authenticated as a root user to use the
DEFINE NAMESPACE @name
Below shows how you can create a namespace using the
DEFINE NAMESPACE statement.
-- Namepace for Abcum Ltd. DEFINE NAMESPACE abcum;