Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- postgres创建分区表
- 1.首先根据业务需要划分分区表,确定分区表的命名
- 2.创建分区表
- create table t_test_0(like t_test including index including constraint ) inherits(t_test)
- 3.向分区表中插入数据
- insert into t_test_0 select * from t_test where id>=0 and id<500
- 4.优化分区表,这里只是创建索引
- ceate index t_test_0_date on t_test_0 using btree(date)
- 5.用truncate 清空父表
- truncate table only t_test;
- 6.打开constraint_exclusion=on;
- 6.测试查询
- select * from t_test where date>='2012-09-12' and date <='2012-12-31';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement