Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the Cypher script to delete a node by ID?

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)

like image 527
Rm558 Avatar asked Jan 26 '15 04:01

Rm558


People also ask

How do I delete a particular relationship in Neo4j?

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.

Which of the following command can be used to delete a property of a node?

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.

How do I remove a property from Neo4j?

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.


1 Answers

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 
like image 124
Luanne Avatar answered Oct 23 '22 12:10

Luanne