In SQL:
Delete From Person Where ID = 1;
In Cypher, what's the script to delete a node by ID?
(Edited: ID = Neo4j's internal Node ID)
Deleting relationship is as simple as deleting nodes. Use the MATCH statement to match the relationships you want to delete. You can delete one or many relationships or all relationships by using one statement.
When you want to delete a node and any relationship going to or from it, use DETACH DELETE . For DETACH DELETE for users with restricted security privileges, see Operations Manual → Fine-grained access control.
The REMOVE clause is used to remove properties and labels from graph elements (Nodes or Relationships). DELETE operation is used to delete nodes and associated relationships. REMOVE operation is used to remove labels and properties.
Assuming you're referring to Neo4j's internal node id:
MATCH (p:Person) where ID(p)=1 OPTIONAL MATCH (p)-[r]-() //drops p's relations DELETE r,p
If you're referring to your own property 'id' on the node:
MATCH (p:Person {id:1}) OPTIONAL MATCH (p)-[r]-() //drops p's relations DELETE r,p
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With