15.5. Delete

15.5.1. Delete single node
15.5.2. Delete a node and connected relationships

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

For properties and labels, see Section 15.6, “Remove”.

The examples start out with the following database:

cypher-delete-graph.svg

15.5.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

(empty result)


15.5.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

(empty result)