Skip to content

Updating Node Properties

To find the node property or properties for found nodes, we need to find the node(s) and then we can SET any information to new value.

For example, to change name of the Person with the name Alex to Mark, we can do this:

Cypher
MATCH (n: Person { firstname: "Alex" }) SET n.firstname = "Mark" RETURN n
Example Output
+------------------------------------------------------------------------------------------------------------------+
| n                                                                                                                |
+------------------------------------------------------------------------------------------------------------------+
| (:Person {firstname: "Mark", city: "Helsinki", userId: 1, email: "alley@gmail.com", age: 25, lastname: "Jones"}) |
+------------------------------------------------------------------------------------------------------------------+

1 row
Set 1 properties

Associating another Label with a Node

To associate another label for a node, the command below can be used:

Cypher
MATCH (p: Person { userId: 3 }) SET p:Admin RETURN p
Example Output
+-------------------------------------------------------------------------------------------------------------------------+
| p                                                                                                                       |
+-------------------------------------------------------------------------------------------------------------------------+
| (:Person:Admin {firstname: "Veronica", city: "Turku", userId: 3, email: "veski@gmail.com", age: 52, lastname: "Skier"}) |
+-------------------------------------------------------------------------------------------------------------------------+

1 row
Added 1 labels

This finds the person with the userId 3 and sets the label Admin for that person. The label Admin will be created on-the-fly here as it did not exist before.

Removing Nodes

To remove the Person with userId 1, the command below can be used:

Cypher
MATCH (n: Person {userId: 1}) DETACH DELETE n
Example Output
Deleted 1 nodes

Note that the word DETACH is also added in the command above. This will also remove any relationships from this node to another node, if any would exist.