Skip to content

NAMESPACE USE

Switches the current session to a namespace.

NAMESPACE USE <namespace>
ParameterTypeRequiredDescription
namespacestringYesDot-separated hierarchical path for the namespace (e.g. production.users).

Simple string: OK on success.

The command checks whether the given namespace exists in the FoundationDB directory layer using an isolated one-off transaction. If the namespace exists and is not marked for removal, the session’s active namespace is updated to the given path. All subsequent commands in the session will operate in that namespace until changed again.

Every new session starts with the default namespace configured via default_namespace in the cluster configuration.

The __internal__ reserved name is rejected at parse time.

Error CodeDescription
NOSUCHNAMESPACEThe namespace does not exist.
NAMESPACEBEINGREMOVEDThe namespace (or one of its ancestors) was previously removed via NAMESPACE REMOVE but has not yet been purged via NAMESPACE PURGE.
ERRThe namespace path contains the reserved __internal__ leaf.

Switch to a namespace:

> NAMESPACE CREATE production.users
OK
> NAMESPACE USE production.users
OK

Non-existent namespace:

> NAMESPACE USE non.existing.namespace
(error) NOSUCHNAMESPACE No such namespace: 'non.existing.namespace'

Reserved name:

> NAMESPACE USE name.__internal__
(error) ERR Namespace 'name.__internal__' is reserved for internal use

Namespace being removed:

> NAMESPACE CREATE staging.orders
OK
> NAMESPACE REMOVE staging.orders
OK
> NAMESPACE USE staging.orders
(error) NAMESPACEBEINGREMOVED Namespace 'staging.orders' is being removed