Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Cypher

You're reading from   Learning Cypher Write powerful and efficient queries for Neo4j with Cypher, its official query language

Arrow left icon
Product type Paperback
Published in May 2014
Publisher
ISBN-13 9781783287758
Length 162 pages
Edition Edition
Arrow right icon
Author (1):
Arrow left icon
Onofrio Panzarino Onofrio Panzarino
Author Profile Icon Onofrio Panzarino
Onofrio Panzarino
Arrow right icon
View More author details
Toc

Deleting data


Cypher provides two clauses to delete data. They are as follows:

  • REMOVE: This clause is used to remove labels and properties from nodes or relationships

  • DELETE: This clause is used to delete nodes and relationships from the database

Removing labels

To remove a label from a node, you must use the REMOVE clause. The syntax is similar to the one for the SET clause, as shown in the following query:

MERGE (b:User {name: "Jack", surname: "Smith"})
REMOVE b:Inactive:MustConfirmEmail

This query removes the labels Inactive and MustConfirmEmail from the node that was matched. Note that we have chained the labels using the colon separator. If the node already doesn't have one or all of the labels specified, this query will not fail; it will only remove the labels it can remove.

Removing properties

The REMOVE clause is the opposite of the SET clause. It can be used to remove a property from a node, as shown in the following query:

MERGE (b:User {name: "Jack", surname: "Smith"})
REMOVE b.age

Anyway...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image