Alter databases

You can modify standard databases using the Cypher command ALTER DATABASE.

Syntax

Command Syntax

ALTER DATABASE

ALTER DATABASE name [IF EXISTS]
{
SET ACCESS {READ ONLY | READ WRITE} |
SET TOPOLOGY n PRIMAR{Y|IES} [m SECONDAR{Y|IES}] |
SET OPTION option value |
SET DEFAULT LANGUAGE CYPHER {5|25}
}
[WAIT [n [SEC[OND[S]]]]|NOWAIT]
ALTER DATABASE name [IF EXISTS]
REMOVE OPTION option
[WAIT [n [SEC[OND[S]]]]|NOWAIT]

There can be multiple SET OPTION or REMOVE OPTION clauses for different option keys.

SET DEFAULT LANGUAGE CYPHER {5|25} is available from Neo4j 2025.06 onwards.

Alter database access mode

By default, a database has read-write access mode on creation. The database can be limited to read-only mode on creation using the configuration settings server.databases.default_to_read_only, server.databases.read_only, and server.database.writable. For details, see the section on Configuration parameters.

A database that was created with read-write access mode can be changed to read-only. To change it to read-only, you can use the ALTER DATABASE command with the sub-clause SET ACCESS READ ONLY. Subsequently, the database access mode can be switched back to read-write using the sub-clause SET ACCESS READ WRITE. Altering the database access mode is allowed at all times, whether a database is online or offline.

If conflicting modes are set by the ALTER DATABASE command and the configuration parameters, i.e. one says read-write and the other read-only, the database will be read-only and prevent write queries.

Modifying access mode is only available to standard databases and not composite databases.

Alter database access mode to read-only

To modify the database access mode, use the following command where actors is the database name:

ALTER DATABASE actors SET ACCESS READ ONLY

The database access mode can be seen in the access output column of the command SHOW DATABASES:

SHOW DATABASES yield name, access
Result
+----------------------------+
| name        | access       |
+----------------------------+
| "actors"    | "read-only"  |
| "movies"    | "read-write" |
| "neo4j"     | "read-write" |
| "system"    | "read-write" |
+----------------------------+

Alter database access using IF EXISTS

ALTER DATABASE commands are optionally idempotent, with the default behavior to fail with an error if the database does not exist. Appending IF EXISTS to the command ensures that no error is returned and nothing happens if the database does not exist.

ALTER DATABASE nonExisting IF EXISTS
SET ACCESS READ WRITE

Alter the default Cypher version of an existing database

You can change the default Cypher version of an existing database, including the system database, using the ALTER DATABASE command with the SET DEFAULT LANGUAGE clause. For example:

ALTER DATABASE movies SET DEFAULT LANGUAGE CYPHER 25

This command will change the default Cypher version of the database movies to Cypher 25.

To view the default Cypher version of each database in the DBMS, run the command SHOW DATABASES with the YIELD clause and specify the defaultLanguage column. For example:

Query
SHOW DATABASES YIELD name, defaultLanguage
Table 1. Result
name defaultLanguage

"actors"

"CYPHER 25"

"movies"

"CYPHER 25"

"neo4j"

"CYPHER 25"

"system"

"CYPHER 25"

Rows: 4

Setting the default language to CYPHER 25 ensures that all queries run on that database will use the version of Cypher 25 that the database is currently running (unless you prepend your queries with CYPHER 5, which overrides this default). For example, a Neo4j 2025.08 database with default language Cypher 25 will use Cypher 25 as it exists in Neo4j 2025.08, including any changes introduced in Neo4j 2025.06, 2025.07, and 2025.08.

Alter database topology

In a cluster environment, you can use the ALTER DATABASE command to change the number of servers hosting a database. For more information, see Managing databases in a cluster.

Alter database options

The ALTER DATABASE command can be used to set or remove specific options for a database.

Table 2. Available options
Key Value Description

txLogEnrichment

FULL|DIFF|OFF

Defines the level of enrichment applied to transaction logs for Change Data Capture (CDC) purposes. For details about enrichment mode, see Change Data Capture Manual → Modify a database’s CDC mode.

The ALTER DATABASE command cannot be used to modify the store format of a database. For details about how to change the store format of a database, see Changing the store format of existing databases.

Modify the options set for a database

ALTER DATABASE `movies`
SET OPTION txLogEnrichment 'FULL'

The database set options can be seen in the options output column of the command SHOW DATABASES.

SHOW DATABASES yield name, options
Table 3. Result
name options

"actors"

{}

"movies"

{txLogEnrichment: "FULL"}

"neo4j"

{}

"system"

{}

Rows: 4

Remove the options set for a database

ALTER DATABASE `movies`
REMOVE OPTION txLogEnrichment

The REMOVE OPTION clause removes the specified option from the database using the ALTER DATABASE command.

SHOW DATABASES YIELD name, options
Table 4. Result
name options

"actors"

{}

"movies"

{}

"neo4j"

{}

"system"

{}

Rows: 4