Overview
The SET
statement allows you to update or remove properties on nodes and edges. These nodes or edges must first be retrieved using the MATCH
statement.
Note: The schema (label) of a node or edge cannot be modified. Similarly, the values of system properties (_id
, _uuid
, _from
, _to
, _from_uuid
, and _to_uuid
) are immutable.
Example Graph

CREATE GRAPH myGraph ANY
INSERT (rowlock:User {_id: "U01", name: "rowlock"}),
(brainy:User {_id: "U02", name: "Brainy", gender: "male"}),
(purplechalk:User {_id: "U03", name: "purplechalk", gender: "female"}),
(mochaeach:User {_id: "U04", name: "mochaeach", gender: "female"}),
(c:Club {_id: "C01"}),
(rowlock)-[:Follows {createdOn: date("2024-01-05")}]->(brainy),
(purplechalk)-[:Follows {createdOn: date("2024-02-01")}]->(brainy),
(mochaeach)-[:Follows {createdOn: date("2024-02-10")}]->(brainy),
(brainy)-[:Joins {memberNo: 1}]->(c)
Updating Properties
To update gender
of the retrieved node n
and createdOn
of the retrieved edge e
:
MATCH (n:User {name: 'rowlock'})-[e:Follows]->(:User {name: 'Brainy'})
SET n.gender = 'male', e.createdOn = '2024-01-07'
RETURN n.gender, e.createdOn
Result:
n.gender | e.createdOn |
---|---|
male | 2024-01-07 |
Removing Properties
To remove the value of gender
of the retrieved node n
:
MATCH (n:User {name: 'mochaeach'})
SET n.gender = null
RETURN n
Result: n
_id | _uuid | schema | values |
---|---|---|---|
U04 | 1080867209103802371 | User | {name: "mochaeach", gender: null } |
Overwriting All Properties
To overwrite all properties of the retrieved node n
, updating the value of name
and removing values of other properties:
MATCH (n:User {name: 'purplechalk'})
SET n = {name: 'MasterSwift'}
RETURN n
Result: n
_id | _uuid | schema | values |
---|---|---|---|
U03 | 12393909473058488322 | User | {name: "MasterSwift", gender: null } |
Removing All Properties
To remove all properties of the retrieved node n
:
MATCH (n:User {name: 'rowlock'})
SET n = {}
RETURN n
Result: n
_id | _uuid | schema | values |
---|---|---|---|
U03 | 9223375335389659138 | User | {name: null , gender: null } |
Updating Properties with CASE
To set values for the new weight
property on Follows
edges based on their createdOn
values:
ALTER EDGE Follows ADD PROPERTY {weight UINT32};
MATCH ()-[e:Follows]->()
SET e.weight = CASE
WHEN e.createdOn < '2024-01-31' THEN 10
ELSE 8
END
RETURN e
Result: e
_uuid |
_from |
_to |
_from_uuid |
_to_uuid |
schema |
values |
---|---|---|---|---|---|---|
1 | U01 | U02 | 9223375335389659138 | 4179343752734703618 | Follows | {createdOn: "2024-01-05", weight: 10} |
3 | U04 | U02 | 1080867209103802371 | 4179343752734703618 | Follows | {createdOn: "2024-02-10", weight: 8} |
2 | U03 | U02 | 12393909473058488322 | 4179343752734703618 | Follows | {createdOn: "2024-02-01", weight: 8} |
Mismatched Value Type
If the provided value does not match the property's expected value type and cannot be converted, the property will be assigned its default value based on the property value type.
To update memberNo
(UINT64
type) of the retrieved edge with a string:
MATCH ()-[e:Joins]->()
SET e.memberNo = 'm2'
RETURN e
Result: e
_uuid |
_from |
_to |
_from_uuid |
_to_uuid |
schema |
values |
---|---|---|---|---|---|---|
4 | U02 | C01 | 4179343752734703618 | 4755803405526499332 | Follows | {memberNo: 0} |