Search code examples
memgraphdb

Error when deleting a node using Cypher in Memgraph


When I try to delete the node

MATCH (c:Customer {name: 'John Smith'})
DELETE c;

I get the message Failed to remove node because of it's existing connections. Consider using DETACH DELETE.. What should I do?


Solution

  • Just follow the error message and replace DELETE with DETACH DELETE:

    MATCH (c:Customer {name: 'John Smith'})
    DETACH DELETE c;
    

    DELETE can only be used on nodes that have no relationships. To delete a node along with all of its relationships, you need to add DETACH.