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).

Integer: 1 if the namespace exists, 0 if it does not.

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 1. A namespace pending removal is not considered to exist.

The __internal__ reserved name is rejected at parse time.

Error CodeDescription
NAMESPACEBEINGREMOVEDThe namespace was previously removed via NAMESPACE REMOVE but has not yet been purged via NAMESPACE PURGE.
ERRThe namespace path contains the reserved __internal__ leaf.

Namespace exists:

> NAMESPACE CREATE production.users
OK
> NAMESPACE EXISTS production.users
(integer) 1

Namespace does not exist:

> NAMESPACE EXISTS production.orders
(integer) 0

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