一、GP或PgSQL
sql
-- 获取表结构
SELECT a.schemaname schema_name, a.tablename table_name, string_agg(DISTINCT b.column_name, ',') AS columns FROM (SELECT schemaname, tablename FROM pg_tables WHERE schemaname = 'public') a
LEFT JOIN (SELECT table_name, column_name FROM information_schema.columns where table_schema = 'public') b
ON a.tablename = b.table_name
GROUP BY a.schemaname, a.tablename;