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
+31-7Lines changed: 31 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,23 +127,47 @@ 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.
131
130
132
-
.Query
131
+
It is possible to delete all nodes and relationships in a graph.
132
+
133
+
134
+
.Delete all nodes and relationships
133
135
[source, cypher, indent=0]
134
136
----
135
137
MATCH (n)
136
138
DETACH DELETE n
137
139
----
138
140
141
+
139
142
.Result
140
143
[role="queryresult",options="footer",cols="1*<m"]
141
144
----
142
145
Deleted 3 nodes, deleted 1 relationship
143
146
----
144
147
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
-
====
148
+
149
+
`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].
150
+
151
+
152
+
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.
153
+
154
+
155
+
.Delete all nodes and relationships using `CALL` subqueries
156
+
[source, cypher]
157
+
----
158
+
MATCH (n)
159
+
CALL (n) {
160
+
DETACH DELETE n
161
+
} IN TRANSACTIONS
162
+
----
163
+
164
+
165
+
To delete everything in a database, including indexes and constraints, you can recreate the database using the following command: `CREATE OR REPLACE DATABASE name`.
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
+
`DEATCH 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