5.3. Queries

This section provides examples of queries and Cypher commands that can be used to create and manage multiple active databases.

This section describes the following:

For detailed information on Cypher administrative commands, see Cypher Manual → Administration.

5.3.1. Show the status of a specific database

Example 5.1. SHOW DATABASE
neo4j@system> SHOW DATABASE neo4j;
+------------------------------+
| name    | status   | default |
+------------------------------+
| "neo4j" | "online" | TRUE    |
+------------------------------+

5.3.2. Show the status of all databases

Example 5.2. SHOW DATABASES
neo4j@system> SHOW DATABASES;
+-------------------------------+
| name     | status   | default |
+-------------------------------+
| "neo4j"  | "online" | TRUE    |
| "system" | "online" | FALSE   |
+-------------------------------+

Switching between online and offline states is achieved using the START DATABASE and STOP DATABASE commands.

5.3.3. Show the status of the default database

The config setting dbms.default_database defines which database is created and started by default when Neo4j starts. The default value of this setting is neo4j.

Example 5.3. SHOW DEFAULT DATABASE
neo4j@system> SHOW DEFAULT DATABASE;
+--------------------+
| name    | status   |
+--------------------+
| "neo4j" | "online" |
+--------------------+

You can change the default database by using dbms.default_database, and restarting the server.

In Community Edition, the default database is the only database available, other than the system database.

5.3.4. Create a database

Example 5.4. CREATE DATABASE
neo4j@system> CREATE DATABASE sales;
+--------------------+
| name    | status   |
+--------------------+
| "sales" | "online" |
+--------------------+

1 row available after 58 ms, consumed after another 0 ms
Added 1 nodes, Set 4 properties, Added 1 labels
neo4j@system> SHOW DATABASES;
+-------------------------------+
| name     | status   | default |
+-------------------------------+
| "neo4j"  | "online" | TRUE    |
| "system" | "online" | FALSE   |
| "sales"  | "online" | FALSE   |
+-------------------------------+

3 rows available after 6 ms, consumed after another 0 ms

5.3.5. Stop a database

Example 5.5. STOP DATABASE
neo4j@system> STOP DATABASE sales;
0 rows available after 18 ms, consumed after another 6 ms
neo4j@system> SHOW DATABASES;
+--------------------------------+
| name     | status    | default |
+--------------------------------+
| "neo4j"  | "online"  | TRUE    |
| "system" | "online"  | FALSE   |
| "sales"  | "offline" | FALSE   |
+--------------------------------+

3 rows available after 5 ms, consumed after another 1 ms
neo4j@system> :use sales
The database is not currently available to serve your request, refer to the database logs for more details. Retrying your request at a later time may succeed.
neo4j@sales[UNAVAILABLE]>

5.3.6. Start a database

Example 5.6. START DATABASE
neo4j@sales[UNAVAILABLE]> :use system
neo4j@system>
neo4j@system> START DATABASE sales;
0 rows available after 21 ms, consumed after another 1 ms
SHOW DATABASES;
+-------------------------------+
| name     | status   | default |
+-------------------------------+
| "neo4j"  | "online" | TRUE    |
| "system" | "online" | FALSE   |
| "sales"  | "online" | FALSE   |
+-------------------------------+

3 rows available after 5 ms, consumed after another 0 ms
neo4j@system> :use sales
neo4j@sales>

5.3.7. Drop, or remove a database

Example 5.7. DROP DATABASE
neo4j@sales> :use system
neo4j@system> DROP DATABASE sales;
0 rows available after 82 ms, consumed after another 1 ms
neo4j@system> SHOW DATABASES;
+-------------------------------+
| name     | status   | default |
+-------------------------------+
| "neo4j"  | "online" | TRUE    |
| "system" | "online" | FALSE   |
+-------------------------------+

2 rows available after 5 ms, consumed after another 1 ms