Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ First, appending `IF NOT EXISTS` to the command ensures that no error is returne
CREATE DATABASE customers IF NOT EXISTS
----

Second, adding `OR REPLACE` to the command deletes any existing database and creates a new one.
Second, adding `OR REPLACE` to the command deletes any existing database and creates a new one.

[source, cypher]
----
Expand All @@ -206,6 +206,17 @@ CREATE OR REPLACE DATABASE customers

This is equivalent to running `DROP DATABASE customers IF EXISTS` followed by `CREATE DATABASE customers`.

Keep in mind that by running `CREATE OR REPLACE DATABASE` you delete also indexes and constraints.
If you wish to preserve them, run the following Cypher command before the `CREATE OR REPLACE DATABASE` and save the output:

[source, cypher]
----
SHOW INDEXES YIELD createStatement
UNION
SHOW CONSTRAINTS YIELD createStatement
RETURN createStatement as statement
----

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).

[NOTE]
Expand Down