The REMOVE clause is used to remove homes and labels from graph elements (Nodes or Relationships).
The most important difference among Neo4j CQL DELETE and REMOVE commands is −
- DELETE operation is used to delete nodes and related relationships.
- REMOVE operation is used to dispose of labels and houses.
Removing a Property
You can eliminate a assets of a node the use of MATCH together with the REMOVE clause.
Syntax
Following is the syntax to put off a assets of a node the usage of the REMOVE clause.
MATCH (node:label{properties . . . . . . . })
REMOVE node.property
RETURN node
Example
Before intending with the instance, create a node named Dhoni as shown underneath.
CREATE (Dhoni:player {name: "MahendraSingh Dhoni", YOB: 1981, POB: "Ranchi"})
Following is a pattern Cypher Query to cast off the above created node the use of the REMOVE clause.
MATCH (Dhoni:player {name: "MahendraSingh Dhoni", YOB: 1981, POB: "Ranchi"})
REMOVE Dhoni.POB
RETURN Dhoni
To execute the above question, carry out the subsequent steps −
Step 1 − Open the Neo4j computer App and start the Neo4j Server. Open the integrated browser app of Neo4j the usage of the URL http://localhost:7474/ as shown within the following screenshot.
Step 2 − Copy and paste the favored question inside the dollar activate and press the play button (to execute the question) highlighted inside the following screenshot.
Result
On executing, you may get the subsequent end result. Here, you could study that the node named POB changed into deleted.
Removing a Label From a Node
Similar to belongings, you may additionally get rid of a label from an current node the use of the remove clause.
Syntax
Following is the syntax to dispose of a label from a node.
MATCH (node:label {properties . . . . . . . . . . . })
REMOVE node:label
RETURN node
Example
Following is a pattern Cypher Query to cast off a label from an existing node the use of the dispose of clause.
MATCH (Dhoni:player {name: "MahendraSingh Dhoni", YOB: 1981, POB: "Ranchi"})
REMOVE Dhoni:player
RETURN Dhoni
To execute the above query, perform the subsequent steps −
Step 1 − Open the Neo4j laptop App and begin the Neo4j Server. Open the integrated browser app of Neo4j the use of the URL http://localhost:7474/ as proven in the following screenshot.
Step 2 − Copy and paste the preferred question inside the dollar prompt and press the play button (to execute the query) highlighted within the following screenshot.
Result
On executing, you will get the subsequent result. Here, you can examine that the label was deleted from the node.
Removing Multiple Labels
You also can remove more than one labels from an present node.
Syntax
Following is the syntax to put off more than one labels from a node.
MATCH (node:label1:label2 {properties . . . . . . . . })
REMOVE node:label1:label2
RETURN node
Example
Before intending with the instance, create a node Ishant as shown under.
CREATE (Ishant:player:person {name: "Ishant Sharma", YOB: 1988, POB: "Delhi"})
Following is a sample Cypher Query to put off more than one labels from a node.
MATCH (Ishant:player:person {name: "Ishant Sharma", YOB: 1988, POB: "Delhi"})
REMOVE Ishant:player:person
RETURN Ishant
To execute the above query, perform the following steps −
Step 1 − Open the Neo4j computer App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown inside the following screenshot.
Step 2 − Copy and paste the favored query within the dollar prompt and press the play button (to execute the query) highlighted within the following screenshot.
Result
On executing, you may get the following result. Here, you can look at that the desired labels have been deleted from the node.