Skip to content

Commit f50de10

Browse files
Clarify that CREATE OR REPLACE DB deletes indexes and constraints as well
1 parent 409908b commit f50de10

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

modules/ROOT/pages/database-administration/standard-databases/create-databases.adoc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ First, appending `IF NOT EXISTS` to the command ensures that no error is returne
197197
CREATE DATABASE customers IF NOT EXISTS
198198
----
199199

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

202202
[source, cypher]
203203
----
@@ -206,6 +206,17 @@ CREATE OR REPLACE DATABASE customers
206206

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

209+
Keep in mind that by running `CREATE OR REPLACE DATABASE` you delete also indexes and constraints.
210+
If you wish to preserve them, run the following Cypher command before the `CREATE OR REPLACE DATABASE` and save the output:
211+
212+
[source, cypher]
213+
----
214+
SHOW INDEXES YIELD createStatement
215+
UNION
216+
SHOW CONSTRAINTS YIELD createStatement
217+
RETURN createStatement as statement
218+
----
219+
209220
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).
210221

211222
[NOTE]

0 commit comments

Comments
 (0)