Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所有示例都显示:
CREATE TABLE ... PARTITION BY ...
这有点荒谬,因为只有当数据集变得太大时才会使用分区,根据定义,这不会是一个新表。如果有人正在创建一个带有分区的新表,我想几乎任何人都会批评这是过早的优化。
只需创建一个分区表并将现有表附加为分区:
create table test (a int); insert into test select generate_series(1,10); alter table test_parent attach partition test DEFAULT; select * from test_parent; a ---- 1 2 3 4 5 6 7 8 9 10 (10 rows)
您也可以重命名表。但是,如果您这样做,您将需要重新定义指向原始表的所有视图。