ag_catalog
contains all the metadata used by Apache AGE. ag_graphs
is contained in ag_catalog
and it stores the information/namespaces about all the graphs present in the database. ag_label
stores the data. So to fetch all the tables, you do:
AG_CATALOG包含Apacheage使用的所有元数据。AG_GRAPS包含在AG_CATALOG中,它存储有关数据库中所有图的信息/名称空间。AG_LABEL存储数据。因此,要获取所有表,您需要执行以下操作:
SELECT * FROM ag_label;
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.
如果我没弄错的话,我们可以利用这样一个概念,即对于您使用AGE创建的每个图形,AGE为该图形创建一个单独的模式,该模式具有其相关的表,并且该模式的名称与您创建的图形的名称完全相同。
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.
因此,您可以使用图表名称作为模式名称,轻松地从PG_CATALOG、INFORMATION_SCHEMA表中选择幕后创建的表。
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
,
您可以在pg_Catalog.pg_Tables和INFORMATION_SCHEMA表中查看在幕后为其创建的相关表,
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,
实际上,如果您对提供的表的详细信息不感兴趣,如TABESPACE_OID、OID等,您可以直接使用ag_Label来获取它们所关联的表名、类型和图,
SELECT * FROM ag_label ;
You can use the following query:
您可以使用以下查询:
SELECT * FROM ag_label;
to get a similar result in AGE, for example:
要在年龄上获得类似的结果,例如:
name | graph | id | kind | relation | seq_name
------------------+-------+----+------+------------------------------+-------------------------
_ag_label_vertex | 16944 | 1 | v | "Demo"._ag_label_vertex | _ag_label_vertex_id_seq
_ag_label_edge | 16944 | 2 | e | "Demo"._ag_label_edge | _ag_label_edge_id_seq
Person | 16944 | 3 | v | "Demo"."Person" | Person_id_seq
REL | 16944 | 4 | e | "Demo"."REL" | REL_id_seq
KNOWS | 16944 | 5 | e | "Demo"."KNOWS" | KNOWS_id_seq
where the kind
column tells you if it is a vertex v
or an edge e
, with their labels shown in the name
column.
其中,Kind列告诉您它是顶点v还是边e,它们的标签显示在名称列中。
Here is a regress test to check the different variations of the function.
下面是一个回归测试,用来检查函数的不同变化。
Table ag_graph
stores names and namespaces of all the graphs.
表aggraph存储所有图的名称和命名空间。
SELECT * FROM ag_graph;
Table ag_label
stores all the data (labels, relations, sequences etc).
表AG_LABEL存储所有数据(标签、关系、序列等)。
SELECT * FROM ag_label;
To see all the vertices and edges:
要查看所有顶点和边,请执行以下操作:
SELECT * FROM <graph_name>._ag_label_vertex;
SELECT * FROM <graph_name>._ag_label_edge;
To see all vertices and edges with a specific label:
要查看具有特定标签的所有顶点和边,请执行以下操作:
SELECT * FROM <graph_name>."<label_name>";
SELECT * FROM ag_label;
gets this done.
SELECT*FROW AG_LABEL;完成此操作。
However, remember to SET search_path
before running the query else simply run SELECT * FROM ag_catalog.ag_label;
.
但是,请记住在运行查询之前设置Search_PATH,否则只需运行SELECT*from ag_Catalog.ag_Label;即可。
You could use the following query to view the table
您可以使用以下查询来查看该表
SELECT oid, * FROM ag_catalog.ag_label;
Table Results would be as follow:
表结果如下:
oid | name | graph | id | kind | relation |
----------+-------------------+-------+----+------+--------------------------+
16950 | _age_label_vertex | 16937 | 1 | v | database.ag_label_vertex |
16963 | _age_label_edge | 16937 | 2 | e | database.ag_label_edge |
16975 | Country | 16937 | 3 | v | database."Country" |
16987 | City | 16937 | 4 | v | database."City" |
16999 | has_city | 16937 | 5 | e | database.has_city |
where:
其中:
- oid : An unique Postgres identifier per label ;
- name: The name of the label ;
- graph: Oid from ag_graph ;
- id : The id for the label, it is unique for each graph ;
- kind : Shows if it is a vertex “v” or an edge “e” ;
- relation : Schema qualified name of table name for label.
Reference:
https://matheusfarias03.github.io/AGE-quick-guide/
参考文献:https://matheusfarias03.github.io/AGE-quick-guide/
You can refer to this guide Guide
你可以参考这本指南
For creating a graph, you can use the create_graph function, located in the ag_catalog namespace:
要创建图形,可以使用位于ag_Catalog名称空间中的create_graph函数:
SELECT * FROM ag_catalog.create_graph('graph_name');
The data for a label is stored in the ag_label and use can use this query to view the available labels:
标签的数据存储在ag_Label中,用户可以使用以下查询来查看可用的标签:
SELECT oid, * FROM ag_catalog.ag_label;
where, oid : An unique Postgres identifier per label.
其中,oid:每个标签的唯一Postgres标识符。
Once you've loaded AGE
and set your search path to ag_catalog
, you can use this query to display all the labels.
SELECT * FROM ag_label;
and this will display all the nodes and vertices in the ag_catalog.
You could also use SELECT * FROM ag_graph;
to display all the graph names.
加载AGE并将搜索路径设置为agCATALOG后,可以使用此查询显示所有标签。选择*from ag_LABEL,这将显示AG_CATALOG中的所有节点和顶点。您还可以使用SELECT*from ag_graph;来显示所有的图形名称。
In PostgreSQL, the tables created by the AGE extension are stored in ag_catalog schema.
在PostgreSQL中,由AGE扩展创建的表存储在ag_CATALOG模式中。
for example:
例如:
to see all the tables in the ag_catalog schema use the following query:
要查看AG_CATALOG模式中的所有表,请使用以下查询:
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'ag_catalog';
to view the columns of a particular table in ag_catalog you have to replace your table with the actual name of the table you want to view:
要查看AG_CATALOG中特定表的列,您必须用要查看的表的实际名称替换您的表:
SELECT column_name, data_type
FROM information_schema.columns
WHERE table_schema = 'ag_catalog' AND table_name = 'your_table_name';
if you want to view all the tables and their columns together, you can use the following query:
如果要一起查看所有表及其列,可以使用以下查询:
SELECT t.table_name, c.column_name, c.data_type
FROM information_schema.tables t
JOIN information_schema.columns c ON t.table_name = c.table_name AND t.table_schema = c.table_schema
WHERE t.table_schema = 'ag_catalog';
ag_graph
stores the list of all the graphs, and ag_label
stores the list of all the additional tables created by Apache AGE.
ag_graph存储所有图的列表,ag_label存储Apache AGE创建的所有附加表的列表。
SELECT * FROM ag_graph;
This is the sample output of the above code.
这是上述代码的样例输出。
demodb=# SELECT * FROM ag_graph;
graphid | name | namespace
---------+---------------------+---------------------
66676 | graph | graph
137025 | bitnine_global_inic | bitnine_global_inic
137077 | test_graph | test_graph
75557 | age_graph | age_graph
(4 rows)
.
.
SELECT * FROM ag_label;
This is the sample output of the above code.
这是上述代码的样例输出。
demodb=# SELECT * FROM ag_label;
name | graph | id | kind | relation | seq_name
------------------+--------+----+------+--------------------------------------+-------------------------
_ag_label_vertex | 66676 | 1 | v | graph._ag_label_vertex | _ag_label_vertex_id_seq
_ag_label_edge | 66676 | 2 | e | graph._ag_label_edge | _ag_label_edge_id_seq
student | 66676 | 8 | v | graph.student | student_id_seq
_ag_label_vertex | 75557 | 1 | v | age_graph._ag_label_vertex | _ag_label_vertex_id_seq
_ag_label_edge | 75557 | 2 | e | age_graph._ag_label_edge | _ag_label_edge_id_seq
_ag_label_vertex | 137025 | 1 | v | bitnine_global_inic._ag_label_vertex | _ag_label_vertex_id_seq
_ag_label_edge | 137025 | 2 | e | bitnine_global_inic._ag_label_edge | _ag_label_edge_id_seq
Country | 137025 | 3 | v | bitnine_global_inic."Country" | Country_id_seq
City | 137025 | 4 | v | bitnine_global_inic."City" | City_id_seq
has_city | 137025 | 5 | e | bitnine_global_inic.has_city | has_city_id_seq
_ag_label_vertex | 137077 | 1 | v | test_graph._ag_label_vertex | _ag_label_vertex_id_seq
_ag_label_edge | 137077 | 2 | e | test_graph._ag_label_edge | _ag_label_edge_id_seq
(12 rows)
In the above output, rows with names starting without an underscore are user-generated labels.
在上面的输出中,名称以下划线开头的行是用户生成的标签。
You can query from the specific labels using the relation name given in relation
column.
您可以使用关系列中给出的关系名称从特定标签进行查询。
SELECT * FROM graph._ag_label_vertex;
SELECT * FROM bitnine_global_inic."City";
To see the tables and to query them in the column mode yo can follow the following steps:
要查看这些表并以列模式查询它们,YO可以执行以下步骤:
- List the Specific tables in and store them as graph data.
- Use the '\d' in sql to view columns of a specific AGE table.
- View all columns is the related tables in the current schema.
To be able to see all the AGE tables created,You can us the following command:
为了能够查看创建的所有AGE表,您可以使用以下命令:
SELECT * FROM ag_catalog.ag_label;
here is a sample output result to show you all the tables created:
下面是一个示例输出结果,向您展示创建的所有表:
name | graph | id | kind | relation | seq_name
------------------+-------+----+------+-----------------------------+-------------------------
_ag_label_vertex | 41520 | 1 | v | test_graph._ag_label_vertex | _ag_label_vertex_id_seq
_ag_label_edge | 41520 | 2 | e | test_graph._ag_label_edge | _ag_label_edge_id_seq
Person | 41520 | 3 | v | test_graph."Person" | Person_id_seq
coworkers | 41520 | 4 | e | test_graph.coworkers | coworkers_id_seq
managers | 41520 | 5 | e | test_graph.managers | managers_id_seq
engineers | 41520 | 6 | e | test_graph.engineers | engineers_id_seq
reports | 41520 | 7 | e | test_graph.reports | reports_id_seq
(7 rows)
更多回答
我是一名优秀的程序员,十分优秀!