|
| 1 | +[[cypher-version-configuration]] |
| 2 | += Configure the Cypher default version |
| 3 | +:page-role: new-2025.06 |
| 4 | +:description: How to configure the Cypher default version. |
| 5 | + |
| 6 | +You can specify the version of Cypher® in which you want to run your queries, choosing between Cypher 5 and Cypher 25. |
| 7 | +Cypher 5 is the default version for all newly created databases, however, if you want to take advantage of the new features in Cypher 25, you can set the default version to Cypher 25. |
| 8 | +For more information, see xref:introduction.adoc#_cypher_versions[Cypher® versions]. |
| 9 | + |
| 10 | +To specify the Cypher version, use one of the following options: |
| 11 | + |
| 12 | +Configure a default Cypher version for the whole DBMS:: |
| 13 | +The default language version for the whole DBMS can be configured in the _neo4j.conf_ file using the setting xref:configuration/configuration-settings.adoc#config_db.query.default_language[db.query.default_language] (default value: CYPHER_5). + |
| 14 | +Changing this setting in an existing DBMS *does not* affect existing databases. |
| 15 | +It only applies to newly created databases unless the version is specified as part of the `CREATE` or `ALTER` database commands. |
| 16 | + |
| 17 | +Configure a default Cypher version per database:: |
| 18 | +The default language for a specific database can be set using a Cypher database administration command with the `SET DEFAULT LANGUAGE` clause when creating the database or by altering the database after it has been created. |
| 19 | +This clause determines the default Cypher version for the specified database, overriding the version set in the configuration file. |
| 20 | +For example, `CREATE DATABASE mydb SET DEFAULT LANGUAGE CYPHER 25` or `ALTER DATABASE mydb SET DEFAULT LANGUAGE CYPHER 5`. |
| 21 | +For more details and examples, see xref:database-administration/syntax.adoc#administration-syntax-database-management[Database management command syntax] and the respective pages in the xref:database-administration/index.adoc[] section. + |
| 22 | +If not specified, the default language for the database is set to the default language of the DBMS. |
| 23 | +Setting the default language on creation only require the correct `CREATE` privilege. |
| 24 | +Modifying the default language for an existing standard database requires the `SET DATABASE DEFAULT LANGUAGE` privilege and for an existing composite database the `ALTER COMPOSITE DATABASE` privilege. |
| 25 | ++ |
| 26 | +[NOTE] |
| 27 | +==== |
| 28 | +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). |
| 29 | +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. |
| 30 | +
|
| 31 | +Setting the default language to `CYPHER 5` ensures that all queries run on that database will use the version of `Cypher 5` as it existed at the time of the Neo4j 2025.06 release (unless you prepend your queries with `CYPHER 25`, which overrides this default). |
| 32 | +Any changes introduced after the 2025.06 release will not affect the semantics of the query. |
| 33 | +==== |
| 34 | + |
| 35 | +Set the Cypher version on a per-query basis:: |
| 36 | +The default language for a specific query can be set by prepending the query with the `CYPHER 5` or `CYPHER 25` keyword. + |
| 37 | +For example, `CYPHER 25 MATCH (n) RETURN n` or `CYPHER 5 MATCH (n) RETURN n`. |
| 38 | +This setting determines the language for the specified query, overriding the default language set in the configuration file and the database. |
0 commit comments