> ## Documentation Index
> Fetch the complete documentation index at: https://new.docs.falkordb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DELETE

> Use the DELETE clause to remove nodes and relationships from FalkorDB graphs. Deleting a node automatically removes all its incoming and outgoing relationships.

The `DELETE` clause is used to remove nodes and relationships from the graph.

## Important Behavior

**⚠️ Note:** Deleting a node automatically deletes all of its incoming and outgoing relationships. You cannot have orphaned relationships in the graph.

## Deleting Nodes

To delete a node and all of its relationships:

```sh theme={null}
GRAPH.QUERY DEMO_GRAPH "MATCH (p:Person {name:'Jim'}) DELETE p"
```

## Deleting Relationships

To delete specific relationships:

```sh theme={null}
GRAPH.QUERY DEMO_GRAPH "MATCH (:Person {name:'Jim'})-[r:FRIENDS]->() DELETE r"
```

This query deletes all outgoing `FRIENDS` relationships from the node with name 'Jim', while keeping the nodes intact.

## Common Patterns

### Delete all nodes and relationships in a graph

```sh theme={null}
GRAPH.QUERY DEMO_GRAPH "MATCH (n) DETACH DELETE n"
```

The `DETACH DELETE` automatically removes all relationships before deleting the node.

### Conditional deletion

```sh theme={null}
GRAPH.QUERY DEMO_GRAPH "MATCH (p:Person) WHERE p.age < 18 DELETE p"
```

Deletes all Person nodes where age is less than 18.

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="What happens to relationships when I delete a node?">
    Deleting a node **automatically deletes** all of its incoming and outgoing relationships. FalkorDB does not allow orphaned relationships in the graph.
  </Accordion>

  <Accordion title="What is the difference between DELETE and DETACH DELETE?">
    In FalkorDB, DELETE actually implements DETACH DELETE behavior — relationships are automatically removed when their endpoint nodes are deleted. Both keywords work the same way.
  </Accordion>

  <Accordion title="How do I delete all data in a graph?">
    Use `MATCH (n) DETACH DELETE n` to remove all nodes and their relationships. Alternatively, use the `GRAPH.DELETE` command to remove the entire graph key.
  </Accordion>

  <Accordion title="Can I delete specific relationships without deleting nodes?">
    Yes. Match the relationship with an alias and delete only it: `MATCH (a)-[r:KNOWS]->(b) DELETE r`. The nodes remain intact.
  </Accordion>
</AccordionGroup>
