我想列出 Postgres 集群中的所有数据库和模式,如何获得该列表?
我已经运行了以下查询(我正在使用 pgAdmin)
SELECT * FROM pg_database; --This lists all the databases in the cluster
SELECT distinct table_catalog, table_schema
FROM information_schema.tables
ORDER BY table_schema; --This lists all the schemas in the current database I am in.
我尝试将它们组合起来(在查询下方),但它只给出来自 information_schema 的结果,并且仅限于一个数据库。
select distinct db.datname, t.table_schema from pg_database db
inner join information_schema.tables t on db.datname = t.table_catalog
order by db.datname, t.table_schema