赞
踩
使用以下查询语句来获取表空间的大小:
SELECT pg_size_pretty(pg_total_relation_size(c.oid)) AS total_size, pg_size_pretty(pg_indexes_size(c.oid)) AS index_size, pg_size_pretty(pg_total_relation_size(c.oid) - pg_indexes_size(c.oid)) AS data_size, nspname AS schema_name, relname AS table_name FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE relkind = 'r' AND nspname NOT LIKE 'pg_%' AND nspname != 'information_schema' ORDER BY pg_total_relation_size(c.oid) DESC;
这个查询语句会返回每个表的总大小、索引大小和数据大小,并按总大小降序排序。请确保在执行查询之前已经连接到正确的数据库,并具有足够的权限来查询表的大小信息。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。