Advertisement
hackerboxes

postgresql分区表

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