Overview
The SET
statement allows you to set properties and labels on nodes and edges. These nodes or edges must first be retrieved using the MATCH
statement.
Note:
- In typed graphs, the schema of a node or edge is immutable.
- The values
_id
,_uuid
,_from
,_to
,_from_uuid
, and_to_uuid
are immutable.
Typed Graph
Example Graph

CREATE GRAPH myGraph {
NODE User ({name STRING, gender STRING}),
NODE Club (),
EDGE Follows ()-[{createdOn DATE}]->(),
EDGE Joins ()-[{memberNo INT32}]->()
}
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 Property Values
To update the values of specified properties:
MATCH (n:User {name: 'rowlock'})-[e:Follows]->(:User {name: 'Brainy'})
SET n.gender = 'male', e.createdOn = '2024-01-07'
RETURN n.gender, e.createdOn
Removing Property Values
To remove the values of specified properties by setting them to null
:
MATCH (n:User {name: 'mochaeach'})
SET n.gender = null
RETURN n
Overwriting All Property Values
To overwrite all property values, the mentioned property values will be updated while others will be set to null
:
MATCH (n:User {name: 'purplechalk'})
SET n = {name: 'MasterSwift'}
RETURN n
Removing All Property Values
To remove all property values by setting an empty specification:
MATCH (n:User {name: 'rowlock'})
SET n = {}
RETURN n
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} |
Open Graph
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)
Adding Labels
To add a label to a node:
MATCH (n:User {name: 'rowlock'})
SET n:Person
To add two labels to a node:
MATCH (n:User {name: 'rowlock'})
SET n:Player, n:Employee
Updating Property Values
To update the values of specified properties:
MATCH (n:User {name: 'rowlock'})-[e:Follows]->(:User {name: 'Brainy'})
SET n.gender = 'male', e.createdOn = '2024-01-07'
RETURN n.gender, e.createdOn
Overwriting All Property Values
To overwrite all property values:
MATCH (n:User {name: 'purplechalk'})
SET n = {name: 'MasterSwift'}
RETURN n