如何在PostgreSQL检查数据库和表的大小

时间:2019-05-19 01:25:39  来源:igfitidea点击:

本教程将确定PostgreSQL server中的数据库大小和表大小。
首先使用命令行登录到服务器,然后连接到PostgreSQL服务器。
现在我们可以使用以下命令来确定PostgreSQL中的数据库和表的大小。

1. 检查PostgreSQL中的数据库大小

要确定数据库大小,请执行PostgreSQL命令提示符中的命令。

postgres=# SELECT pg_size_pretty(pg_database_size('mydb'));

2. 在PostgreSQL中检查表的大小

要确定表的大小,首先连接到数据库,然后从PostgreSQL命令提示符执行以下命令。

postgres=# connect mydb;

mydb=# SELECT pg_size_pretty( pg_total_relation_size('mytbl'));