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:
_id and _uuid are immutable.
CREATE GRAPH myGraph { NODE User ({name STRING, gender STRING}), NODE Club (), EDGE Follows ()-[{createdOn DATE}]->(), EDGE Joins ()-[{memberNo INT32}]->() }
To update the value of each specified property:
GQLMATCH (n:User {name: 'rowlock'})-[e:Follows]->(:User {name: 'Brainy'}) SET n.gender = 'male', e.createdOn = '2024-01-07' RETURN n.gender, e.createdOn
To remove the values of specified properties by setting them to null:
GQLMATCH (n:User {name: 'mochaeach'}) SET n.gender = null
You can overwrite all property values of a node or edge using a record. Any property included in the record will be updated, while all other properties will be set to null.
GQLMATCH (n:User {name: 'purplechalk'}) SET n = {name: 'MasterSwift'} RETURN n
To remove all property values by setting an empty record:
GQLMATCH (n:User {name: 'rowlock'}) SET n = {} RETURN n
If the provided value does not match the property's value type and cannot be converted, the property will be assigned its default value based on the property value type.
For example, if you update memberNo (UINT64 type) with a string value, memberNo will be automatically set to 0:
GQLMATCH ()-[e:Joins]->() SET e.memberNo = 'm2'

CREATE GRAPH myGraph ANY
To add a label to a node:
GQLMATCH (n:User {name: 'rowlock'}) SET n:Person
To add two labels to a node:
GQLMATCH (n:User {name: 'rowlock'}) SET n:Player, n:Employee
NOTETo remove labels from nodes or edges, use the REMOVE statement.
To update the value of each specified property:
GQLMATCH (n:User {name: 'rowlock'})-[e:Follows]->(:User {name: 'Brainy'}) SET n.gender = 'male', e.createdOn = date('2024-01-07') RETURN n.gender, e.createdOn
You can replace all properties of a node or edge using a record.
To replace all property values:
GQLMATCH (n:User {name: 'purplechalk'}) SET n = {username: 'MasterSwift', age: 36} RETURN n