匿名用户pg中子表的truncate问题
truncate table only northamerica;
truncate table northamerica;
有啥区别?测试没发现有啥不同的
northamerica 是父表的一个子分区
我来答
添加附件
收藏
分享
问题补充
2条回答
默认
最新
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
墨值悬赏
匿名用户truncate table only northamerica;
truncate table northamerica;
有啥区别?测试没发现有啥不同的
northamerica 是父表的一个子分区
drop table if exist test;
drop table if exist test_2025_01_01;
create table test(id serial primary key, info text);
create table test_2025_01_01() inherits (test);
insert into test(info) values('info1');
insert into test_2025_01_01(info) values('info2');
postgres=# begin;
BEGIN
postgres=# truncate test;
TRUNCATE TABLE
postgres=# select * from test;
id | info
----+------
(0 rows)
postgres=# select * from test_2025_01_01;
id | info
----+------
(0 rows)
postgres=# rollback;
ROLLBACK
postgres=# begin;
BEGIN
postgres=# truncate only test;
TRUNCATE TABLE
postgres=# select * from test_2025_01_01;
id | info
----+-------
2 | info2
(1 row)
postgres=# select * from test;
id | info
----+-------
2 | info2
(1 row)
postgres=#
postgres=# select * from only test;
id | info
----+------
(0 rows)
postgres=# rollback;
ROLLBACK
postgres=#
评论
有用 0
墨值悬赏