Create composite databases
Composite databases are managed using Cypher® administrative commands. Note that it is not possible to modify access options or database topologies for composite databases as these are inherited from the constituent databases. For information about modifying access options, see Alter database access mode. For information about about topologies for databases, see Create databases in a cluster.
Drivers and client applications connect to composite databases just like standard databases. For more information, see the manuals for the different Neo4j drivers and applications.
Create a composite database
Composite databases can be created using CREATE COMPOSITE DATABASE
.
Composite database names are subject to the same rules as standard databases. One difference is however that the deprecated syntax using dots without enclosing the name in backticks is not available. Both dots and dashes need to be enclosed within backticks when using composite databases.
Having dots ( |
CREATE COMPOSITE DATABASE inventory
When a composite database has been created, it shows up in the listing provided by the command SHOW DATABASES
.
SHOW DATABASES
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | name | type | aliases | access | address | role | writer | requestedStatus | currentStatus | statusMessage | default | home | constituents | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | "inventory" | "composite" | [] | "read-only" | "localhost:7687" | NULL | FALSE | "online" | "online" | "" | FALSE | FALSE | [] | | "library" | "composite" | [] | "read-only" | "localhost:7687" | NULL | FALSE | "online" | "online" | "" | FALSE | FALSE | ["library.sci-fi"] | | "neo4j" | "standard" | [] | "read-write" | "localhost:7687" | "primary" | TRUE | "online" | "online" | "" | TRUE | TRUE | [] | | "sci-fi" | "standard" | ["library.sci-fi"] | "read-write" | "localhost:7687" | "primary" | TRUE | "online" | "online" | "" | FALSE | FALSE | [] | | "system" | "system" | [] | "read-write" | "localhost:7687" | "primary" | TRUE | "online" | "online" | "" | FALSE | FALSE | [] | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
For a full description of the columns returned by this command, and how to sort the results by specific columns, see List databases.
To create database aliases in the composite database, give the composite database as a namespace for the alias. For information about creating aliases in composite databases, see Managing aliases in composite databases.
Create composite databases with IF NOT EXISTS
or OR REPLACE
The CREATE COMPOSITE 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 COMPOSITE DATABASE inventory IF NOT EXISTS
This will not create a new composite database, because a composite database with the name inventory
already exists.
Second, adding OR REPLACE
to the command will result in any existing database being deleted and a new one being created.
CREATE OR REPLACE COMPOSITE DATABASE inventory
This is equivalent to running DROP DATABASE inventory IF EXISTS
followed by CREATE COMPOSITE DATABASE inventory
.
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 |
Set a default Cypher version for a composite database
You can set the default Cypher version for a composite database when creating it. If not specified, the default language for the composite database is set to the default language of the DBMS. For example:
CREATE COMPOSITE DATABASE inventory DEFAULT LANGUAGE CYPHER 5
This command creates a composite database named inventory
with the default language set to Cypher 5.
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:
SHOW DATABASES YIELD name, defaultLanguage
name | defaultLanguage |
---|---|
|
|
|
|
|
|
|
|
|
|
Rows: 5 |
For more information about other options for configuring the Cypher version, see Configure the Cypher default version.
Setting the default language to |