Monday 19 July 2021

Neo4j: Delete all the nodes

Syntax to delete all the nodes

MATCH (n) DETACH DELETE (n)

 

Follow below steps to test above query.

 

Step 1: Open neo4j browser by hitting following url in browser.

http://localhost:7474/browser/

 


Step 2: Execute following queries in $ prompt to create 3 nodes.

CREATE (Sailaja:Person{name: "Sailaja", age: 32, city: "Hyderabad", female: true})

CREATE (RamaKrishna:Person{name: "Rama Krishna", age: 32, city: "Bangalore", male: true})

CREATE (SivaKrishna:Person{name: "Siva Krishna", age: 32, city: "Amaravati", male: true})

 

Step 3: Confirm that the nodes are created by executing below command.

MATCH (n) RETURN n

 


Step 4: Delete all the nodes by executing below command.

MATCH (n) DETACH DELETE (n)

 


Step 5: Confirm that the nodes are deleted by executing below command.

MATCH (n) return n

 



Previous                                                    Next                                                    Home

No comments:

Post a Comment