Greenplum
-
查询哪个表的分布键🌟 ( Greenplum )
SELECT att.nspname AS 模式名 , att.relname AS 表名 , table_comment AS 表注释 , string_agg (a.attname, '、') AS 分布键 FROM ( SELECT c.oid , obj_description(c.oid) AS table_comment , n.nspname,c.relname,regexp_split_to_table (array_to_string (d.distkey, ' '),' ')::int as attnu FROM gp_distribution_policy d LEFT JOIN pg_class c ON c.oid = d.localoid LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.oid = 'u_dws.opn_label_factory_user_group'::regclass -- '模式名.表名'::regclass ) att LEFT JOIN pg_attribute a ON a.attrelid = att.oid WHERE att.attnu = a.attnum GROUP BY 1,2,3 ;
或者是:
SELECT aaa.oid, aaa.nspname AS "模式名", aaa