select
d.datname as database_name,
n.nspname as schema_name,
c.relname as table_name,
case
when c.relstorage = 'o' then 'orc'
when c.relstorage = 'p' then 'parquet'
when c.relstorage = 'm' then 'magmaap'
when c.relstorage = 'x' then 'external'
when c.relstorage = 'v' then 'virtual'
when c.relstorage = 'r' then 'hudi_orc'
when c.relstorage = 'q' then 'hudi_parquet'
when c.relstorage = 'f' then 'foreign'
when c.relstorage = 'a' then 'aorows'
when c.relstorage = 'h' then 'heap'
else 'unknown' end as table_type,
t.attname as column_name,
tp.typname as column_type,
col_description(t.attrelid,t.attnum) as column_description
from pg_database d
join pg_class c
on d.datname = current_database()
join pg_namespace n
on c.relnamespace = n.oid
and n.nspname = 'public'
join pg_attribute t
on c.oid = t.attrelid
and t.attnum > 0
join pg_type tp
on t.atttypid = tp.oid;
postgres=# select
postgres-# d.datname as database_name,
postgres-# n.nspname as schema_name,
postgres-# c.relname as table_name,
postgres-# case
postgres-# when c.relstorage = 'o' then 'orc'
postgres-# when c.relstorage = 'p' then 'parquet'
postgres-# when c.relstorage = 'm' then 'magmaap'
postgres-# when c.relstorage = 'x' then 'external'
postgres-# when c.relstorage = 'v' then 'virtual'
postgres-# when c.relstorage = 'r' then 'hudi_orc'
postgres-# when c.relstorage = 'q' then 'hudi_parquet'
postgres-# when c.relstorage = 'f' then 'foreign'
postgres-# when c.relstorage = 'a' then 'aorows'
postgres-# when c.relstorage = 'h' then 'heap'
postgres-# else 'unknown' end as table_type,
postgres-# t.attname as column_name,
postgres-# tp.typname as column_type,
postgres-# col_description(t.attrelid,t.attnum) as column_description
postgres-# from pg_database d
postgres-# join pg_class c
postgres-# on d.datname = current_database()
postgres-# join pg_namespace n
postgres-# on c.relnamespace = n.oid
postgres-# and n.nspname = 'public'
postgres-# join pg_attribute t
postgres-# on c.oid = t.attrelid
postgres-# and t.attnum > 0
postgres-# join pg_type tp
postgres-# on t.atttypid = tp.oid;
database_name | schema_name | table_name | table_type | column_name | column_type | column_description
---------------+-------------+------------+------------+-------------+-------------+--------------------
postgres | public | t2 | magmaap | id | int4 |
postgres | public | t1 | orc | id | int4 | 编号
postgres | public | t1 | orc | age | text | 年龄
(3 rows)