diff --git a/modules/ROOT/pages/clauses/delete.adoc b/modules/ROOT/pages/clauses/delete.adoc index 0f6c13678..18669961e 100644 --- a/modules/ROOT/pages/clauses/delete.adoc +++ b/modules/ROOT/pages/clauses/delete.adoc @@ -127,9 +127,9 @@ For more information, see link:{neo4j-docs-base-uri}/operations-manual/{page-ver [[delete-all-nodes-and-relationships]] == Delete all nodes and relationships -It is possible to delete all nodes and relationships in a graph. +It is possible to delete all nodes and relationships in a graph. -.Query +.Delete all nodes and relationships [source, cypher, indent=0] ---- MATCH (n) @@ -142,8 +142,25 @@ DETACH DELETE n Deleted 3 nodes, deleted 1 relationship ---- -[TIP] -==== -`DETACH DELETE` is not suitable for deleting large amounts of data, but is useful when experimenting with small example datasets. -To delete large amounts of data, instead use xref::subqueries/subqueries-in-transactions.adoc#delete-with-call-in-transactions[CALL subqueries in transactions]. -==== \ No newline at end of file +`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]. + +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. + +.Delete all nodes and relationships using `CALL` subqueries +[source, cypher] +---- +MATCH (n) +CALL (n) { + DETACH DELETE n +} IN TRANSACTIONS +---- + +To remove all data, including indexes and constraints, recreate the database using the following command: `CREATE OR REPLACE DATABASE name`. + +.Delete a database and recreate it +[source, cypher] +---- +CREATE OR REPLACE DATABASE neo4j +---- + +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`]. \ No newline at end of file diff --git a/modules/ROOT/pages/queries/basic.adoc b/modules/ROOT/pages/queries/basic.adoc index 2ab239466..cb6d57af4 100644 --- a/modules/ROOT/pages/queries/basic.adoc +++ b/modules/ROOT/pages/queries/basic.adoc @@ -901,4 +901,6 @@ MATCH (n) DETACH DELETE n ---- -For more information, see the section on the xref:clauses/delete.adoc[] clause. +[NOTE] +`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]. +For more information, and alternatives to `DETACH DELETE`, see xref:clauses/delete.adoc#delete-all-nodes-and-relationships[`DELETE` -> Delete all nodes and relationships].