1.手动查看:
查看数据库mydb1的表空间路径
mydb1=> select datname,dattablespace from pg_database where datname='mydb1';
datname | dattablespace
---------+---------------
mydb1 | 18727
(1 row)
mydb1=> select oid,spcname from pg_tablespace where oid=18727;
oid | spcname
-------+---------
18727 | my1_ts
(1 row)
mydb1=> \db
List of tablespaces
Name | Owner | Location
------------+----------+--------------------------------
my1_ts | mymotif | /opt/Postgresql/9.4/data/my1ts
my2_ts | mymotif | /opt/Postgresql/9.4/data/my2ts
mymotif_ts | mymotif | /opt/Postgresql/9.4/data
pg_default | postgres |
pg_global | postgres |
(5 rows)
查看数据库mydb1的oid
mydb1=> SELECT oid,datname from pg_database ; oid | datname -------+----------- 1 | template1 12172 | template0 12177 | postgres 16459 | mymotif 16498 | mydb 16523 | testdb 17381 | mypostgis 18770 | mydb1 (8 rows)
$ ls -l data/my1ts/PG_9.4_201409291/
总用量 16
drwx------ 2 postgres postgres 4096 9月 14 22:30 16459
drwx------ 2 postgres postgres 12288 9月 15 23:40 18770
目录(或文件)18770便是mydb1大小。
mydb1=> select pg_size_pretty(pg_database_size('mydb1')); pg_size_pretty ---------------- 6724 kB (1 row)