
- 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 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 -
By using this command, we can delete a Node and its associated properties permanently from the Database.
DELETE a Node clause syntax
DELETE <node-name-list>
S.No. | Syntax Element | Description |
---|---|---|
1. | DELETE | It is a Neo4j CQL keyword. |
2. | <node-name-list> | It is a list of node names, which are going to delete from Database. |
NOTE -
We should use comma(,) operator to separate the node names.
Example
This example demonstrates how to delete a Node permanently from the Database.
Step 1 - Open Neo4j Data Browser.
Step 2 - Type the below command on Data Browser
MATCH (e: 'Employee') RETURN e
NOTE -
MATCH (e: 'Employee') RETURN e
MATCH (e: "Employee") RETURN e
MATCH (e: Employee) RETURN e
All three commands are same, we can choose any one of these commands.

Step 3 - Click on "Execute" button and observe the results.

Here we can observe that there is one node available with "Employee" name in the Database.
Step 4 - Type the below command on Data Browser.
MATCH (e: Employee) DELETE e
Now instead of "RETURN e", use "DELETE e" command to delete Employee node

Step 5 - Click on "Execute" button and observe the results.

Here we can observe that one node is deleted from the Database.
Now check whether the Employee node is deleted from Database or not.
Step 6 - Type the below command and click on Execute command.
MATCH (e: Employee) RETURN e

Here we can observe that Employee node is deleted permanently as zero rows returned by this query.
DELETE 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.
Example
This example demonstrates how to delete a Node and its associate Node and relationship permanently from the Database.
Step 1 - Open Neo4j Data Browser
Step 2 - Type the below command on Data Browser
MATCH (cc:CreditCard)-[r]-(c:Customer)RETURN r

Step 3 - 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.
Step 4 - Type the below command on Data Browser
MATCH (cc: CreditCard)-[rel]-(c:Customer) DELETE cc,c,rel

Step 5 - 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.
Step 6 - Type the below command on Data Browser.
MATCH (cc:CreditCard)-[r]-(c:Customer) RETURN r

Step 7 - Click on "Execute" button and observe the results.

Here we can observe that zero rows returned from the database.