Neo4j 简明教程
Neo4j - Remove Clause
REMOVE 子句用于从图元素(节点或关系)中移除属性和标签。
The REMOVE clause is used to remove properties and labels from graph elements (Nodes or Relationships).
Neo4j CQL DELETE 和 REMOVE 命令之间的主要区别是 −
The main difference between Neo4j CQL DELETE and REMOVE commands is −
-
DELETE operation is used to delete nodes and associated relationships.
-
REMOVE operation is used to remove labels and properties.
Removing a Property
你可以使用 MATCH 和 REMOVE 子句来删除节点的属性。
You can remove a property of a node using MATCH along with the REMOVE clause.
Syntax
以下是使用 REMOVE 子句删除节点属性的语法。
Following is the syntax to remove a property of a node using the REMOVE clause.
MATCH (node:label{properties . . . . . . . })
REMOVE node.property
RETURN node
Example
在继续执行示例之前,创建一个名为 Dhoni 的节点,如下所示。
Before proceeding with the example, create a node named Dhoni as shown below.
CREATE (Dhoni:player {name: "MahendraSingh Dhoni", YOB: 1981, POB: "Ranchi"})
以下是使用 REMOVE 子句删除以上创建的节点的示例 Cypher 查询。
Following is a sample Cypher Query to remove the above created node using the REMOVE clause.
MATCH (Dhoni:player {name: "MahendraSingh Dhoni", YOB: 1981, POB: "Ranchi"})
REMOVE Dhoni.POB
RETURN Dhoni
执行上述查询,执行以下步骤:
To execute the above query, carry out the following steps −
Step 1 - 打开 Neo4j Desktop App 并启动 Neo4j Server。使用 URL http://localhost:7474/ 打开 Neo4j 的内置浏览器应用,如下面的屏幕截图所示。
Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot.

Step 2 - 在美元提示符中复制并粘贴所需的查询,并按播放按钮(执行查询)突出显示在下面的屏幕截图中。
Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot.

Removing a Label From a Node
类似于属性,你也可以使用 remove 子句从现有节点中删除标签。
Similar to property, you can also remove a label from an existing node using the remove clause.
Syntax
以下是用于从节点中删除标签的语法。
Following is the syntax to remove a label from a node.
MATCH (node:label {properties . . . . . . . . . . . })
REMOVE node:label
RETURN node
Example
以下是使用 remove 子句从现有节点中删除标签的示例 Cypher 查询。
Following is a sample Cypher Query to remove a label from an existing node using the remove clause.
MATCH (Dhoni:player {name: "MahendraSingh Dhoni", YOB: 1981, POB: "Ranchi"})
REMOVE Dhoni:player
RETURN Dhoni
执行上述查询,执行以下步骤:
To execute the above query, carry out the following steps −
Step 1 - 打开 Neo4j Desktop App 并启动 Neo4j Server。使用 URL http://localhost:7474/ 打开 Neo4j 的内置浏览器应用,如下面的屏幕截图所示。
Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot.

Step 2 - 在美元提示符中复制并粘贴所需的查询,并按播放按钮(执行查询)突出显示在下面的屏幕截图中。
Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot.

Removing Multiple Labels
你也可以从现有节点中删除多个标签。
You can also remove multiple labels from an existing node.
Syntax
以下是从节点中删除多个标签的语法。
Following is the syntax to remove multiple labels from a node.
MATCH (node:label1:label2 {properties . . . . . . . . })
REMOVE node:label1:label2
RETURN node
Example
在继续执行示例之前,创建一个称为 Ishant 的节点,如下所示。
Before proceeding with the example, create a node Ishant as shown below.
CREATE (Ishant:player:person {name: "Ishant Sharma", YOB: 1988, POB: "Delhi"})
以下是从节点中删除多个标签的示例 Cypher 查询。
Following is a sample Cypher Query to remove multiple 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, carry out the following steps −
Step 1 - 打开 Neo4j Desktop App 并启动 Neo4j Server。使用 URL http://localhost:7474/ 打开 Neo4j 的内置浏览器应用,如下面的屏幕截图所示。
Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot.

Step 2 - 在美元提示符中复制并粘贴所需的查询,并按播放按钮(执行查询)突出显示在下面的屏幕截图中。
Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot.
