メモ。
=# SELECT attr.attname AS column_name -# FROM pg_attribute AS attr -# INNER JOIN pg_stat_user_tables AS stat -# ON attr.attrelid = stat.relid -# AND stat.schemaname = 'スキーマ名' -# AND stat.relname = 'テーブル名' -# INNER JOIN pg_constraint cons -# ON attr.attnum = ANY (cons.conkey) -# AND cons.contype = 'p' -# AND cons.conrelid = stat.relid;
主キー項目だけが出力されます。