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
Copy file name to clipboardExpand all lines: modules/ROOT/pages/clauses/delete.adoc
+24-7Lines changed: 24 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,9 +127,9 @@ For more information, see link:{neo4j-docs-base-uri}/operations-manual/{page-ver
127
127
[[delete-all-nodes-and-relationships]]
128
128
== Delete all nodes and relationships
129
129
130
-
It is possible to delete all nodes and relationships in a graph.
130
+
It is possible to delete all nodes and relationships in a graph.
131
131
132
-
.Query
132
+
.Delete all nodes and relationships
133
133
[source, cypher, indent=0]
134
134
----
135
135
MATCH (n)
@@ -142,8 +142,25 @@ DETACH DELETE n
142
142
Deleted 3 nodes, deleted 1 relationship
143
143
----
144
144
145
-
[TIP]
146
-
====
147
-
`DETACH DELETE` is not suitable for deleting large amounts of data, but is useful when experimenting with small example datasets.
148
-
To delete large amounts of data, instead use xref::subqueries/subqueries-in-transactions.adoc#delete-with-call-in-transactions[CALL subqueries in transactions].
149
-
====
145
+
`DETACH DELETE` is useful when experimenting with small example datasets, but it is not suitable for deleting large amounts of data, nor does it delete xref:indexes/search-performance-indexes/overview.adoc[indexes] and xref:constraints/index.adoc[constraints].
146
+
147
+
To delete large amounts of data without deleting indexes and constraints, use xref::subqueries/subqueries-in-transactions.adoc#delete-with-call-in-transactions[CALL subqueries in transactions] instead.
148
+
149
+
.Delete all nodes and relationships using `CALL` subqueries
150
+
[source, cypher]
151
+
----
152
+
MATCH (n)
153
+
CALL (n) {
154
+
DETACH DELETE n
155
+
} IN TRANSACTIONS
156
+
----
157
+
158
+
To remove all data, including indexes and constraints, recreate the database using the following command: `CREATE OR REPLACE DATABASE name`.
159
+
160
+
.Delete a database and recreate it
161
+
[source, cypher]
162
+
----
163
+
CREATE OR REPLACE DATABASE neo4j
164
+
----
165
+
166
+
For more information, see the link:{neo4j-docs-base-uri}/operations-manual/current/database-administration/standard-databases/create-databases/#_create_databases_with_if_not_exists_or_or_replace[Operations Manual -> Create databases with `IF NOT EXISTS` or `OR REPLACE`].
Copy file name to clipboardExpand all lines: modules/ROOT/pages/queries/basic.adoc
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -901,4 +901,6 @@ MATCH (n)
901
901
DETACH DELETE n
902
902
----
903
903
904
-
For more information, see the section on the xref:clauses/delete.adoc[] clause.
904
+
[NOTE]
905
+
`DETACH DELETE` is not suitable for deleting large amounts of data, nor does it delete xref:indexes/search-performance-indexes/overview.adoc[indexes] and xref:constraints/index.adoc[constraints].
906
+
For more information, and alternatives to `DETACH DELETE`, see xref:clauses/delete.adoc#delete-all-nodes-and-relationships[`DELETE` -> Delete all nodes and relationships].
0 commit comments