Greenplum数据库建表及分区 语句!

  • A+
所属分类:SQL技巧

​​Greenplum数据库建表及分区 语句

Greenplum数据库建表及分区 语句!

 

greenplum

创建分区表

CREATE TABLE fi_middle.order_detail

(

date_id integer,

order_id character varying(22),

product_id character varying(50),

order_quantity numeric,

allot_quantity numeric,

original_price numeric,

sale_price numeric,

vip_price numeric,

bargin_price numeric,

medium numeric,

promotion_id numeric,

is_vip_discount numeric,

product_type numeric,

reduce_price numeric,

etl_change_date timestamp without time zone,

order_items_id numeric,

gift_card_charge numeric(12,2),

gift_unit_price numeric,

item_id numeric,

parent_item_id numeric,

allot_activity_fee numeric(12,2),

allot_point_deduction_amount numeric,

send_date timestamp without time zone,

privilege_code_discount_amount numeric,

relation_type numeric,

parent_id character varying(16),

shop_id numeric,

shop_type numeric

)

WITH (

OIDS=FALSE

)

DISTRIBUTED BY (order_id)

PARTITION BY RANGE(send_date)

(

PARTITION p_order_detail_20170701 START ('2017-06-01 00:00:00'::timestamp without time zone) END ('2017-07-01 00:00:00'::timestamp without time zone),

PARTITION p_order_detail_20170801 START ('2017-07-01 00:00:00'::timestamp without time zone) END ('2017-08-01 00:00:00'::timestamp without time zone)

)

添加分区

alter table fi.order_detail_adt_cp add partition p_order_detail_adt_20170601 START ('2017-05-01 00:00:00'::timestamp without time zone) END ('2017-06-01 00:00:00'::timestamp without time zone) EVERY ('1 mon'::interval)

修改表名称

alter table fi_middle.order_detail rename to order_detail_adt;

(表名默认在旧表模式下,不必指定模式)

内容修改

update fi.fi_promotion_info set supp_no='00'||supp_no where date_id=20170915 and length(supp_no)=5 and supp_no<>'80000';

update fi.fi_promotion_info set supp_no='0'||supp_no where date_id=20170915 and length(supp_no)=4;

update fi.fi_promotion_info set end_date=end_date+interval '1 day' where date_id=20170915 and to_char(end_date,'yyyymmdd hh24:mi:ss') like '%00:00:00';

update fi.fi_promotion_info set cat2_name='全品' where date_id=20170915 and cat2_name='全部品种';

 

以上就是今天要分享的技巧,你学会了吗?若有什么问题,欢迎在下方留言。

学习资料见知识星球。

以上就是今天要分享的技巧,你学会了吗?若有什么问题,欢迎在下方留言。

快来试试吧,小琥 my21ke007。获取 1000个免费 Excel模板福利​​​​!

更多技巧, www.excelbook.cn

欢迎 加入 零售创新 知识星球,知识星球主要以数据分析、报告分享、数据工具讨论为主;

Greenplum数据库建表及分区 语句!

你将获得:

1、价值上万元的专业的PPT报告模板。

2、专业案例分析和解读笔记。

3、实用的Excel、Word、PPT技巧。

4、VIP讨论群,共享资源。

5、优惠的会员商品。

6、一次付费只需99元,即可下载本站文章涉及的文件和软件。

  • 我的微信
  • weinxin
  • 我的知识星球
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: