title: Neo4j Create new Database from Query Result
body: <h3>Is there a way in Neo4j to create a new Database, that gets populated by some query data from another database?</h3>
  <p>For Example, I have a Database that consists of the following Nodes:
  <a href="https://i.stack.imgur.com/epmv4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/epmv4.png" alt="enter image description here" /></a></p>
  <p>The Graph from above can be created via the following statement:
  (In this example imagine the graph is the full database)</p>
  <pre><code>CREATE (n0:Node)
  CREATE (n1:Node)
  CREATE (n2:Node {capital_letter: &quot;A&quot;})
  CREATE (n3:Node)
  CREATE (n4:Node)
  CREATE (n5:Node)
  CREATE (n6:Node {capital_letter: &quot;B&quot;})
  CREATE (n7:Node)
  CREATE (n8:Node {capital_letter: &quot;A&quot;})
  CREATE (n9:Node {capital_letter: &quot;B&quot;})
  CREATE (n10:Node)
  CREATE (n2)-[:TRANSACTIONS]-&gt;(n0)
  CREATE (n2)-[:TRANSACTIONS]-&gt;(n1)
  CREATE (n2)-[:TRANSACTIONS]-&gt;(n3)
  CREATE (n3)-[:TRANSACTIONS]-&gt;(n6)
  CREATE (n4)-[:TRANSACTIONS]-&gt;(n2)
  CREATE (n4)-[:TRANSACTIONS]-&gt;(n7)
  CREATE (n6)-[:TRANSACTIONS]-&gt;(n5)
  </code></pre>
  <p><strong>MY QUESTION</strong>:</p>
  <p><strong>Is there is any way to query for a sub-graph of these nodes, to then put them into a new persistent database?</strong></p>
  <p>For example I would like to build a new Database, with all A and B nodes, aswell as all their neighbours and all the relationships between them.</p>
  <p>I imagine something like the following:</p>
  <pre><code>INSERT INTO NEW DATABASE &quot;NEW DB&quot;
  MATCH (a {capital_letter: &quot;A&quot;})
  OPTIONAL MATCH (a {capital_letter: &quot;A&quot;})-[t1]-(a_neighbours)
  MATCH (b {capital_letter: &quot;B&quot;})
  OPTIONAL MATCH (b {capital_letter: &quot;B&quot;})-[t2]-(b_neighbours)
  RETURN a, b, t1, t2, a_neighbours, b_neighbours
  </code></pre>
  <p><strong>Of course the above statement does not work</strong>, but is there <em>any</em> possibility in Neo4J to construct a Database like so?</p>
  <p>Please note, that my Database consists of 100Mio+ Nodes so only a feasable approach is really helpful.</p>
  <p>**My last resort would be to just query the data, export it to .csv and then construct a new database via the neo4j-admin tool <a href="https://neo4j.com/docs/operations-manual/current/tutorial/neo4j-admin-import/" rel="nofollow noreferrer">https://neo4j.com/docs/operations-manual/current/tutorial/neo4j-admin-import/</a></p>
  <p>I just want to know if there is another (maybe quicker) way.</p>