[PostgreSQL]カラム名、カラムコメント取得
SELECT psat.relname AS TABLE_NAME,pa.attname AS COLUMN_NAME,pd.description AS COLUMN_COMMENT FROM pg_stat_all_tables AS psat,pg_description AS pd,pg_attribute AS pa WHERE psat.schemaname = (SELECT schemaname FROM pg_stat_user_tables WHERE relname = 'テーブル名') AND psat.relname = 'テーブル名' AND psat.relid = pd.objoid AND pd.objsubid <> 0 AND pd.objoid = pa.attrelid AND pd.objsubid = pa.attnum ORDER BY pd.objsubid