NAMESPACE USE
Switches the current session to a namespace.
Syntax
Section titled “Syntax”NAMESPACE USE <namespace>Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
namespace | string | Yes | Dot-separated hierarchical path for the namespace (e.g. production.). |
Return Value
Section titled “Return Value”Simple string: OK on success.
Behavior
Section titled “Behavior”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.
Errors
Section titled “Errors”| Error Code | Description |
|---|---|
NOSUCHNAMESPACE | The namespace does not exist. |
NAMESPACEBEINGREMOVED | The namespace (or one of its ancestors) was previously removed via NAMESPACE REMOVE but has not yet been purged via NAMESPACE PURGE. |
ERR | The namespace path contains the reserved __internal__ leaf. |
Examples
Section titled “Examples”Switch to a namespace:
> NAMESPACE CREATE production.usersOK
> NAMESPACE USE production.usersOKNon-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 useNamespace being removed:
> NAMESPACE CREATE staging.ordersOK
> NAMESPACE REMOVE staging.ordersOK
> NAMESPACE USE staging.orders(error) NAMESPACEBEINGREMOVED Namespace 'staging.orders' is being removed