cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to reset the graph data?

I am new to neo4j,when I studied the course of 2-c-add-intermediate-node,I did some wrong steps,the data changed,when I clicked "check database" button,it shows "Try again......".How to reset the graph data?

6 REPLIES 6

Hello! Are you talking about the Movies Graph Example database?


The other day I did something to duplicate the entire database (can't remember what), using desktop. I decided to delete that db and reinstall it. I used this github link to find scripts/movies.cypher and imported it into desktop. This might be different if you're using Sandbox or Aura? There is probably another way to reset it to the initial database.


Also, I have had luck putting things under Newbie Questions. Hope this helps!

@82796779

if you want to delete all nodes/all relationships, and still keep all index and constraint definitions you can un

match (n) detach delete n;

which walks all nodes, detaches all relationship from said node, and then deletes said node.

Note if you are working with a graph which has for example 100k nodes you might want to consider batching this and thus perform the deletes in smaller numbers and so as to avoid a single txn which is committing 100k records etc which might lead to a out of memory. To delete in batches and with Neo4j 4.4.x forward see CALL {} (subquery) - Neo4j Cypher Manual and the section with

MATCH (n)
CALL {
  WITH n
  DETACH DELETE n
} IN TRANSACTIONS OF 2 ROWS

but you probably could increase IN TRANSACTIONS OF 2 ROWS to IN TRANSACTIONS OF 10000 ROWS

Hello @82796779,

Not sure if you were able you were able to complete the challenge on creating intermediate nodes.
If your sandbox terminated and you re-enter the challenge, the sandbox will be automatically reset to where it should be for the beginning of the challenge.

Let us know if you need more help.

Elaine

Hi all, I understand that running: 

match (n) detach delete n;

will delete all nodes and relationships - but if I want to reset everything back to the beginning (reset all constraints and load data clauses) how can I do this?
Ideally, I just want a blank graph and start again (maintaining only the files in my import folder and APOC and GDS plugins). Cheers

This will totally reset data and indexes/constraints:

CREATE OR REPLACE DATABASE neo4j

@elaine_rosenber Thank you !