In this section, we will discuss updating labels, properties, and relationships.
The properties of a node are modified by using the following Cypher statement:
MATCH (f:FEMALE {name: "Sheena"}) SET f.surname = "Foster" return f;
The preceding statement will find the node Sheena
and will add or update (if it already exists) the property surname
with a new or modified value. For removing the property, just replace the SET
statement in the preceding Cypher query with SET f.surname = NULL
. We can also set multiple properties by separating them with a comma.
The REMOVE
statement is another construct provided by Cypher for removing the properties of a node. For example, we can also execute the following statement for removing the property surname
:
MATCH (f:FEMALE {name: "Sheena"}) REMOVE f.surname return f;