How to delete/create databases in Neo4j?

前端 未结 12 1174
既然无缘
既然无缘 2020-12-12 11:52

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 t

相关标签:
12条回答
  • 2020-12-12 12:24

    From Neo4j 2.3,

    We can delete all nodes with relationships,

    MATCH (n)
    DETACH DELETE n
    

    Currently there is no any option to create multiple databases in Noe4j. You need to make multiple stores of Neo4j data. See reference.

    0 讨论(0)
  • 2020-12-12 12:24

    As of version 3 I believe it is now possible to create separate database instances and thus their location is slightly different.

    Referring to:https://neo4j.com/developer/guide-import-csv/

    The --into retail.db is obviously the target database, which must not contain an existing database.

    On my Ubuntu box the location is in:

    /var/lib/neo4j/data/databases where I currently see only graph.db which I believe must be the default.

    0 讨论(0)
  • 2020-12-12 12:28

    quick and dirty way that works fine:

    bin/neo4j stop
    rm -rf data/
    mkdir data
    bin/neo4j start
    
    0 讨论(0)
  • 2020-12-12 12:28

    Easiest answer is: NO

    The best way to "start over" is to

    • move to another empty data folder

    or

    • close Neo4j completely
    • empty the old data folder
    • restart Neo4j and set the empty folder as the data folder

    There is a way to delete all nodes and relationships (as described here)

    MATCH (n)
    OPTIONAL MATCH (n)-[r]-()
    DELETE n,r
    
    0 讨论(0)
  • 2020-12-12 12:35

    even more simple command to delete all nodes and relationships:

    MATCH (n)
    OPTIONAL MATCH (n)-[r]-()
    DELETE n,r
    
    0 讨论(0)
  • 2020-12-12 12:36

    In Neo4j 2.0.0 the ? is no longer supported. Use OPTIONAL MATCH instead:

    START n=node(*)
    OPTIONAL MATCH (n)-[r]-()
    delete n,r;
    
    0 讨论(0)
提交回复
热议问题