Multi-Database
A single server node hosts multiple named databases, each an isolated graph
with its own history. The --db flag points at a root directory; each
database lives in its own subdirectory underneath it. A database named
default always exists; system is reserved.
DDL
CREATE DATABASE sales
CREATE DATABASE IF NOT EXISTS sales
DROP DATABASE sales
DROP DATABASE IF EXISTS sales
SHOW DATABASES
- Database names are case-insensitive, may be backtick-quoted, and are kept filesystem-safe.
CREATE DATABASE/DROP DATABASEare replicated as Raft control commands, so the set of databases is consistent across the cluster.DROP DATABASEis idempotent and refuses to dropdefault.SHOW DATABASESis a local registry read (also surfaced over Bolt for the Neo4j Browser’s database dropdown).
Selecting a database
Per query, choose the target database in any of three ways:
USE sales
MATCH (o:Order) RETURN count(o)
- A leading
USE <db>prefix (alsoUSE <db> AS OF '<id>'for time travel). - The
dbfield in a REST request body or the BoltRUN/BEGINmetadata. - Otherwise the
defaultdatabase.
Selection is per-statement and never sticky across pooled Bolt connections.
Isolation
Databases are fully isolated — a write to default is invisible to sales and
vice versa; there is no cross-database query or traversal. Each database has its
own engram history, its own full-text indexes, and its own snapshots.
This isolation holds across failover: in a multi-node cluster, CREATE DATABASE
replicates to all nodes, writes route to the correct isolated graph, and both
databases survive a leader kill with post-failover writes still routing
correctly (this is covered by the failover test suite).