如何获取 postgresql 9.5 中特定模式中存在的所有表的表行数?我希望结果为 table_name |行数。如何使用查询来完成?
最佳答案
这可以通过一些 XML 魔术来完成:
select table_schema, table_name,
(xpath('/row/count/text()', query_to_xml('select count(*) from '||format('%I.%I', table_schema, table_name), true, true, '')))[1]::text::int as row_count
from information_schema.tables
where table_schema = 'public'
关于sql - 如何获取 postgresql 9.5 中特定模式中存在的所有表的表行数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44330142/