- 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 - REMOVE Label
Neo4j CQL REMOVE clause
Sometimes based on our client requirements, we need to add or remove properties to/from existing Nodes or Relationships.
We use Neo4j CQL SET clause to add new properties to existing Nodes or Relationships.
We use Neo4j CQL REMOVE clause to remove existing properties of Nodes or Relationships.
Neo4j CQL REMOVE command is used
To remove labels of a Node or a Relationship
To remove properties of a Node or a Relationship
Main Difference between Neo4j CQL DELETE and REMOVE commands:-
DELETE operation is used to delete Nodes and associated Relationships.
REMOVE operation is used to remove labels and properties.
Similarity between Neo4j CQL DELETE and REMOVE commands:-
Both commands should not be used as alone.
Both commands should be used with MATCH Command.
We have already discussed how to remove a property or set of properties of a Node or a Relationship in the previous chapter. We will discuss how to remove a label or set of labels of a Node or a Relationship in this chapter.
To Remove a Label of a Node/Relationship
We can use same syntax to remove a Label or list of Labels of a Node or a Relationship permanently from the Database.
REMOVE a Label clause syntax:
REMOVE <label-name-list>
| S.No. | Syntax Element | Description |
|---|---|---|
| 1. | REMOVE | It is a Neo4j CQL keyword. |
| 2. | <label-name-list> | It is a list of labels to remove it from a Node or a Relationship permanently. |
<label-name-list> syntax:
<node-name>:<label1-name>, <node-name>:<label2-name>, .... <node-name>:<labeln-name>
Syntax Description
| S.No. | Syntax Element | Description |
|---|---|---|
| 1. | <node-name> | It is a name of a Node. |
| 2. | <label-name> | It is a label name of a Node. |
NOTE:-
We should use comma(,) operator to separate the label names list.
We should use colon(:) operator to separate the node names and label name.
Example1:-
This example demonstrates how to remove an unwanted label to a Node 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 (m:Movie) RETURN m
Click on "Execute" button and observe the results.
Click on node to see its properties window.
Here we can observe that four labels are available to a single node.
As per our client requirement, we need to remove "Picture" label to this node
Type below command on Browser and click on Execute button.
MATCH (m:Movie) REMOVE m:Picture
Click on "Execute" button and observe the results.
Here we can observe that one label is removed from node permanently from the Database.
Type the below command on Data Browser
MATCH (m:Movie) RETURN m
Click on "Execute" button and observe the results.
Click on node to see its properties window.
Here we can observe that this node has only three labels :Movie,Cinema,Film from Properties Window. That means our previous command has removed Picture label successfully.