Create, start, and stop databases
Neo4j supports the management of multiple databases within the same DBMS.
The metadata for these databases, including the associated security model, is maintained in a special database called the system
database.
All multi-database administrative commands must be run against the system
database.
These administrative commands are automatically routed to the system
database when connected to the DBMS over Bolt.
Administrative commands should not be used during a rolling upgrade. For more information, see Upgrade and Migration Guide → Upgrade a cluster. |
Create databases
You can create a database using the Cypher command CREATE DATABASE
.
Database names are subject to the rules specified in Database names section.
Having dots ( |
CREATE DATABASE customers
In Neo4j, the default store format for all new databases is aligned
.
If you want to change it, you can set a new value for the db.format
configuration in the neo4j.conf file.
See Store formats, for more details about available database store formats in Neo4j.
When a database has been created, it will show up in the listing provided by the command SHOW DATABASES
.
SHOW DATABASES YIELD name
+-------------+ | name | +-------------+ | "customers" | | "movies" | | "neo4j" | | "system" | +-------------+
Use IF NOT EXISTS
or OR REPLACE
when creating databases
The CREATE DATABASE
command is optionally idempotent, with the default behavior to fail with an error if the database already exists.
There are two ways to circumvent this behavior.
First, appending IF NOT EXISTS
to the command ensures that no error is returned and nothing happens should the database already exist.
CREATE DATABASE customers IF NOT EXISTS
Second, adding OR REPLACE
to the command results in any existing database being deleted and a new one being created.
CREATE OR REPLACE DATABASE customers
This is equivalent to running DROP DATABASE customers IF EXISTS
followed by CREATE DATABASE customers
.
The behavior of IF NOT EXISTS
and OR REPLACE
apply to both standard and composite databases (e.g. a composite database may replace a standard database or another composite database).
The |
Create database options
The CREATE DATABASE
command can have a map of options, e.g. OPTIONS {key: 'value'}
.
Key | Value | Description |
---|---|---|
|
|
Controls how the system handles existing data on disk when creating the database.
Currently this is only supported with |
|
ID of the cluster server |
Defines which server is used for seeding the data of the created database.
The server ID can be found in the |
|
URI to a backup or a dump from an existing database. |
Defines an identical seed from an external source which will be used to seed all servers. |
|
comma separated list of configuration values. |
Defines additional configuration specified by comma separated |
|
credentials |
Defines credentials that need to be passed into certain seed providers. |
|
|
Defines level of enrichment applied to transaction logs for Change Data Capture (CDC) purposes. For details about enrichment mode, see Change Data Capture Manual → Enable CDC on self-managed instances → Set the enrichment mode. |
The |
Start databases
Databases can be started using the command START DATABASE
.
START DATABASE customers
Both standard databases and composite databases can be started using this command. |
The status of the started database can be seen using the command SHOW DATABASE name
.
SHOW DATABASE customers YIELD name, requestedStatus, currentStatus
+-----------------------------------------------+ | name | requestedStatus | currentStatus | +-----------------------------------------------+ | "customers" | "online" | "online" | +-----------------------------------------------+
Stop databases
Databases can be stopped using the command STOP DATABASE
.
STOP DATABASE customers
Both standard databases and composite databases can be stopped using this command. |
The status of the stopped database can be seen using the command SHOW DATABASE name
.
SHOW DATABASE customers YIELD name, requestedStatus, currentStatus
+-----------------------------------------------+ | name | requestedStatus | currentStatus | +-----------------------------------------------+ | "customers" | "offline" | "offline" | +-----------------------------------------------+
Databases that are stopped with the |