warehouse_db=# create table emp1(id int,name char(10));
warehouse_db=# insert into emp1 values (generate_series(1,100000),'test');
INSERT 0 100000
warehouse_db=# select pg_size_pretty(pg_relation_size('emp1'));
pg_size_pretty
----------------
43 MB
(1 row)
warehouse_db=# SELECT pg_relation_filepath('emp1');
pg_relation_filepath
----------------------
base/16384/25386
(1 row)
warehouse_db=# \! du -sh /usr/local/pg9.5.2/data/base/16384/25386
43M /usr/local/pg9.5.2/data/base/16384/25386
warehouse_db=# truncate table emp1;
TRUNCATE TABLE
warehouse_db=# SELECT pg_relation_filepath('emp1');
pg_relation_filepath
----------------------
base/16384/25387
(1 row)
warehouse_db=# select pg_size_pretty(pg_relation_size('emp1'));
pg_size_pretty
----------------
0 bytes
(1 row)
warehouse_db=# \! du -sh /usr/local/pg9.5.2/data/base/16384/25387
0 /usr/local/pg9.5.2/data/base/16384/25387
warehouse_db=#
阅读(3155) | 评论(0) | 转发(0) |