ลอง:
SELECT n.nspname AS table_schema,
pg_catalog.pg_get_userbyid(c.relowner) AS table_owner,
c.relname AS table_name
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace)
WHERE c.relkind = 'v'
;
หากคุณต้องการรายละเอียดเพิ่มเติมคุณสามารถแก้ไขสิ่งต่อไปนี้เพื่อให้เหมาะกับความต้องการของคุณ:
SELECT n.nspname AS table_schema,
pg_catalog.pg_get_userbyid(c.relowner) AS table_owner,
c.relname AS table_name,
s.n_live_tup AS row_count,
count (a.attname) AS column_count,
pg_catalog.obj_description(c.oid, 'pg_class') AS comments,
CASE c.relkind
WHEN 'v'
THEN pg_catalog.pg_get_viewdef(c.oid, true)
ELSE null
END AS query
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace)
LEFT JOIN pg_catalog.pg_attribute a ON (c.oid = a.attrelid AND a.attnum > 0 AND NOT a.attisdropped)
LEFT JOIN pg_catalog.pg_stat_all_tables s ON (c.oid = s.relid)
WHERE c.relkind = 'v'
GROUP BY n.nspname,
c.relowner,
c.relkind,
c.relname,
s.n_live_tup,
c.oid
ORDER BY n.nspname,
c.relname
;