From my understanding labels in apacheAGE are stored under the schema ag_labels, and also are separate tables that the vertices and edges are stored. Also every database object inside postgres is holding an oid. What is a way to see the oid’s of the different label relations inside a graph, or in general?
Question posted in PostgreSQL
The official documentation can be found here.
The official documentation can be found here.
3
Answers
You can run the following query to find the OID of labels table
But there may be a situation where more than one graph can have the same labels. In that case, the above query returns multiple OIDs and we can not differentiate which OID belongs to which graph’s label. So, you need to join
pg_class
andpg_namespace
in order to add a check for which graph you need to return the label’s OID.Above you can replace
tbl.relname = '_ag_label_vertex'
ortbl.relname = '_ag_label_edge'
to get the OID of vertices or edges table.To View all the vertexes and their Oids you can use the command
This would return you 2 columns
id
andproperties
.Id is the Oid of a certain Vertex.
And to View all the edges with their ID, Start Id and End ID you can use:
This would return you four columns:
ID
,Start Id
,End ID
andproperties
.In Apache AGE, it is possible to retrieve the object IDs (oids) for various database objects and label relations using the built-in functions. Below are some examples of how this can be achieved:
To retrieve the oids for all tables in the current schema, execute the following query:
This query selects the oid and table name for all regular tables in the pg_class system catalog.
To retrieve the oids for all label relations in the current graph, execute the following query:
This query selects the oid and label name for all label relations in the ag_labels schema.
To retrieve the oid for a specific label relation, execute the following query:
This query selects the oid for the label relation named ‘my_label_relation’.
Note: the above examples assume that the user is connected to the PostgreSQL database where Apache AGE is running, and that the necessary privileges to query the system catalogs are available.