Home » Neo4j Delete a Relationship

Neo4j Delete a Relationship

by Online Tutorials Library

Neo4j Delete a Relationship

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.

Example:

Delete the relationship named “PLAYER_OF” from the database:

Output:

Neo4j Delete a relationship 1

The above statement will match all Raul nodes that have a relationship type of PLAYER_OF with an Itly node.


Delete All Relationships related to a Node

There is a method to delete a node and all relationships related to that node.

Use the DETACH DELETE statement:

Example:

Output:

Neo4j Delete a relationship 2

This will delete the node “Kohli” where name is “Virat Kohli” with all its relationship.


Delete Whole Database

To delete all database use the DETACH DELETE statement without using a filter.

Next TopicNeo4j Read Clauses

You may also like