使用Postgres检索Apache-age图中标签关系的OID值。

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

Retrieving OID values for label relations in Apache-age graph using Postgres

问题

我目前正在处理一个Apache-age图,并需要检索图中标签关系的OID值。我正在使用Postgres来管理我的数据库,并尝试查询ag_labels模式,但似乎不包含标签关系的OID值。

到目前为止,我尝试过以下代码:

SELECT oid, relname FROM pg_class WHERE relkind = 'r' AND relname LIKE 'ag_labels_%';

这个查询返回了图中所有标签关系的relname值,但没有OID值。

我还尝试直接查询pg_catalog.pg_class表,但似乎也没有返回标签关系的OID值。

我想知道是否有其他表或模式可以查找Apache-age中标签关系的OID值。任何建议或见解都将不胜感激。

提前感谢!

英文:

I'm currently working on an Apache-age graph and need to retrieve the OID values for the label relations in the graph. I'm using Postgres to manage my database and have tried querying the ag_labels schema, but it doesn't seem to contain the OID values for the label relations.

Here's the code I've tried so far:

SELECT oid, relname FROM pg_class WHERE relkind = 'r' AND relname LIKE 'ag_labels_%';

This query returns the relname values for all label relations in my graph, but not the OID values.

I've also tried querying the pg_catalog.pg_class table directly, but this doesn't seem to return the OID values for the label relations either.

I'm wondering if there's another table or schema I should be looking at to retrieve the OID values for label relations in Apache-age. Any suggestions or insights would be greatly appreciated.

Thanks in advance!

答案1

得分: 0

我不认为有一个单独的查询可以查看所有现有标签的 OID。标签存储在 ag.label 表中,但这个表不包含关于 OID 的信息。您可以尝试首先查询所有标签:

SELECT * FROM ag_label;

然后运行:

SELECT oid, relname FROM pg_class WHERE relkind = 'r';

在返回的行中查找您要查找的标签的名称和 OID。

英文:

I dont think there is a single query you can run to see all the oids of the existing labels. The labels are stored in the ag.label table but that doesn't hold information about the OID. What you could try is first querying for all the labels with


SELECT * FROM ag_label;

and then run


SELECT oid, relname FROM pg_class WHERE relkind = 'r';

and in the returned rows find the names and oids of the labels you are looking for.

答案2

得分: 0

如果你运行以下查询:

SELECT oid, relname FROM pg_class WHERE relkind = 'r';

它将返回类似以下的oid:

postgres=# SELECT oid, relname FROM pg_class WHERE relkind = 'r';
  oid  |         relname         
-------+-------------------------
  2619 | pg_statistic
  1247 | pg_type
 27575 | _ag_label_vertex
 27585 | _ag_label_edge
 35178 | ag_graph
 35190 | ag_label
  3118 | pg_foreign_table
 35771 | _ag_label_vertex
  1260 | pg_authid
 35791 | Person
 35781 | _ag_label_edge
 35800 | RELTYPE
  3429 | pg_statistic_ext_data
  1418 | pg_user_mapping
  6100 | pg_subscription

另一个条件 "relname LIKE 'ag_labels_%'" 可能是你没有得到期望结果的原因。

英文:

If you run the query:

SELECT oid, relname FROM pg_class WHERE relkind = 'r';

It will return oids as well like this:

postgres=# SELECT oid, relname FROM pg_class WHERE relkind = 'r';
  oid  |         relname         
-------+-------------------------
  2619 | pg_statistic
  1247 | pg_type
 27575 | _ag_label_vertex
 27585 | _ag_label_edge
 35178 | ag_graph
 35190 | ag_label
  3118 | pg_foreign_table
 35771 | _ag_label_vertex
  1260 | pg_authid
 35791 | Person
 35781 | _ag_label_edge
 35800 | RELTYPE
  3429 | pg_statistic_ext_data
  1418 | pg_user_mapping
  6100 | pg_subscription

The other condition "relname LIKE 'ag_labels_%'" might be the reason you are not getting the desired results.

答案3

得分: 0

以下是已翻译的内容:

也许您正在寻找以下命令

SELECT oid, relation FROM ag_label;

它返回数据库中所有标签的 OID,类似于以下内容:

  oid   |           relation
--------+------------------------------
 803774 | test_graph._ag_label_vertex
 803787 | test_graph._ag_label_edge
 803799 | test_graph."Person"
 803811 | test_graph."MARRIED_TO"
 803823 | test_graph."PARENT_OF"
 803835 | test_graph."BROTHER_OF"
(6 rows)
英文:

Perhaps you're looking for the command

SELECT oid, relation FROM ag_label;

It returns the OIDs of all the labels in your database, something like this:

  oid   |           relation
--------+------------------------------
 803774 | test_graph._ag_label_vertex
 803787 | test_graph._ag_label_edge
 803799 | test_graph."Person"
 803811 | test_graph."MARRIED_TO"
 803823 | test_graph."PARENT_OF"
 803835 | test_graph."BROTHER_OF"
(6 rows)

答案4

得分: 0

Here is the translated text without the code:

尝试以下步骤:

  1. 打开Apache Age的配置文件。

  2. 其次,找到track-oid并将其打开。要添加它,可以执行以下操作:

    autovacuum = on
    track_oid = on

  3. 现在保存该文件并重新启动服务器以应用更改。

完成上述所有步骤后,您现在可以使用以下查询进行检索:

SELECT oid, relname FROM pg_catalog.pg_class WHERE relkind = 'r' AND relname LIKE 'ag_labels_%';

英文:

Try these steps:

  1. open the configuration file oof apache-age
  2. Secondly find the track-oid and turn it on. And to add it you can do this:

> autovacuum = on

> track_oid = on

  1. Now save that fine and restart the server to apply changes.

After doing all the above steps , you can now use this query for the retrieval.

SELECT oid, relname FROM pg_catalog.pg_class WHERE relkind = 'r' AND relname LIKE 'ag_labels_%';

答案5

得分: 0

你可以运行此查询以检索特定图的所有边和顶点的ID和标签。

SELECT * FROM your_graph_name.your_label_name;
   id        |      properties                                                                                 
-------------+-----------------------------------
844424930131971 | {name: 'A'}
844424930131972 | {name: 'B'}
844424930131973 | {name: 'C'}
(3 rows)
英文:

You can run this query to retrieve id's of all the edges and vertices of a specific graph and label.

SELECT * FROM test."Node";
       id        |      properties                                                                                                                                  
             
-----------------+-----------------------------------------------------------

 844424930131971 | {name: 'A'}
 844424930131972 | {name: 'B'}
 844424930131973 | {name: 'C'}
(3 rows)

"test" is graph name and "Node" is label name. Replace it with you own data.

huangapple
  • 本文由 发表于 2023年5月13日 18:31:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76242253.html
匿名

发表评论

匿名网友

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

确定