Managing database aliases for standard databases
Database aliases can be created and managed using a set of Cypher administration commands executed against the system
database.
The required privileges are described in the The DBMS ALIAS MANAGEMENT privileges.
When connected to the DBMS over Bolt, administration commands are automatically routed to the system
database.
If a transaction modifies a database alias, other transactions concurrently executing against that alias may be aborted and rolled back for safety. This prevents issues such as a transaction executing against multiple target databases for the same alias. |
There are two kinds of database aliases - local and remote:
- Local database aliases
-
A local database alias can only target a database within the same DBMS. It can be used in all Cypher commands in place of the target database. Please note that the local database alias will be resolved while executing the command. Privileges are defined on the target database, and not the local database alias.
- Remote database aliases
-
A remote database alias may target a database from another Neo4j DBMS. It can be used for:
-
Connecting to a database of a remote Neo4j DBMS.
Remote database aliases require configuration to safely connect to the remote target, which is described in Connecting remote databases. It is not possible to impersonate a user on the remote database or to execute an administration command on the remote database via a remote database alias. -
USE
clauses. -
Defining the access privileges to the remote database.
-
Introduced in 2025.06 Setting a default Cypher version for queries to the remote database.
-
Starting with Neo4j 2025.06, a database or remote alias can be assigned a default Cypher version. However, local database aliases cannot be assigned a default Cypher version. They always get the Cypher version of their target database. |
When a query is run against a database alias, it will be redirected to the target database. The home database for users can be set to an alias, which will be resolved to the target database on use. Starting with Neo4j 2025.04, a database alias can also be set as the DBMS default database.
This page describes managing database aliases for standard databases. For aliases created as part of a composite database, see Managing database aliases in composite databases.
List database aliases
You can list all available database aliases using the SHOW ALIASES FOR DATABASE
command.
The command returns a table of all database aliases, whether they belong to a composite database or not.
If you need more details, you can append the command with YIELD *
.
The YIELD *
clause returns the full set of columns.
The required privileges are described in the The DBMS ALIAS MANAGEMENT privileges.
Column | Description | Type |
---|---|---|
|
The fully qualified name of the database alias. Default Output |
|
|
The name of the composite database this alias belongs to, or |
|
|
The name of the target database. Default Output This column is filtered according to the
If a user has not been granted the |
|
|
The location of the database, either |
|
|
Target location or |
|
|
User connecting to the remote database or |
|
|
The driver options for connection to the remote database or |
|
|
The default language for non-constituent remote database aliases or |
|
|
Any properties set on the database alias. |
|
Show all database aliases
To list all database aliases, use the SHOW ALIASES FOR DATABASE
command without any additional parameters.
This command returns all database aliases, including local and remote aliases, for all databases in the DBMS.
SHOW ALIASES FOR DATABASE
+--------------------------------------------------------------------------------------------+ | name | composite | database | location | url | user | +--------------------------------------------------------------------------------------------+ | "films" | NULL | "movies" | "local" | NULL | NULL | | "motion pictures" | NULL | "movies" | "local" | NULL | NULL | | "movie scripts" | NULL | "scripts" | "remote" | "neo4j+s://location:7687" | "alice" | +--------------------------------------------------------------------------------------------+
Show a specific database alias
To list just one database alias, the SHOW ALIASES
command takes an alias name:
SHOW ALIAS films FOR DATABASES
+---------------------------------------------------------+ | name | composite | database | location | url | user | +---------------------------------------------------------+ | "films" | NULL | "movies" | "local" | NULL | NULL | +---------------------------------------------------------+
Show detailed information about all database aliases
To see all columns for all database aliases, use the YIELD *
clause with the SHOW ALIASES FOR DATABASE
command:
SHOW ALIASES FOR DATABASE YIELD *
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | name | composite | database | location | url | user | driver | defaultLanguage | properties | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | "films" | NULL | "movies" | "local" | NULL | NULL | NULL | NULL | {} | | "motion pictures" | NULL | "movies" | "local" | NULL | NULL | NULL | NULL | {namecontainsspace: TRUE} | | "movie scripts" | NULL | "scripts" | "remote" | "neo4j+s://location:7687" | "alice" | {connection_pool_idle_test: PT2M, connection_pool_max_size: 10, logging_level: "INFO", ssl_enforced: TRUE, connection_pool_acquisition_timeout: PT1M, connection_timeout: PT5S, connection_max_lifetime: PT1H} | "CYPHER 25" | {} | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Show the number of database aliases
To see the number of database aliases, use a count()
aggregation with YIELD
and RETURN
.
SHOW ALIASES FOR DATABASE YIELD *
RETURN count(*) as count
+-------+ | count | +-------+ | 3 | +-------+
Filter and sort database aliases
You can filter and sort the results of the SHOW ALIASES FOR DATABASE
command using the YIELD
, ORDER BY
, and WHERE
clauses.
The YIELD
clause allows you to specify which columns to return, while the ORDER BY
clause sorts the results based on a specified column.
The WHERE
clause filters the results based on a condition.
SHOW ALIASES FOR DATABASE YIELD name, url, database
ORDER BY database
WHERE name CONTAINS 'e'
In this example:
-
The number of columns returned has been reduced with the
YIELD
clause. -
The order of the returned columns has been changed.
-
The results are ordered by the
database
column usingORDER BY
. -
The results have been filtered to only show database alias names containing
'e'
.
It is also possible to use SKIP
and LIMIT
to paginate the results.
+-----------------------------------------------------------+ | name | url | database | +-----------------------------------------------------------+ | "motion pictures" | NULL | "movies" | | "movie scripts" | "neo4j+s://location:7687" | "scripts" | +-----------------------------------------------------------+
Create database aliases
You can create both local and remote database aliases using the command CREATE ALIAS
.
For more information on local and remote database aliases as part of a composite database, see Create database aliases in composite databases.
The required privileges are described in the The DBMS ALIAS MANAGEMENT privileges.
Database alias names are subject to the rules specified in the Alias names section. |
Create database aliases for local databases
A local database alias targets a database within the same DBMS.
CREATE ALIAS `northwind` FOR DATABASE `northwind-graph-2021`
When you create a local database alias, it shows up in the aliases
column provided by the command SHOW DATABASES
and in the SHOW ALIASES FOR DATABASE
command.
SHOW DATABASE `northwind`
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | name | type | aliases | access | address | role | writer | requestedStatus | currentStatus | statusMessage | default | home | constituents | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | "northwind-graph-2021" | "standard" | ["northwind"] | "read-write" | "localhost:7687" | "primary" | TRUE | "online" | "online" | "" | FALSE | FALSE | [] | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
SHOW ALIAS `northwind` FOR DATABASE
+---------------------------------------------------------------------------+ | name | composite | database | location | url | user | +---------------------------------------------------------------------------+ | "northwind" | NULL | "northwind-graph-2021" | "local" | NULL | NULL | +---------------------------------------------------------------------------+
Use IF EXISTS
or OR REPLACE
when creating database aliases
The CREATE ALIAS
command is optionally idempotent, with the default behavior to fail with an error if the database alias already exists.
To work around this, you can append IF EXISTS
or OR REPLACE
to the command.
Both check for any remote or local database aliases.
-
Appending
IF NOT EXISTS
to the command. This ensures that no error is returned and nothing happens should the database alias already exist.QueryCREATE ALIAS `northwind` IF NOT EXISTS FOR DATABASE `northwind-graph-2021`
-
Appending
OR REPLACE
to the command. This means that if the database alias already exists, it will be replaced with the new one.QueryCREATE OR REPLACE ALIAS `northwind` FOR DATABASE `northwind-graph-2021`
This is equivalent to running
followed byDROP ALIAS `northwind` IF EXISTS FOR DATABASE
.CREATE ALIAS `northwind` FOR DATABASE `northwind-graph-2021
`
The |
Set properties for local database aliases
You can set properties for local database aliases using the PROPERTIES
clause of the CREATE ALIAS
command.
These properties can later be used in queries with the graph.propertiesByName()
function.
For example:
CREATE ALIAS `northwind-2022`
FOR DATABASE `northwind-graph-2022`
PROPERTIES { newestNorthwind: true, index: 3 }
To verify that the properties have been set, use the SHOW ALIASES FOR DATABASE
command with the YIELD
clause:
SHOW ALIAS `northwind-2022` FOR DATABASE YIELD name, properties
+------------------------------------------------------+ | name | properties | +------------------------------------------------------+ | "northwind-2022" | {index: 3, newestnorthwind: TRUE} | +------------------------------------------------------+
Create database aliases for remote databases
A database alias can target a remote database by providing an URL and the credentials of a user on the remote Neo4j DBMS. See Configuring remote database aliases for the necessary configurations.
Since remote database aliases target databases that are not in this DBMS, they do not fetch the default Cypher version from their target like the local database aliases.
Instead, they are assigned the version given by db.query.default_language
, which is set in the neo4j.conf
file.
Alternatively, you can specify the version in the CREATE ALIAS
or ALTER ALIAS
commands.
See Set a default Cypher version for remote database aliases and Alter the default Cypher version of a remote database alias for more information.
CREATE ALIAS `remote-northwind` FOR DATABASE `northwind-graph-2020`
AT "neo4j+s://location:7687"
USER alice
PASSWORD 'example_secret'
To view the remote database alias details, use the SHOW ALIASES FOR DATABASE
command:
SHOW ALIAS `remote-northwind`
FOR DATABASE
+----------------------------------------------------------------------------------------------------------+ | name | composite | database | location | url | user | +----------------------------------------------------------------------------------------------------------+ | "remote-northwind" | NULL | "northwind-graph-2020" | "remote" | "neo4j+s://location:7687" | "alice" | +----------------------------------------------------------------------------------------------------------+
You can also use IF EXISTS
or OR REPLACE
when creating remote database aliases.
It works the same way as described in the Use IF EXISTS
or OR REPLACE
when creating database aliases section.
Both check for any remote or local database aliases.
Create remote database aliases with driver settings
It is possible to override the default driver settings per database alias, which are used for connecting to the remote database.
This is the list of the allowed driver settings for remote database aliases:
-
ssl_enforced
(Default:true
) — SSL for remote database alias drivers is configured through the target URL scheme. Ifssl_enforced
is set to true, a secure URL scheme is enforced. It is be validated when the command is executed. -
connection_timeout
(For details, see dbms.routing.driver.connection.connect_timeout.) -
connection_max_lifetime
(For details, see dbms.routing.driver.connection.max_lifetime.) -
connection_pool_acquisition_timeout — for details, see dbms.routing.driver.connection.pool.acquisition_timeout.
-
connection_pool_idle_test — for details, see dbms.routing.driver.connection.pool.idle_test.
-
connection_pool_max_size
(For details, see dbms.routing.driver.connection.pool.max_size.) -
logging_level
(For details, see dbms.routing.driver.logging.level.)
You can set these driver settings when creating a remote database alias using the DRIVER
clause of the CREATE ALIAS
or ALTER ALIAS
commands.
For example, the following query creates a remote database alias using driver settings connection_timeout
and
connection_pool_max_size
for connecting to the remote database northwind-graph-2020
:
CREATE ALIAS `remote-with-driver-settings` FOR DATABASE `northwind-graph-2020`
AT "neo4j+s://location:7687"
USER alice
PASSWORD 'example_secret'
DRIVER {
connection_timeout: duration({minutes: 1}),
connection_pool_max_size: 10
}
To view the remote database alias details, including the driver settings, use the SHOW ALIASES FOR DATABASE
command with the YIELD *
clause:
SHOW ALIAS `remote-with-driver-settings` FOR DATABASE YIELD *
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | name | composite | database | location | url | user | driver | properties | +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | "remote-with-driver-settings" | NULL | "northwind-graph-2020" | "remote" | "neo4j+s://location:7687" | "alice" | {connection_pool_max_size: 10, connection_timeout: PT1M} | {} | +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Set a default Cypher version for remote database aliases
You can set a default Cypher version for remote database aliases using the DEFAULT LANGUAGE
clause of the CREATE ALIAS
or ALTER ALIAS
commands.
For example, the following query creates a remote database alias with the default language CYPHER 25
:
CREATE ALIAS `remote-with-default-language`
FOR DATABASE `northwind-graph-2020`
AT "neo4j+s://location:7687"
USER alice
PASSWORD 'example_secret'
DEFAULT LANGUAGE CYPHER 25
To view the remote database alias details, including the default language, use the SHOW ALIASES FOR DATABASE
command with the YIELD
clause:
SHOW ALIAS `remote-with-default-language` FOR DATABASE YIELD name, defaultLanguage
+--------------------------------------------------+ | name | defaultLanguage | +--------------------------------------------------+ | "remote-with-default-language" | "CYPHER 25" | +--------------------------------------------------+
Setting the default language to |
Set properties for remote database aliases
You can set properties for remote database aliases using the PROPERTIES
clause of the CREATE ALIAS
command.
These properties can then be used in queries with the graph.propertiesByName()
function.
CREATE ALIAS `remote-northwind-2021` FOR DATABASE `northwind-graph-2021` AT 'neo4j+s://location:7687'
USER alice PASSWORD 'password'
PROPERTIES { newestNorthwind: false, index: 6 }
To view the remote database alias properties, use the SHOW ALIASES FOR DATABASE
command with the YIELD
clause:
SHOW ALIAS `remote-northwind-2021` FOR DATABASE YIELD name, properties
+--------------------------------------------------------------+ | name | properties | +--------------------------------------------------------------+ | "remote-northwind-2021" | {index: 6, newestnorthwind: FALSE} | +--------------------------------------------------------------+
Alter database aliases
You can alter both local and remote database aliases using the ALTER ALIAS
command.
For all aliases, the command allows you to change the target database and properties of the database alias.
For remote aliases, the command also allows you to change the URL, user credentials, default language, or driver settings of the database alias.
The required privileges are described in the The DBMS ALIAS MANAGEMENT privileges.
Only the clauses used will be altered.
Local database aliases cannot be altered to remote aliases, or vice versa. |
Alter a local database alias target
You can alter a local database alias to target a different database using the SET DATABASE TARGET
clause of the ALTER ALIAS
command.
For example:
ALTER ALIAS `northwind`
SET DATABASE TARGET `northwind-graph-2021`
To verify that the local database alias has a new target database, you can use the SHOW DATABASE
command.
It shows up in the aliases
column for the target database.
.Query
SHOW DATABASE `northwind-graph-2021`
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | name | type | aliases | access | address | role | writer | requestedStatus | currentStatus | statusMessage | default | home | constituents | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | "northwind-graph-2021" | "standard" | ["northwind"] | "read-write" | "localhost:7687" | "primary" | TRUE | "online" | "online" | "" | FALSE | FALSE | [] | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Alter a remote database alias target
You can alter a remote database alias to target a different remote database using the SET DATABASE TARGET
clause of the ALTER ALIAS
command.
For example:
ALTER ALIAS `remote-northwind`
SET DATABASE TARGET `northwind-graph-2020` AT "neo4j+s://other-location:7687"
Alter a remote database alias credentials and driver settings
You can change the user credentials and driver settings of a remote database alias using the USER
, PASSWORD
, and DRIVER
subclauses of the SET DATABASE
clause of the ALTER ALIAS
command.
For example:
ALTER ALIAS `remote-with-driver-settings`
SET DATABASE
USER bob
PASSWORD 'new_example_secret'
DRIVER {
connection_timeout: duration({ minutes: 1}),
logging_level: 'debug'
}
All driver settings are replaced by the new ones.
In this case, by not repeating the driver setting |
Remove all custom driver settings from a remote database alias
You can remove all custom driver settings from a remote database alias by setting the DRIVER
clause to an empty map {}
.
ALTER ALIAS `movie scripts` SET DATABASE
DRIVER {}
Alter the default Cypher version of a remote database alias
You can alter the default Cypher version of a remote database alias using the SET DATABASE DEFAULT LANGUAGE
clause of the ALTER ALIAS
command.
For example:
ALTER ALIAS `remote-with-default-language`
SET DATABASE DEFAULT LANGUAGE CYPHER 5
Setting the default language to |
Alter properties of local and remote database aliases
You can alter the properties of a local or remote database alias using the SET DATABASE PROPERTIES
clause of the ALTER ALIAS
command.
For example:
ALTER ALIAS `motion pictures` SET DATABASE PROPERTIES { nameContainsSpace: true, moreInfo: 'no, not really' }
ALTER ALIAS `movie scripts` SET DATABASE PROPERTIES { nameContainsSpace: true }
The updated properties can then be used in queries with the graph.propertiesByName()
function.
Use IF EXISTS
when altering database aliases
The ALTER ALIAS
command is optionally idempotent, with the default behavior to fail with an error if the database alias does not exist.
Appending IF EXISTS
to the command ensures that no error is returned and nothing happens should the alias not exist.
ALTER ALIAS `no-alias` IF EXISTS SET DATABASE TARGET `northwind-graph-2021`
(no changes, no records)
Delete database aliases
You can delete both local and remote database aliases using the DROP ALIAS
command.
The required privileges are described in the The DBMS ALIAS MANAGEMENT privileges.
Delete local database aliases
You can delete a local database alias using the DROP ALIAS
command.
For example:
DROP ALIAS `northwind` FOR DATABASE
To verify that the local database alias has been deleted, you can use the SHOW DATABASES
command.
The deleted alias will no longer appear in the aliases
column.
SHOW DATABASE `northwind-graph-2021`
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | name | type | aliases | access | address | role | writer | requestedStatus | currentStatus | statusMessage | default | home | constituents | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | "northwind-graph-2021" | "standard" | [] | "read-write" | "localhost:7687" | "primary" | TRUE | "online" | "online" | "" | FALSE | FALSE | [] | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Delete remote database aliases
You can delete a remote database alias using the DROP ALIAS
command.
For example:
DROP ALIAS `remote-northwind` FOR DATABASE
To verify that the remote database alias has been deleted, you can use the SHOW ALIASES FOR DATABASE
command.
SHOW ALIASES `remote-northwind` FOR DATABASE
+-----------------------------------------------------+ | name | composite | database | location | url | user | +-----------------------------------------------------+ +-----------------------------------------------------+
Use IF EXISTS
when deleting database aliases
The DROP ALIAS
command is optionally idempotent, with the default behavior to fail with an error if the database alias does not exist.
Inserting IF EXISTS
after the alias name ensures that no error is returned and nothing happens should the alias not exist.
DROP ALIAS `northwind` IF EXISTS FOR DATABASE
(no changes, no records)