How to delete property from relationship in Memgraph?

59 Views Asked by At

I've came across two possible solutions for deleting a property from all nodes:

First method is to set it to null: MATCH (n:name) SET n.age = NULL

Second method is to remove property.

MATCH (n:name)
REMOVE n.age
RETURN n;

In both cases the end result seems the same to me.

Can the value of a property in a relationship be set to null and be deleted in that way?

1

There are 1 best solutions below

0
On BEST ANSWER

Yes, that is officially supported by openCypher.

Here is an excerpt from the latest (version 9) openCypher language reference:

Remove a property

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

Query

MATCH (n {name: 'Andres'})
SET n.name = NULL
RETURN n

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