Search code examples
postgresqlapache-age

Is there a way to see all the AGE created tables?


For example in a PostgreSQL database, all the other tables can be seen using

\dt

Or with

SELECT * FROM pg_catalog.pg_tables;

And we know that AGE creates its own label tables, vertex table, edge table.

How can I see those tables, and how can I query for them to view them along with their all columns?


Solution

  • If I got you correctly , we can make use out of the concept that for each graph you create using AGE to work with , AGE creates a separate schema for this graph that has it's related tables , and this schema named exactly the same as the name of your created graph.

    so you can easily select the created tables behind the scenes from the pg_catalog , information_schema tables using the graph name as our schema name.

    we created a graph through age as ,

    SELECT * FROM ag_catalog.create_graph('your_first_graph');
    

    you can go and see it's related tables that created for it behind the scenes in both pg_catalog.pg_tables and information_schema.tables,

    SELECT *
    FROM pg_catalog.pg_tables
    WHERE schemaname = 'your_first_graph';
    

    and ,

    SELECT *
    FROM information_schema.tables
    WHERE table_schema = 'your_first_graph';
    

    And if you aim to query them and observe their entries you can use <your graph name>.<desired table name> and do your queries for example ,

    SELECT *
    FROM your_first_graph._ag_label_edge ;
    

    Actually if you are not interested in detailed table information provided such as tablespace_oid , oid ..etc , you can directly the ag_label to get tables name , type and graph to which they are related as,

    SELECT * FROM ag_label ;