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:

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:

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, the fastest way to delete everything in your current database is by issuing the following query:

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.