当前位置:Gxlcms > 数据库问题 > postgresql查看数据库占用的物理存储空间大小

postgresql查看数据库占用的物理存储空间大小

时间:2021-07-01 10:21:17 帮助过:5人阅读

1.手动查看:

查看数据库postgres的oid

postgres=# SELECT oid from pg_database where datname=‘postgres‘;
oid
-------
12002
(1 行记录)

查找数据库的目录

D:\Program Files\PostgreSQL\9.2\data\base

查看名称为12002的文件的大小即是数据库postgres的大小;

linux可以以下命令替代

[root@arch 12002]# cd /var/lib/postgres/data/base/12002

[root@arch 12002]# du -sh

9.6M .

 

2.sql语句查询:

postgres=# select pg_size_pretty(pg_database_size(‘postgres‘));
pg_size_pretty
----------------
6229 kB
(1 行记录)

 

参考资料:

人气教程排行