- Neo4j CQL Write Clauses
- Neo4j - Merge Command
- Neo4j - Set Clause
- Neo4j - Delete Clause
- Neo4j - Remove Clause
- Neo4j - Foreach Clause
- Neo4j CQL Read Clause
- Neo4j - Match Clause
- Neo4j - Optional Match Clause
- Neo4j - Where Clause
- Neo4j - Count Function
- Neo4j CQL General Clauses
- Neo4j - Return Clause
- Neo4j - Order By Clause
- Neo4j - Limit Clause
- Neo4j - Skip Clause
- Neo4j - With Clause
- Neo4j - Unwind Clause
- Neo4j CQL Functions
- Neo4j - String Functions
- Neo4j - Aggregation Function
- Neo4j CQL Admin
- Neo4j - Backup & Restore
- Neo4j - Index
- Neo4j - Create Unique Constraint
- Neo4j - Drop Unique
- Neo4j Useful Resources
- Neo4j - Quick Guide
- Neo4j - Useful Resources
- Neo4j - Discussion
Neo4j CQL - DELETE
Neo4j CQL DELETE clause
Neo4j CQL DELETE clause is used
To delete a Node
To delete a Node and associated Nodes and Relationships
We are to going to discuss how to delete a node in this chapter. We will discuss how to delete a Node and associated Nodes and Relationships in next chapter.
To Delete a Node:-
We can also delete a Node and all its associated nodes and Relationships at a time permanently from the Database.
DELETE a Node and Relationship clause syntax
DELETE <node1-name>,<node2-name>,<relationship-name>
| S.No. | Syntax Element | Description |
|---|---|---|
| 1. | DELETE | It is a Neo4j CQL keyword. |
| 2. | <node1-name> | It is one end node name used to create a relationship <relationship-name>. |
| 3. | <node2-name> | It is another node name used to create a relationship <relationship-name>. |
| 4. | <relationship-name> | It is a relationship name, which is created between <node1-name> and <node2-name>. |
NOTE:-
We should use comma(,) operator to separate the node names and relationship name.
Example1:-
TThis example demonstrates how to delete a Node and its associate Node and relationship permanently from the Database.
Steps to follow:
Open Neo4j Data Browser
Type the below command on Data Browser
It is Neo4j Data Browser Homepage
MATCH (cc:CreditCard)-[r]-(c:Customer)RETURN r
Click on "Execute" button and observe the results.
Here we are observing that one node for Customer, one node for CreditCard and a relationship between them is available.
Type the below command on Data Browser
MATCH (cc: CreditCard)-[rel]-(c:Customer) DELETE cc,c,rel
Click on "Execute" button and observe the results.
Here we can observe that two nodes and their associated 10 relationships are deleted successfully.
Now check whether the DELETE operation is done successfully or not.
Type the below command on Data Browser.
MATCH (cc:CreditCard)-[r]-(c:Customer) RETURN r
Click on "Execute" button and observe the results.
Here we can observe that zero rows returned from the database.