REMOVE
Introduction
For deleting nodes and relationships, see 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:
N0 [ label = "{Swedish|name = \'Andy\'\lage = 36\l}" ] N0 -> N2 [ color = "#2e3436" fontcolor = "#2e3436" label = "KNOWS\n" ] N0 -> N1 [ color = "#2e3436" fontcolor = "#2e3436" label = "KNOWS\n" ] N1 [ label = "{Swedish|name = \'Timothy\'\lage = 25\l}" ] N2 [ label = "{Swedish, German|name = \'Peter\'\lage = 34\l}" ]
Remove a property
Neo4j doesn’t allow storing null
in properties.
Instead, if no value exists, the property is just not there.
So, REMOVE
is used to remove a property value from a node or a relationship.
MATCH (a {name: 'Andy'})
REMOVE a.age
RETURN a.name, a.age
The node is returned, and no property age
exists on it.
a.name | a.age |
---|---|
|
|
Rows: 1 |
Remove all properties
REMOVE
cannot be used to remove all existing properties from a node or relationship.
Instead, using SET
with =
and an empty map as the right operand will clear all properties from the node or relationship.