Database Reference
In-Depth Information
But if you run this command, you'll get an error, warning you that the node has relation-
ships. In Neo4j, you can only delete a node if it doesn't have any relationships (either in-
coming or outgoing). To make sure you can delete a node, you need to delete its relation-
ships at the same time, as shown in the following snippet:
Hereyouusethestandardpatterntomatchallrelationshipscomingintoorgoingoutofthe
grace node
, and delete all relationships that start or end at the specified node
.
The output of the delete query doesn't contain any data, but it will show the number of
deleted nodes and relationships:
Nodes deleted: 1
Relationships deleted: 1
Finally, let's take a look at how you can update properties on existing nodes using Cypher.
6.3.3. Updating node and relationship properties
Let'ssayyoumadeamistakewithJohn'syearofbirth,andyouneedtoupdateit.Thecom-
mand to do that would look like this:
You can see that the syntax is very simple: first you select the node to update , then
you use the set command to set the selected property of the node to the new value. If the
property you're setting doesn't already exist, it will be created by this command.
You can specify multiple nodes to add the same property to all of them:
Search WWH ::




Custom Search