As your table organization needs grow over time and your projects become more complex, you can use namespaces to organize your tables in a way that reflects your business domains, teams, or environments. As described in the Namespaces and Catalog Model section, namespaces are LanceDB’s way of generalizing catalog specs, providing developers a clean way to manage hierarchical organization of tables in the catalog. The SDKs treat a namespace as a path and can use it for table resolution when you use LanceDB outside the root namespace.Documentation Index
Fetch the complete documentation index at: https://lancedb-bcbb4faf-docs-namespace-typescript-examples.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Table operations with namespace paths
Let’s imagine a scenario where your table management needs have evolved, and you now have the following multi-level structure to organize your tables outside the root namespace.["prod", "search"]) represents a level in the namespace hierarchy, and the table name is
specified when you create, open, list, or drop it.
The SDK methods expose the namespace path in the idiom of each language:
- Python: pass
namespace_path=["prod", "search"]to table operations. - Rust: call builder methods such as
.namespace(vec!["prod".to_string(), "search".to_string()]). - TypeScript: pass a
namespacePatharray, for exampleawait db.openTable("user", ["prod", "search"]).
Using namespaces is optional in LanceDB, and most basic use cases do not require to work with them.
An empty namespace (
[]), which is the default, means “root namespace”, and the data will be stored in
the data/ directory under the specified root path.Namespace management APIs
You can open/create/drop tables inside a namespace path (like["prod", "search"]).
All three SDKs expose namespace lifecycle operations directly.
In Python, use lancedb.connect_namespace(...) when calling namespace lifecycle methods such as
create_namespace, list_namespaces, describe_namespace, and drop_namespace.
In TypeScript, use lancedb.connectNamespace(...) and call createNamespace, listNamespaces,
describeNamespace, and dropNamespace on the returned Connection.
In Rust, use lancedb::connect_namespace(...) and call create_namespace, list_namespaces,
and drop_namespace.
Namespace creation and deletion have modes that control what happens when the target already exists,
doesn’t exist, or contains data:
- Create mode:
createfails if the namespace already exists,exist_okkeeps the existing namespace, andoverwritereplaces it. - Drop mode:
failreports an error when the namespace doesn’t exist, andskiptreats a missing namespace as a successful no-op. - Drop behavior:
restrictkeeps non-empty namespaces from being dropped, andcascadedrops child namespaces and tables first.
Namespaces in LanceDB Enterprise
In LanceDB Enterprise deployments, configure namespace-backed federated databases in a TOML file under your deployment’sconfig directory.
LanceDB Enterprise supports both directory-based (ns_impl = "dir") and REST-based (ns_impl = "rest") namespace implementations.
The example below shows how to configure a directory-based namespace implementation in LanceDB Enterprise.
"rest" with forwarding prefixed headers
for authentication and context propagation.
forward_header_prefixes = ["X-forward"], any incoming header starting with X-forward is forwarded to
http://<your_org>.internal.catalog.com. This is useful for auth propagation, for example sending
X-forward-authorization: Bearer xxxx.
For the LanceDB REST API itself, requests use x-api-key for API-key authentication. If your endpoint
serves more than one database, LanceDB can also use headers such as x-lancedb-database or
x-lancedb-database-prefix to route the request to the right database context.