Search code examples
cyphergraph-databasesmemgraphdb

How can I delete relationships belonging to a node using Cypher in Memgraph?


I have a node, and I want to delete all of the relationships for that node. I've tried to use MATCH (node) DELETE node; but I get an error. What am I doing wrong?


Solution

  • Cypher prevents accidental deletion of relationships. You need to use the DETACH keyword, which will remove relationships from a node you are deleting. The following should work and delete everything in the database:

    MATCH (node) DETACH DELETE node;