PostgreSQL

2024-05-23#postgresql

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

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;

加载中...