当前位置:   article > 正文

Postgresql中drop table是否会释放空间_pg drop table可以释放空间吗

pg drop table可以释放空间吗

作者:瀚高PG实验室 (Highgo PG Lab)

mydb=# create table tbl_kenyon(id int,cname varchar(50),remark text);
CREATE TABLE
mydb=#  insert into tbl_kenyon select generate_series(1,10000000),'kenyon good boy',md5('kenyon good boy');
INSERT 0 10000000
mydb=#  insert into tbl_kenyon select generate_series(1,10000000),'kenyon good boy',md5('kenyon good boy');
INSERT 0 10000000


mydb=# select pg_size_pretty(pg_relation_size('tbl_kenyon'));
 pg_size_pretty
----------------
 1611 MB
(1 row)
[highgo@hgdb 4.1.1]$ du -sh
6.2G	.


mydb=# select pg_relation_filepath('tbl_kenyon');
 pg_relation_filepath
----------------------
 base/32996/57990
(1 row)
[highgo@hgdb base]$ ll 32996/57990*
-rw------- 1 highgo highgo 1073741824 Feb 24 10:57 32996/57990
-rw------- 1 highgo highgo  615333888 Feb 24 10:57 32996/57990.1
-rw------- 1 highgo highgo     434176 Feb 24 10:51 32996/57990_fsm



mydb=# drop table tbl_kenyon ;
DROP TABLE
[highgo@hgdb base]$ ll 32996/57990*
-rw------- 1 highgo highgo 0 Feb 24 10:58 32996/57990
[highgo@hgdb 4.1.1]$ du -sh
4.6G	.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

从上面的内容可以看出,drop table 会直接释放空间

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/256217
推荐阅读
相关标签
  

闽ICP备14008679号