Skip to content

NAMESPACE EXISTS

Checks whether a namespace exists.

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

Boolean: true if the namespace exists, false if it does not.

RESP2 has no boolean type. On a RESP2 connection you get the integer 1 for true and 0 for false. See Protocol Versions.

The command checks the FoundationDB directory layer for the given namespace path. It uses an isolated one-off transaction.

If the directory entry exists but the namespace is marked for removal (NAMESPACE REMOVE), the command raises a NAMESPACEBEINGREMOVED error rather than returning true. A namespace pending removal is not considered to exist.

The __internal__ reserved name is rejected at parse time.

Argument errors:

Error CodeError messageCause
ERRNamespace '<path>' is reserved for internal useThe namespace path contains the reserved __internal__ name.

Namespace errors:

Error CodeError messageCause
NAMESPACEBEINGREMOVEDNamespace '<path>' is being removed-

Namespace exists:

> NAMESPACE CREATE production.users
OK
> NAMESPACE EXISTS production.users
(true)

Namespace does not exist:

> NAMESPACE EXISTS production.orders
(false)

Reserved name:

> NAMESPACE EXISTS 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 EXISTS staging.orders
(error) NAMESPACEBEINGREMOVED Namespace 'staging.orders' is being removed