PG数据库空间占用查询
2、查询数据库所有表空间占用空间大小。
·
1、查询所有数据库占用空间大小
SELECT datname, pg_size_pretty(pg_database_size(datname)) AS size FROM pg_database;
2、查询数据库所有表空间占用空间大小
SELECT spcname, pg_size_pretty(pg_tablespace_size(spcname)) AS size FROM pg_tablespace;
3、查询单个数据库表占用空间大小
SELECT pg_size_pretty(pg_total_relation_size('t_audit_log')) AS size;
4、查询所有数据库表占用空间大小
SELECT
table_schema,
table_name,
pg_size_pretty(pg_total_relation_size('"'||table_schema||'"."'||table_name||'"')) as size
FROM information_schema.tables
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_total_relation_size('"'||table_schema||'"."'||table_name||'"') DESC;
更多推荐
所有评论(0)