Amazon redshift 每个表的列列表

Amazon redshift 每个表的列列表,amazon-redshift,Amazon Redshift,此查询正在按预期工作: select nspname, relname, max(attnum) as num_cols from pg_attribute a, pg_namespace n, pg_class c where n.oid = c.relnamespace and a.attrelid = c.oid and c.relname not like '%pkey' and n.nspname not like 'pg%' and n.nspname not like 'info

此查询正在按预期工作:

select nspname, relname, max(attnum) as num_cols
from pg_attribute a, pg_namespace n, pg_class c
where n.oid = c.relnamespace and  a.attrelid = c.oid
and c.relname not like '%pkey'
and n.nspname not like 'pg%'
and n.nspname not like 'information%'
group by 1, 2
order by 1, 2;

nspname | relname  | num_cols
--------+----------+----------
public  | category |        4
public  | date     |        8
public  | event    |        6
public  | listing  |        8
public  | sales    |       10
public  | users    |       18
public  | venue    |        5
但是如何获得每个表的列列表呢? 预期产出:

nspname | relname  | num_cols
--------+----------+----------
public  | category | col1, col2, col3, col4
public  | date     | col1, col2, col3, col4 ..., col8
Mysql的group_concat函数将在这里应用

该页上提到的以下查询没有为我返回任何行

select distinct attrelid, rtrim(name), attname, typname
from pg_attribute a, pg_type t, stv_tbl_perm p
where t.oid=a.atttypid and a.attrelid=p.id
and a.attrelid between 100100 and 110000
and typname not in('oid','xid','tid','cid')
order by a.attrelid asc, typname, attname;

确保在搜索路径中包含所有要查看的架构

没有用户id搜索路径中的架构的红移无法显示列。要访问表结构,您可能还需要对架构拥有使用权

set search_path to '$user', public, enterprise;