SET

MATCH (n) WHERE n.name = 'Alice' SET n.age = 31

Update properties or labels on matched nodes and relationships. Automatically updates the updated_at timestamp.

Syntax#

MATCH (variable) WHERE predicate
SET <assignment>[, <assignment>]*

Each <assignment> is one of:

FormEffect
n.key = valueSet a single property
n.key = nullRemove a property (equivalent to REMOVE n.key)
n:LabelAdd a label
n:Label1:Label2Add multiple labels
n += {key: value, ...}Merge a property map onto n (existing keys not in the map are preserved)
n = {key: value, ...}Replace all properties on n with the map (existing keys not in the map are removed)

Examples#

Multiple properties in one clause#

MATCH (r:Robot {id: 'r1'})
SET r.battery = 96, r.status = 'charging', r.task = 'standby'

Add a label#

MATCH (n:Person {id: 'p1'}) SET n:Verified

Merge a map#

MATCH (n:Person {id: 'p1'})
SET n += {age: 31, lastSeen: timestamp()}

+= keeps any existing properties not mentioned in the map. Use n = {...} instead to replace the full property set.

Parameterized#

MATCH (n:Person {id: $id}) SET n.age = $age, n.role = $role

See Also#

  • MATCH + WHERE — select what to update
  • REMOVE — remove properties or labels
  • MERGE — find-or-create with ON CREATE SET / ON MATCH SET
Try it
Open ↗
Loading engine…