Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion pages/fundamentals/constraints.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

<Callout type="info">

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.

</Callout>

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
Expand Down
19 changes: 17 additions & 2 deletions pages/fundamentals/indexes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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).
</Callout>

<Callout type="info">

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.

</Callout>

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
Expand Down
2 changes: 1 addition & 1 deletion pages/querying/clauses.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +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 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
Expand Down
2 changes: 1 addition & 1 deletion pages/querying/clauses/_meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
"case": "CASE",
"create": "CREATE",
"delete": "DELETE",
"drop-graph": "DROP GRAPH",
"drop": "DROP",
"explain": "EXPLAIN",
"foreach": "FOREACH",
"load-csv": "LOAD CSV",
Expand Down
24 changes: 0 additions & 24 deletions pages/querying/clauses/drop-graph.mdx

This file was deleted.

85 changes: 85 additions & 0 deletions pages/querying/clauses/drop.mdx
Original file line number Diff line number Diff line change
@@ -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.