SELECT col_attr.attname as "ColumnName"
FROM pg_catalog.pg_attribute col_attr
WHERE col_attr.attnum > 0
AND NOT col_attr.attisdropped
AND col_attr.attrelid =
(SELECT cls.oid
FROM pg_catalog.pg_class cls
LEFT JOIN pg_catalog.pg_namespace ns
ON ns.oid = cls.relnamespace
WHERE cls.relname = 'MyTable')
ORDER BY "ColumnName" ASC
通常,使用
information_schema
:这也有效: