有没有一种方法可以查看所有已创建的 AGE 表格?

huangapple go评论62阅读模式
英文:

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

问题

例如,在PostgreSQL数据库中,可以使用以下命令查看所有其他表格:

\dt

或者使用以下命令:

SELECT * FROM pg_catalog.pg_tables;

我们知道AGE会创建自己的标签表、顶点表和边表。

我如何查看这些表格,以及如何查询它们以查看它们以及它们的所有列?

英文:

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?

答案1

得分: 2

ag_catalog 包含了Apache AGE使用的所有元数据。ag_graphs 包含在 ag_catalog 中,它存储了数据库中所有图形的信息/命名空间。ag_label 存储数据。因此,要获取所有表格,您可以执行以下操作:

SELECT * FROM ag_label;
英文:

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:

SELECT * FROM ag_label;

答案2

得分: 1

您可以使用以下查询:

SELECT * FROM ag_label;


在AGE中获得类似的结果,例如:

   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


其中`kind`列告诉您它是一个顶点`v`还是一条边`e`,它们的标签显示在`name`列中。

[这里是一个回归测试](https://github.com/apache/age/blob/88ead70e9bdc8961c25717890433df5cb0acd967/regress/expected/catalog.out),可以检查该函数的不同变体。
英文:

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.

Here is a regress test to check the different variations of the function.

答案3

得分: 1

如果我理解正确,我们可以利用 AGE 创建图时的概念,为每个使用 AGE 创建的图创建一个单独的模式,该模式与您创建的图的名称完全相同,其中包括与之相关的表格。

因此,您可以在后台使用图名称作为模式名称,轻松选择所创建的表格,从 pg_cataloginformation_schema 表格中获取相关信息。

我们通过 AGE 创建了一个图,如下所示:

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

您可以前往查看在后台为其创建的相关表格,分别位于 pg_catalog.pg_tablesinformation_schema.tables 中:

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

以及

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

如果您打算查询它们并观察其条目,您可以使用 <您的图名称>.<所需表格名称> 进行查询,例如:

SELECT *
FROM your_first_graph._ag_label_edge;

实际上,如果您对提供的详细表格信息不感兴趣,比如 tablespace_oid、oid 等,您可以直接使用 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.

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(&#39;your_first_graph&#39;);

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 = &#39;your_first_graph&#39;;

and ,

SELECT *
FROM information_schema.tables
WHERE table_schema = &#39;your_first_graph&#39;;

And if you aim to query them and observe their entries you can use &lt;your graph name&gt;.&lt;desired table name&gt; 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 ;

答案4

得分: 1

表格 ag_graph 存储了所有图的名称和命名空间。

从 ag_graph 中选择所有内容;

表格 ag_label 存储了所有数据(标签、关系、序列等)。

从 ag_label 中选择所有内容;

要查看所有顶点和边:

从 <graph_name>._ag_label_vertex 中选择所有内容;
从 <graph_name>._ag_label_edge 中选择所有内容;

要查看具有特定标签的所有顶点和边:

从 <graph_name>.<label_name> 中选择所有内容;
英文:

Table ag_graph stores names and namespaces of all the graphs.

SELECT * FROM ag_graph;

Table ag_label stores all the data (labels, relations, sequences etc).

SELECT * FROM ag_label;

To see all the vertices and edges:

SELECT * FROM &lt;graph_name&gt;._ag_label_vertex;
SELECT * FROM &lt;graph_name&gt;._ag_label_edge;

To see all vertices and edges with a specific label:

SELECT * FROM &lt;graph_name&gt;.&quot;&lt;label_name&gt;&quot;;

答案5

得分: 1

SELECT * FROM ag_label; 完成此操作。

但请记住在运行查询之前设置 search_path,否则只需运行 SELECT * FROM ag_catalog.ag_label;

英文:

SELECT * FROM ag_label; gets this done.

However, remember to SET search_path before running the query else simply run SELECT * FROM ag_catalog.ag_label;.

答案6

得分: 1

您可以使用以下查询来查看表格:

SELECT oid, * FROM ag_catalog.ag_label;

表格结果如下:

      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        |

其中:

  • oid:每个标签的唯一的Postgres标识符;
  • name:标签的名称;
  • graph:来自ag_graph的Oid;
  • id:标签的ID,对于每个图形都是唯一的;
  • kind:显示它是顶点“v”还是边缘“e”;
  • relation:标签的表格名称的模式限定名称。

参考链接:
https://matheusfarias03.github.io/AGE-quick-guide/

英文:

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.&quot;Country&quot;       |
   16987  | City              | 16937 |  4 | v    | database.&quot;City&quot;          |
   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/

答案7

得分: 0

你可以参考这个指南 Guide

创建图表时,您可以使用位于ag_catalog命名空间中的create_graph函数:

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

标签的数据存储在ag_label中,您可以使用以下查询查看可用的标签:

SELECT oid, * FROM ag_catalog.ag_label;
其中,oid:每个标签的唯一Postgres标识符
英文:

You can refer to this guide Guide

For creating a graph, you can use the create_graph function, located in the ag_catalog namespace:

SELECT * FROM ag_catalog.create_graph(&#39;graph_name&#39;);

The data for a label is stored in the ag_label and use can use this query to view the available labels:

SELECT oid, * FROM ag_catalog.ag_label;

where, oid : An unique Postgres identifier per label.

答案8

得分: 0

你加载了 AGE 并将搜索路径设置为 ag_catalog 后,可以使用以下查询来显示所有标签。
SELECT * FROM ag_label; 这将显示在 ag_catalog 中的所有节点和顶点。
你也可以使用 SELECT * FROM ag_graph; 来显示所有图的名称。

英文:

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.

答案9

得分: 0

在 PostgreSQL 中,由 AGE 扩展创建的表存储在 ag_catalog 模式中。

例如:

要查看 ag_catalog 模式中的所有表,请使用以下查询:

SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'ag_catalog';

要查看 ag_catalog 中特定表的列,您需要将您的表名替换为要查看的实际表名:

SELECT column_name, data_type
FROM information_schema.columns
WHERE table_schema = 'ag_catalog' AND table_name = 'your_table_name';

如果您想要同时查看所有表及其列,可以使用以下查询:

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';
英文:

In PostgreSQL, the tables created by the AGE extension are stored in ag_catalog schema.

for example:

to see all the tables in the ag_catalog schema use the following query:

SELECT table_name
FROM information_schema.tables
WHERE table_schema = &#39;ag_catalog&#39;;

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:

SELECT column_name, data_type
FROM information_schema.columns
WHERE table_schema = &#39;ag_catalog&#39; AND table_name = &#39;your_table_name&#39;;

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 = &#39;ag_catalog&#39;;

答案10

得分: 0

ag_graph 存储了所有图形的列表,ag_label 存储了由 Apache AGE 创建的所有附加表的列表。

SELECT * FROM ag_graph;
这是上述代码的示例输出。

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;
这是上述代码的示例输出。

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.&quot;Country&quot;        | Country_id_seq
 City             | 137025 |  4 | v    | bitnine_global_inic.&quot;City&quot;           | 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)

在上述输出中,名称以下划线开头的行是用户生成的标签。

您可以使用 relation 列中给定的关系名称从特定标签查询。

SELECT * FROM graph._ag_label_vertex;
SELECT * FROM bitnine_global_inic."City";
英文:

ag_graph stores the list of all the graphs, and ag_label stores the list of all the additional tables created by 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.&quot;Country&quot;        | Country_id_seq
 City             | 137025 |  4 | v    | bitnine_global_inic.&quot;City&quot;           | 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.&quot;City&quot;;

答案11

得分: 0

以下是已翻译的内容:

要查看表格并以列模式查询它们,您可以按照以下步骤操作:

  1. 列出特定表格并将它们存储为图形数据。
  2. 使用SQL中的'\d'来查看特定AGE表格的列。
  3. 查看当前模式中相关表格的所有列。
英文:

To see the tables and to query them in the column mode yo can follow the following steps:

  1. List the Specific tables in and store them as graph data.
  2. Use the '\d' in sql to view columns of a specific AGE table.
  3. View all columns is the related tables in the current schema.

答案12

得分: 0

AGE与PostgreSQL兼容。因此,您也可以运行dt命令来检查AGE创建的表。
在这里,您可以看到我已经创建了一个名为demodb的数据库,并在其中创建了一个图形演示。在运行命令\dt之后,以下是输出。

现在,要检查AGE创建的表,即顶点表和边表,您可以运行以下命令。

SELECT * FROM demo._ag_label_vertex;

以及对于_ag_label_edge。

以下是上述命令的结果。

希望有所帮助!

英文:

AGE is compatible with PostgreSQL. So, you can also run dt command to check the table created by AGE.
Here you can see i have created a demodb and a graph demo in it. And after running the command \dt here is the output.有没有一种方法可以查看所有已创建的 AGE 表格?

Now to check the table created by AGE i.e., vertex and edge table you can run the commands.

SELECT * FROM demo._ag_label_vertex;

And same for _ag_label_edge.

Here is the result of the above commands.
有没有一种方法可以查看所有已创建的 AGE 表格?

Hope it helped!

答案13

得分: -1

为了能够查看所有创建的AGE表格,您可以使用以下命令:

SELECT * FROM ag_catalog.ag_label;

以下是一个示例输出结果,显示了所有创建的表格:

      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."&quot;Person&quot;         | 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)
英文:

To be able to see all the AGE tables created,You can us the following command:

SELECT * FROM ag_catalog.ag_label;

here is a sample output result to show you all the tables created:

<pre> 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.&quot;Person&quot; | 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)
</pre>

huangapple
  • 本文由 发表于 2023年6月30日 02:10:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76583627.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定