1.1、环境准备

  1. drop table if exists bills ;
  2. create table bills
  3. (
  4. id serial not null,
  5. goodsdesc text not null,
  6. beginunit text not null,
  7. begincity text not null,
  8. pubtime timestamp not null,
  9. amount float8 not null default 0,
  10. primary key (id)
  11. ) distribute by shard(id) to group default_group;
  12. COMMENT ON TABLE bills is '运单记录';
  13. COMMENT ON COLUMN bills.id IS 'id号';
  14. COMMENT ON COLUMN bills.goodsdesc IS '货物名称';
  15. COMMENT ON COLUMN bills.beginunit IS '启运省份';
  16. COMMENT ON COLUMN bills.begincity IS '启运城市';
  17. COMMENT ON COLUMN bills.pubtime IS '发布时间';
  18. COMMENT ON COLUMN bills.amount IS '运费';
  19. INSERT INTO bills(id,goodsdesc,beginunit,begincity,pubtime,amount)
  20. VALUES(default,'衣服','海南省','三亚市','2015-10-05 09:32:01',ROUND((random()*10000)::NUMERIC,2));
  21. INSERT INTO bills(id,goodsdesc,beginunit,begincity,pubtime,amount)
  22. VALUES(default,'建筑设备','福建省','三明市','2015-10-05 07:21:22',ROUND((random()*10000)::NUMERIC,2));
  23. INSERT INTO bills(id,goodsdesc,beginunit,begincity,pubtime,amount)
  24. VALUES(default,'设备','福建省','三明市','2015-10-05 11:21:54',ROUND((random()*10000)::NUMERIC,2));
  25. INSERT INTO bills(id,goodsdesc,beginunit,begincity,pubtime,amount)
  26. VALUES(default,'普货','福建省','三明市','2015-10-05 15:19:17',ROUND((random()*10000)::NUMERIC,2));
  27. INSERT INTO bills(id,goodsdesc,beginunit,begincity,pubtime,amount)
  28. VALUES(default,'5 0铲车,后八轮翻斗车','河南省','三门峡市','2015-10-05 07:53:13',ROUND((random()*10000)::NUMERIC,2));
  29. INSERT INTO bills(id,goodsdesc,beginunit,begincity,pubtime,amount)
  30. VALUES(default,'鲜香菇2000斤','河南省','三门峡市','2015-10-05 10:38:29',ROUND((random()*10000)::NUMERIC,2));
  31. INSERT INTO bills(id,goodsdesc,beginunit,begincity,pubtime,amount)
  32. VALUES(default,'旋挖附件38吨','河南省','三门峡市','2015-10-05 10:48:38',ROUND((random()*10000)::NUMERIC,2));
  33. INSERT INTO bills(id,goodsdesc,beginunit,begincity,pubtime,amount)
  34. VALUES(default,'旋挖附件35吨','河南省','三门峡市','2015-10-05 10:48:38',ROUND((random()*10000)::NUMERIC,2));
  35. INSERT INTO bills(id,goodsdesc,beginunit,begincity,pubtime,amount)
  36. VALUES(default,'旋挖附件39吨','河南省','三门峡市','2015-10-05 11:38:38',ROUND((random()*10000)::NUMERIC,2));
  37. INSERT INTO bills(id,goodsdesc,beginunit,begincity,pubtime,amount)
  38. VALUES(default,'设备','上海市','上海市','2015-10-05 07:59:35',ROUND((random()*10000)::NUMERIC,2));
  39. INSERT INTO bills(id,goodsdesc,beginunit,begincity,pubtime,amount)
  40. VALUES(default,'普货40吨需13米半挂一辆','上海市','上海市','2015-10-05 08:13:59',ROUND((random()*10000)::NUMERIC,2));