3.3.14. REMOVE

The REMOVE clause is used to remove properties and labels from graph elements.

3.3.14.1. Introduction

For deleting nodes and relationships, see Section 3.3.12, “DELETE”.

Removing labels from a node is an idempotent operation: If you try to remove a label from a node that does not have that label on it, nothing happens. The query statistics will tell you if something needed to be done or not.

The examples use the following database:

alt

3.3.14.2. Remove a property

Neo4j doesn’t allow storing null in properties. Instead, if no value exists, the property is just not there. So, to remove a property value on a node or a relationship, is also done with REMOVE.

Query. 

MATCH (andres { name: 'Andres' })
REMOVE andres.age
RETURN andres

The node is returned, and no property age exists on it.

Result. 

+------------------------+
| andres                 |
+------------------------+
| Node[0]{name:"Andres"} |
+------------------------+
1 row
Properties set: 1

3.3.14.3. Remove a label from a node

To remove labels, you use REMOVE.

Query. 

MATCH (n { name: 'Peter' })
REMOVE n:German
RETURN n

Result. 

+------------------------------+
| n                            |
+------------------------------+
| Node[2]{name:"Peter",age:34} |
+------------------------------+
1 row
Labels removed: 1

3.3.14.4. Removing multiple labels

To remove multiple labels, you use REMOVE.

Query. 

MATCH (n { name: 'Peter' })
REMOVE n:German:Swedish
RETURN n

Result. 

+------------------------------+
| n                            |
+------------------------------+
| Node[2]{name:"Peter",age:34} |
+------------------------------+
1 row
Labels removed: 2