From cae0db5276b0df1e6b3551f6b7045a7be2d25669 Mon Sep 17 00:00:00 2001 From: imilinovic Date: Wed, 10 Sep 2025 10:08:47 +0200 Subject: [PATCH 1/3] drop all indexes and constraints --- pages/querying/clauses.mdx | 2 ++ pages/querying/clauses/_meta.ts | 2 ++ pages/querying/clauses/drop-all-constraints.mdx | 15 +++++++++++++++ pages/querying/clauses/drop-all-indexes.mdx | 16 ++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 pages/querying/clauses/drop-all-constraints.mdx create mode 100644 pages/querying/clauses/drop-all-indexes.mdx diff --git a/pages/querying/clauses.mdx b/pages/querying/clauses.mdx index 41f8a74aa..ee96dfc55 100644 --- a/pages/querying/clauses.mdx +++ b/pages/querying/clauses.mdx @@ -13,6 +13,8 @@ using the following clauses: * [`CASE`](/querying/clauses/case) - allows the creation of conditional expressions * [`CREATE`](/querying/clauses/create) - creates new nodes and relationships * [`DELETE`](/querying/clauses/delete) - deletes nodes and relationships + * [`DROP ALL CONSTRAINTS`](/querying/clauses/drop-all-constraints) - delete all constraints in your database + * [`DROP ALL INDEXES`](/querying/clauses/drop-all-indexes) - delete all indices in your database * [`DROP GRAPH`](/querying/clauses/drop-graph) - delete all the data, along with all the indices, constraints, triggers, and streams * [`EXPLAIN`](/querying/clauses/explain) - inspect a particular Cypher query in order to see its execution plan. * [`FOREACH`](/querying/clauses/foreach) - iterates over a list of elements and stores each element inside a variable diff --git a/pages/querying/clauses/_meta.ts b/pages/querying/clauses/_meta.ts index 2b61dc9c9..767070582 100644 --- a/pages/querying/clauses/_meta.ts +++ b/pages/querying/clauses/_meta.ts @@ -4,6 +4,8 @@ export default { "case": "CASE", "create": "CREATE", "delete": "DELETE", + "drop-all-constraints": "DROP ALL CONSTRAINTS", + "drop-all-indexes": "DROP ALL INDEXES", "drop-graph": "DROP GRAPH", "explain": "EXPLAIN", "foreach": "FOREACH", diff --git a/pages/querying/clauses/drop-all-constraints.mdx b/pages/querying/clauses/drop-all-constraints.mdx new file mode 100644 index 000000000..f848057f0 --- /dev/null +++ b/pages/querying/clauses/drop-all-constraints.mdx @@ -0,0 +1,15 @@ +--- +title: DROP ALL CONSTRAINTS +description: Learn to delete all constraints in your database using the DROP ALL CONSTRAINTS clause in Memgraph. +--- + +# DROP ALL CONSTRAINTS + +The `DROP ALL CONSTRAINTS` clause allows you to delete all constraints in your database in a single operation. +This includes all types of constraints: existence constraints, unique constraints, and type constraints. + +## Syntax + +```cypher +DROP ALL CONSTRAINTS; +``` diff --git a/pages/querying/clauses/drop-all-indexes.mdx b/pages/querying/clauses/drop-all-indexes.mdx new file mode 100644 index 000000000..501e9b11a --- /dev/null +++ b/pages/querying/clauses/drop-all-indexes.mdx @@ -0,0 +1,16 @@ +--- +title: DROP ALL INDEXES +description: Learn to delete all indices in your database using the DROP ALL INDEXES clause in Memgraph. +--- + +# DROP ALL INDEXES + +The `DROP ALL INDEXES` clause allows you to delete all indices in your database in a single operation. +This includes all types of indices: label indices, label-property indices, edge type indices, edge type-property indices, global edge indices, +point indices, text indices, vector indices, and vector edge indices. + +## Syntax + +```cypher +DROP ALL INDEXES; +``` From 819f132503cb4cce4e1aeb9b2fc40ad72bf033b7 Mon Sep 17 00:00:00 2001 From: matea16 Date: Tue, 30 Sep 2025 10:04:14 +0200 Subject: [PATCH 2/3] restructure --- pages/querying/clauses.mdx | 4 +- pages/querying/clauses/_meta.ts | 4 +- .../querying/clauses/drop-all-constraints.mdx | 15 ---- pages/querying/clauses/drop-all-indexes.mdx | 16 ---- pages/querying/clauses/drop-graph.mdx | 24 ------ pages/querying/clauses/drop.mdx | 85 +++++++++++++++++++ 6 files changed, 87 insertions(+), 61 deletions(-) delete mode 100644 pages/querying/clauses/drop-all-constraints.mdx delete mode 100644 pages/querying/clauses/drop-all-indexes.mdx delete mode 100644 pages/querying/clauses/drop-graph.mdx create mode 100644 pages/querying/clauses/drop.mdx diff --git a/pages/querying/clauses.mdx b/pages/querying/clauses.mdx index ee96dfc55..06c40b728 100644 --- a/pages/querying/clauses.mdx +++ b/pages/querying/clauses.mdx @@ -13,9 +13,7 @@ using the following clauses: * [`CASE`](/querying/clauses/case) - allows the creation of conditional expressions * [`CREATE`](/querying/clauses/create) - creates new nodes and relationships * [`DELETE`](/querying/clauses/delete) - deletes nodes and relationships - * [`DROP ALL CONSTRAINTS`](/querying/clauses/drop-all-constraints) - delete all constraints in your database - * [`DROP ALL INDEXES`](/querying/clauses/drop-all-indexes) - delete all indices in your database - * [`DROP GRAPH`](/querying/clauses/drop-graph) - delete all the data, along with all the indices, constraints, triggers, and streams + * [`DROP`](/querying/clauses/drop) - drop all constraints, indexes, or the entire database * [`EXPLAIN`](/querying/clauses/explain) - inspect a particular Cypher query in order to see its execution plan. * [`FOREACH`](/querying/clauses/foreach) - iterates over a list of elements and stores each element inside a variable * [`LOAD CSV`](/data-migration/csv) - loads data from CSV file diff --git a/pages/querying/clauses/_meta.ts b/pages/querying/clauses/_meta.ts index 767070582..ebd1d59a5 100644 --- a/pages/querying/clauses/_meta.ts +++ b/pages/querying/clauses/_meta.ts @@ -4,9 +4,7 @@ export default { "case": "CASE", "create": "CREATE", "delete": "DELETE", - "drop-all-constraints": "DROP ALL CONSTRAINTS", - "drop-all-indexes": "DROP ALL INDEXES", - "drop-graph": "DROP GRAPH", + "drop": "DROP", "explain": "EXPLAIN", "foreach": "FOREACH", "load-csv": "LOAD CSV", diff --git a/pages/querying/clauses/drop-all-constraints.mdx b/pages/querying/clauses/drop-all-constraints.mdx deleted file mode 100644 index f848057f0..000000000 --- a/pages/querying/clauses/drop-all-constraints.mdx +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: DROP ALL CONSTRAINTS -description: Learn to delete all constraints in your database using the DROP ALL CONSTRAINTS clause in Memgraph. ---- - -# DROP ALL CONSTRAINTS - -The `DROP ALL CONSTRAINTS` clause allows you to delete all constraints in your database in a single operation. -This includes all types of constraints: existence constraints, unique constraints, and type constraints. - -## Syntax - -```cypher -DROP ALL CONSTRAINTS; -``` diff --git a/pages/querying/clauses/drop-all-indexes.mdx b/pages/querying/clauses/drop-all-indexes.mdx deleted file mode 100644 index 501e9b11a..000000000 --- a/pages/querying/clauses/drop-all-indexes.mdx +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: DROP ALL INDEXES -description: Learn to delete all indices in your database using the DROP ALL INDEXES clause in Memgraph. ---- - -# DROP ALL INDEXES - -The `DROP ALL INDEXES` clause allows you to delete all indices in your database in a single operation. -This includes all types of indices: label indices, label-property indices, edge type indices, edge type-property indices, global edge indices, -point indices, text indices, vector indices, and vector edge indices. - -## Syntax - -```cypher -DROP ALL INDEXES; -``` diff --git a/pages/querying/clauses/drop-graph.mdx b/pages/querying/clauses/drop-graph.mdx deleted file mode 100644 index 0503d0bbd..000000000 --- a/pages/querying/clauses/drop-graph.mdx +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: DROP GRAPH -description: Learn to delete all the data, along with all the indices, constraints, triggers, and streams, in a very efficient manner using the DROP GRAPH clause in Memgraph. ---- - -# DROP GRAPH - -In the [analytical -mode](/fundamentals/storage-memory-usage#in-memory-analytical-storage-mode), the -fastest way to delete everything in your current database is by issuing the -following query: - -```cypher -DROP GRAPH; -``` - -The query allows the user to delete all the data, along with all the indices, -constraints, triggers, and streams, in a very efficient manner. For this query -to succeed, the user must ensure that Memgraph is operating in the -`IN_MEMORY_ANALYTICAL` storage mode. The user must also ensure that `DROP GRAPH` -is the only transaction running at the time of issuing the command. If any other -Cypher query is running when `DROP GRAPH` starts to execute, it will prevent -this command from running until all the other queries are finished. - diff --git a/pages/querying/clauses/drop.mdx b/pages/querying/clauses/drop.mdx new file mode 100644 index 000000000..33f2ece99 --- /dev/null +++ b/pages/querying/clauses/drop.mdx @@ -0,0 +1,85 @@ +--- +title: DROP +description: Learn to delete all indexes, constraints or the entire data of the graph. +--- + +# DROP + +The `DROP` commands in Memgraph provide a way to remove different types of +schema elements and data from your database. Depending on your needs, you can +choose to remove only specific structures such as indexes or constraints, or +perform a complete reset of the entire database. + + +Memgraph supports several `DROP` operations: + +- `DROP ALL INDEXES` – removes every index in the database. +- `DROP ALL CONSTRAINTS` – removes all defined constraints. +- `DROP GRAPH` – clears the entire database, including data, indexes, constraints, +triggers, and streams, in one operation (analytical mode only). + +Each of these operations serves a different purpose, ranging from cleaning up +schema elements to performing a complete reset. The following sections describe +each command in detail. + +## DROP ALL INDEXES + +The `DROP ALL INDEXES` clause allows you to delete all indices in your database +in a single operation. This includes all types of indices: label indices, +label-property indices, edge type indices, edge type-property indices, global +edge indices, point indices, text indices, vector indices, and vector edge +indices. + +Removing all indexes can be useful if you want to redefine indexing strategies +or if you are about to load data in bulk and recreate indexes afterward. + +**Syntax:** + +```cypher +DROP ALL INDEXES; +``` + +## DROP ALL CONSTRAINTS + +The `DROP ALL CONSTRAINTS` clause allows you to delete all constraints in your +database in a single operation. This includes all types of constraints: +- existence constraints +- unique constraints +- type constraints + +This operation is particularly helpful when you want to redefine your schema +rules or prepare the database for significant restructuring. + +**Syntax:** + +```cypher +DROP ALL CONSTRAINTS; +``` + +## DROP GRAPH + +While dropping indexes and constraints clears only schema definitions, the `DROP +GRAPH` command provides a much more comprehensive reset. + +In the [analytical +mode](/fundamentals/storage-memory-usage#in-memory-analytical-storage-mode), the +fastest way to delete everything in your current database is by issuing the +following query: + +```cypher +DROP GRAPH; +``` + +The query allows the user to delete **all data**, along with **all indices**, +**constraints**, **triggers**, and **streams**, in a very efficient manner. + +To ensure successful execution: +- Memgraph must be operating in the `IN_MEMORY_ANALYTICAL` storage mode. +- `DROP GRAPH` must be the only transaction running at the time of execution. If +any other Cypher queries are running, they must finish before this command can +proceed. + +This command is ideal when you need a fresh start without manually removing data +or schema elements. + + From d2bf61f4b1ec5f32d23ee53f7e1a14412f15d8bc Mon Sep 17 00:00:00 2001 From: imilinovic Date: Tue, 30 Sep 2025 12:31:22 +0200 Subject: [PATCH 3/3] add drop all indexes and constraints info on index and constraints pages --- pages/fundamentals/constraints.mdx | 20 +++++++++++++++++++- pages/fundamentals/indexes.mdx | 19 +++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/pages/fundamentals/constraints.mdx b/pages/fundamentals/constraints.mdx index 8889057f8..2bbebd8f7 100644 --- a/pages/fundamentals/constraints.mdx +++ b/pages/fundamentals/constraints.mdx @@ -274,11 +274,29 @@ DROP CONSTRAINT ON (n:Person) ASSERT n.age IS TYPED INTEGER; Now, `SHOW CONSTRAINT INFO;` returns an empty set. +## Drop all constraints + +The `DROP ALL CONSTRAINTS` clause allows you to delete all constraints in your +database in a single operation. This includes all types of constraints: +- existence constraints +- unique constraints +- type constraints + +```cypher +DROP ALL CONSTRAINTS; +``` + ## Schema-related procedures You can also modify the constraints using the [`schema.assert()` procedure](/querying/schema#assert). -### Delete all constraints +### Delete all constraints via schema.assert + + + +The `DROP ALL CONSTRAINTS` command should be preferred over the [`schema.assert()`](/querying/schema#assert) procedure for removing all constraints, as it works on all constraint types. + + To delete all constraints, use the [`schema.assert()`](/querying/schema#assert) procedure with the following parameters: - `indices_map` = map of key-value pairs of all indexes in the database diff --git a/pages/fundamentals/indexes.mdx b/pages/fundamentals/indexes.mdx index 99c07973f..93ab6c166 100644 --- a/pages/fundamentals/indexes.mdx +++ b/pages/fundamentals/indexes.mdx @@ -655,8 +655,17 @@ DROP GLOBAL EDGE INDEX ON :(property_name); DROP POINT INDEX ON :Label(property); ``` -These queries instruct all active transactions to abort as soon as possible. -Once all transactions have finished, the index will be deleted. +### Drop all indexes + +The `DROP ALL INDEXES` clause allows you to delete all indices in your database +in a single operation. This includes all types of indices: label indices, +label-property indices, edge type indices, edge type-property indices, global +edge indices, point indices, text indices, vector indices, and vector edge +indices. + +```cypher +DROP ALL INDEXES; +``` ### Delete all node indexes @@ -665,6 +674,12 @@ The `schema.assert()` procedure will not drop edge and point indexes. Our plan is to update it, and you can track the progress on our [GitHub](https://github.com/memgraph/memgraph/issues/2462). + + +The `DROP ALL INDEXES` command should be preferred over the [`schema.assert()`](/querying/schema#assert) procedure for removing all indexes, as it works on all index types. + + + To delete all indexes, use the [`schema.assert()`](/querying/schema#assert) procedure with the following parameters: - `indices_map` = `{}` - `unique_constraints` = map of key-value pairs of all uniqueness constraints in the database