0

Is there a way to get all nodes or all relationships or both together in Neo4j? The closest I've seen is the relationships(), for example:

MATCH p = (a)-->(b)-->(c)
WHERE a.name = 'Alice' AND c.name = 'Eskil'
RETURN relationships(p)

However, I'm looking to do something similar to:

SHOW TABLES

Where it would just list everything. Is it possible to do something like that not at the query-level but for an entire database?

David542
  • 104,438
  • 178
  • 489
  • 842
  • Does this answer your question? [neo4j how to return all node labels with Cypher?](https://stackoverflow.com/questions/18398576/neo4j-how-to-return-all-node-labels-with-cypher) – Richard Dec 28 '21 at 03:13
  • @Richard thanks for pointing that out. How do you get the relationships/edges then? – David542 Dec 28 '21 at 03:17
  • 1
    To get a list of [Relationship Types](https://neo4j.com/docs/developer-manual/current/cypher/functions/scalar/#functions-type). – Richard Dec 28 '21 at 03:18
  • 1
    `SHOW TABLES` just list the tables but not the contents. If you want the list of relationship types, you can refer to https://neo4j.com/docs/operations-manual/current/reference/procedures/#procedure_db_relationshiptypes , or you can refer to https://neo4j.com/docs/operations-manual/current/reference/procedures/#procedure_db_schema_visualization to view the db schema – Christophe Willemsen Dec 28 '21 at 15:45

1 Answers1

0

Does this answer your question?

List all nodes

MATCH (n)
RETURN n

List all relationships

MATCH ()-[r]->()
RETURN r

List both

MATCH (s)-[r]->(e)
RETURN s,e,r
Lukasmp3
  • 118
  • 5
  • with distinct. If there are a million nodes of type Person, I want it to return ['Person'] and not 1M items. – David542 Jan 03 '22 at 04:24
  • Ok, I missed that you want to return node labels and relationship types. How about this: `MATCH (n), ()-[r]->() RETURN COLLECT(distinct labels(n)) AS nodeLabels, COLLECT(distinct type(r)) AS relationshipTypes` – Lukasmp3 Jan 03 '22 at 09:55