Prev |  | Next

## 15.20. Set

Updating properties on nodes and relationships is done with the `SET` clause. `SET` can also be used with maps from parameters.

### 15.20.1. Set a property

To set a property on a node or relationship, use `SET`.

Query.

    START n = node(2)
    SET n.surname = 'Taylor'
    RETURN n

The newly changed node is returned by the query.

Result

n
1 row
Properties set: 1
0 ms
`Node[2]{name:"Andres",age:36,awesome:true,surname:"Taylor"}`

### 15.20.2. Remove a property

Normally you remove a property by using delete, but it’s sometimes handy to do it using the `SET` command. One example is if the property comes from a parameter.

Query.

    START n = node(2)
    SET n.name = null
    RETURN n

The node is returned by the query, and the name property is now missing.

Result

n
1 row
Properties set: 1
0 ms
`Node[2]{awesome:true,age:36}`

### 15.20.3. Copying properties between nodes and relationships

You can also use SET to copy all properties from one graph element to another. Remember that doing this will remove all other properties on the receiving graph element.

Query.

    START at = node(2), pn = node(1)
    SET at = pn
    RETURN at, pn

The Andres node has had all it’s properties replaced by the properties in the Peter node.

Result

at | pn
--- | ---
1 row
Properties set: 3
0 ms
`Node[2]{name:"Peter",age:34}` | `Node[1]{name:"Peter",age:34}`

Copyright © 2013 Neo Technology

Prev | Up | Next
| Home |