我们在 PostgreSQL 中维护了大约 100 多个模式。现在我们要查询所有模式,有什么办法吗?除了意见、程序和工会之外的一切?任何允许您查询多个模式的 postgres 函数
问问题
2831 次
1 回答
4
以下目录查询将为数据库的所有模式上的每个表生成有效查询。您可以将其复制到有效的 SQL 文件中。
SELECT 'SELECT * FROM ' || table_schema || '.' || table_name || ';' AS query
FROM information_schema.tables
WHERE table_schema IN
(
SELECT schema_name
FROM information_schema.schemata
WHERE schema_name NOT LIKE 'pg_%' AND schema_name != 'information_schema'
);
这有帮助吗?
于 2018-10-13T17:12:49.883 回答