You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clarify that CREATE OR REPLACE DB deletes indexes and constraints as well (#2154)
You may need to preserve the database structure (indexes and
constraints) when you move the database from test env to production. In
this case, it's important to know that the `CREATE OR REPLACE DB` cmd
removes not only data but also indexes and constraints. If you want to
keep them, you have to do it before executing the command.
Copy file name to clipboardexpand all lines: modules/ROOT/pages/database-administration/standard-databases/create-databases.adoc
+15
Original file line number
Diff line number
Diff line change
@@ -206,6 +206,21 @@ CREATE OR REPLACE DATABASE customers
206
206
207
207
This is equivalent to running `DROP DATABASE customers IF EXISTS` followed by `CREATE DATABASE customers`.
208
208
209
+
Keep in mind that using `CREATE OR REPLACE DATABASE` also removes indexes and constraints.
210
+
To preserve them, run the following Cypher commands before the `CREATE OR REPLACE DATABASE` and save their outputs:
211
+
212
+
[source, cypher]
213
+
----
214
+
SHOW CONSTRAINTS YIELD createStatement AS statement
215
+
----
216
+
217
+
[source, cypher]
218
+
----
219
+
SHOW INDEXES YIELD createStatement, owningConstraint
220
+
WHERE owningConstraint IS NULL
221
+
RETURN createStatement AS statement
222
+
----
223
+
209
224
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).
0 commit comments