【发布时间】:2020-01-09 01:32:10
【问题描述】:
所以我想把一些价值观放在一起,因为它们有相同的受让人。 但不幸的是,我找不到正确的查询。
这是基本查询(所以,它有效,但由于“privilege_type”而有很多行):
SELECT
table_schema,
table_name,
grantee,
privilege_type
FROM
information_schema.role_table_grants
WHERE
table_schema='public';
结果: https://image.noelshack.com/fichiers/2019/36/5/1567753951-capture.png
所以现在我只想通过“受让人”制作一行。因此,我需要将“privilege_type”的所有值放入每个“被授权人”的 ARRAY 中。
我试过了,但是不行:
SELECT
table_schema,
table_name,
grantee,
ARRAY(SELECT privilege_type
FROM
information_schema.role_table_grants
GROUP BY grantee) as privileges
FROM
information_schema.role_table_grants
WHERE
table_schema='public';
我该怎么做...? 所以我只能得到(例如上一张图片)2行...... 实在看不懂……
【问题讨论】:
标签: sql arrays postgresql information-schema