Amazon redshift Amazon红移获取表的标识列列表

Amazon redshift Amazon红移获取表的标识列列表,amazon-redshift,Amazon Redshift,如何在Amazon Redshift中获取表的标识列列表?使用系统的表 谢谢。该表包含有关表和列的信息: select * from pg_table_def where tablename = 't2'; schemaname|tablename|column| type | encoding | distkey |sortkey| notnull ----------+---------+------+---------+----------+---------+-------+--

如何在Amazon Redshift中获取表的标识列列表?使用系统的表

谢谢。

该表包含有关表和列的信息:

select * from pg_table_def where tablename = 't2';
schemaname|tablename|column|  type   | encoding | distkey |sortkey| notnull 
----------+---------+------+---------+----------+---------+-------+---------
public    | t2      | c1   | bigint  | none     | t       |     0 | f
public    | t2      | c2   | integer | mostly16 | f       |     0 | f
public    | t2      | c3   | integer | none     | f       |     1 | t
public    | t2      | c4   | integer | none     | f       |     2 | f
(4 rows)

此外,标准PostgreSQL目录表可供Amazon Redshift用户访问。有关PostgreSQL系统目录的更多信息,请参阅。

,了解如何获取红移数据库中的所有标识列。以下查询已由发布Neil@AWS到AWS红移论坛:

select 
    c.relname, 
    a.attname 
from pg_class c, pg_attribute a, pg_attrdef d 
where c.oid = a.attrelid 
    and c.relkind = 'r' 
    and a.attrelid = d.adrelid 
    and a.attnum = d.adnum 
    and d.adsrc like '%identity%' 
order by 1;

感谢您的回答,但此表未提供有关标识列的任何信息。必须有一个包含此信息的系统表,但我仍然找不到它。标识列是什么意思?主键?它们是红移中的自动递增列。只是一些附加信息:pg_attrdef中的列adsrc包含身份信息,格式为identitytable_id column_index text_表示身份。因此,对于第二列为identity1,1的表id=13123,它将是identity13123,1,'1,1'::text。