Delete
DELETE
DELETE
clause deletes node or relationship records from the table.
We will use the example database for demonstration, whose schema and data import commands are given here.
Delete Nodes
Delete Single Label Nodes
The following statements first create a User (Alice, 35) node record, without inserting any relationships to that node record, and then deletes the record
Delete Multi Label Nodes
The following statements first create a user node and a city node both with name “A” and then delete them.
Detach Delete
DELETE
can only delete nodes that do not have any relationships. To delete a node and all of its relationships with
a single clause, use DETACH DELETE
.
For example, to delete every record in the database, you can do the following:
Delete Relationships
Delete Single Label Relationships
The following query deletes the Follows
relationship between Adam
and Karissa
:
Delete Multi Label Relationships
The following query deletes all out-going edges from “Karissa”.