All Products
Search
Document Center

PolarDB:SET

Last Updated:Jan 22, 2025

The SET clause is used to update labels and properties on vertices and edges.

Terminal SET clauses

A SET clause that is not followed by another clause is a terminal clause. When a Cypher query ends with a terminal clause, no results are returned from the Cypher function call. However, the Cypher function call still requires a column list definition. When Cypher ends with a terminal node, define a single value in the column list definition: no data is returned in this variable.

Set a property

Use the SET clause to set a property on a node or relationship.

Example

SELECT *
FROM cypher('graph_name', $$
   MATCH (v {name: 'Andres'})
   SET v.surname = 'Taylor'
$$) as (v agtype);

Returns the changed vertex.

 v 
---
(0 rows)

Return a created vertex

You can execute the following query to create a single vertex:

Example

SELECT *
FROM cypher('graph_name', $$
    MATCH (v {name: 'Andres'})
    SET v.surname = 'Taylor'
    RETURN v
$$) as (v agtype);

Returns the changed vertex.

                                         v                                         
-----------------------------------------------------------------------------------------
{id: 3; label: 'Person'; properties: {surname:"Taylor", age:36, hungry:true}}::vertex
(1 row)

Use the SET clause to set multiple properties

If you want to set multiple properties in one query, you can separate them with commas.

Example

SELECT *
FROM cypher('graph_name', $$
MATCH (v {name: 'Andres'})
SET v.position = 'Developer', v.surname = 'Taylor'
RETURN v
$$) as (v agtype);

Returns the changed vertex.

                                                           v                                         
--------------------------------------------------------------------------------------------------------------------------------
{"id": 281474976710661, "label": "", "properties": {"name": "Andres", "surname": "Taylor", "position": "Developer"}}: :vertex
(1 row)