跳到内容
观澜涉川 · 札记EN

PostgreSQL

· 约 1 分钟阅读

获取数据表和字段的元数据

SELECT
table_schema,
table_name,
column_name,
data_type,
col_description((table_schema || '.' || table_name)::regclass::oid, ordinal_position) as column_comment
FROM
information_schema.columns
WHERE
table_schema NOT IN ('information_schema', 'pg_catalog')
ORDER BY
table_schema,
table_name,
ordinal_position;