Neo4J:删除关系

1、现有关系

MATCH (n:Person) RETURN n;

Neo4J:删除关系_第1张图片

2、不能删除含有关系的节点

MATCH(p:Person) DELETE p;

Neo4J:删除关系_第2张图片

Neo.ClientError.Schema.ConstraintValidationFailed: Cannot delete node<1153>, because it still has relationships. To delete this node, you must first delete its relationships.

3、删除指定关系

MATCH (p1:Person)-[r:LOVES]-(p2:Person) 
DELETE p1,p2,r

Neo4J:删除关系_第3张图片
注意,delete子句的格式是DELETE ,,

剩下的实体关系
Neo4J:删除关系_第4张图片

4、DETACH DELETE

MATCH(p:Person)
DETACH DELETE p;

Neo4J:删除关系_第5张图片

Neo4J:删除关系_第6张图片

你可能感兴趣的:(知识图谱)