Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete/create databases in Neo4j?

Is it possible to create/delete different databases in the graph database Neo4j like in MySQL? Or, at least, how to delete all nodes and relationships of an existing graph to get a clean setup for tests, e.g., using shell commands similar to rmrel or rm?

like image 865
rmv Avatar asked Dec 21 '10 10:12

rmv


People also ask

How do I remove a property from Neo4j?

The REMOVE clause is used to remove properties and labels from graph elements (Nodes or Relationships). DELETE operation is used to delete nodes and associated relationships. REMOVE operation is used to remove labels and properties.

How do I delete a record in Neo4j?

In Neo4j to delete a node or relations between nodes you have to use DELETE clause. To delete any node you need DELETE clause with the MATCH statement, the MATCH statement data will find the specific node and whichever node is matched with the statement that node will be vanished.

How do I delete all relationships in Neo4j?

Deleting Nodes and Relationships Deleting all nodes and relationships in a Neo4j database is very simple. Here is an example that does just that: MATCH (n) DETACH DELETE n; The DETACH keyword specifies to remove or “detach” all relationships from a particular node before deletion.

How do I create a database in Neo4j browser?

x, to create a new database without removing your existing one, you can simply edit the neo4j. conf file in your conf directory of your $NEO4J_HOME . Search for dbms. active_database= , which should have the default value of graph.


2 Answers

You can just remove the entire graph directory with rm -rf, because Neo4j is not storing anything outside that:

rm -rf data/* 

Also, you can of course iterate through all nodes and delete their relationships and the nodes themselves, but that might be too costly just for testing ...

like image 59
Peter Neubauer Avatar answered Oct 26 '22 06:10

Peter Neubauer


even more simple command to delete all nodes and relationships:

MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r 
like image 22
John Bachir Avatar answered Oct 26 '22 05:10

John Bachir