14.27. Delete

14.27.1. Delete single node
14.27.2. Delete a node and connected relationships

Deleting graph elements — nodes and relationships, is done with DELETE.

The examples start out with the following database:

cypher-delete-graph.svg

14.27.1. Delete single node

To delete a node, use the DELETE clause.

Query. 

MATCH n
WHERE n.name='Danny'
DELETE n

Nothing is returned from this query, except the count of affected nodes.

Result

Nodes deleted: 1
2 ms

(empty result)


14.27.2. Delete a node and connected relationships

If you are trying to delete a node with relationships on it, you have to delete these as well.

Query. 

START n = node(3)
MATCH n-[r]-()
DELETE n, r

Nothing is returned from this query, except the count of affected nodes.

Result

Nodes deleted: 1
Relationships deleted: 2
2 ms

(empty result)