SQL分区表示例
-- Create table
create table TT_FVP_OCR_ADDRESS
(
id NUMBER not null,
waybill_no VARCHAR2(32) not null,
dest_zone_code VARCHAR2(32),
confidence NUMBER(16,4),
input_tm DATE,
insert_tm DATE default sysdate not null,
deal_flg NUMBER(2) default 0 not null,
deal_count NUMBER(2) default 0 not null,
deal_ip VARCHAR2(30),
deal_tm DATE,
ocr_addr VARCHAR2(1000)
)
partition by range (INSERT_TM)
(
partition TT_FVP_OCR_ADDRESS_P20170616 values less than (TIMESTAMP' 2017-06-17 00:00:00'),
partition TT_FVP_OCR_ADDRESS_P20170617 values less than (TIMESTAMP' 2017-06-18 00:00:00'),
partition TT_FVP_OCR_ADDRESS_P20170618 values less than (TIMESTAMP' 2017-06-19 00:00:00'),
partition TT_FVP_OCR_ADDRESS_P20170619 values less than (TIMESTAMP' 2017-06-20 00:00:00'),
partition TT_FVP_OCR_ADDRESS_P20170620 values less than (TIMESTAMP' 2017-06-21 00:00:00'),
partition TT_FVP_OCR_ADDRESS_P20170621 values less than (TIMESTAMP' 2017-06-22 00:00:00'),
partition TT_FVP_OCR_ADDRESS_P20170622 values less than (TIMESTAMP' 2017-06-23 00:00:00'),
partition TT_FVP_OCR_ADDRESS_P20170623 values less than (TIMESTAMP' 2017-06-24 00:00:00'),
partition TT_FVP_OCR_ADDRESS_P20170624 values less than (TIMESTAMP' 2017-06-25 00:00:00'),
partition TT_FVP_OCR_ADDRESS_P20170625 values less than (TIMESTAMP' 2017-06-26 00:00:00'),
partition TT_FVP_OCR_ADDRESS_P20170626 values less than (TIMESTAMP' 2017-06-27 00:00:00')
);
-- Add comments to the table
comment on table TT_FVP_OCR_ADDRESS
is 'ocr地址表';
-- Add comments to the columns
comment on column TT_FVP_OCR_ADDRESS.id
is 'ID';
comment on column TT_FVP_OCR_ADDRESS.waybill_no
is '运单号';
comment on column TT_FVP_OCR_ADDRESS.dest_zone_code
is '收方城市代码';
comment on column TT_FVP_OCR_ADDRESS.confidence
is '可信度';
comment on column TT_FVP_OCR_ADDRESS.input_tm
is '录单时间';
comment on column TT_FVP_OCR_ADDRESS.insert_tm
is '插入时间';
comment on column TT_FVP_OCR_ADDRESS.deal_flg
is '处理标志';
comment on column TT_FVP_OCR_ADDRESS.deal_count
is '处理次数';
comment on column TT_FVP_OCR_ADDRESS.deal_ip
is '处理IP';
comment on column TT_FVP_OCR_ADDRESS.deal_tm
is '处理时间';
comment on column TT_FVP_OCR_ADDRESS.ocr_addr
is '纠错地址';
create index IDX_TT_FVP_OCR_ADDRESS on TT_FVP_OCR_ADDRESS (DEAL_FLG)
local;
-- Create/Recreate primary, unique and foreign key constraints
alter table TT_FVP_OCR_ADDRESS
add constraint PK_TT_FVP_OCR_ADDRESS primary key (ID, INSERT_TM)
using index
local;
--创建FVP_OCR_ADDRESS表的序列
create sequence SEQ_TT_FVP_OCR_ADDRESS
minvalue 1
maxvalue 999999999999999999999
start with 1000
increment by 1
cache 20;
--维护分区
DECLARE
V_OUT VARCHAR2(2000);
BEGIN
DBAMON.CONFIG_TAB_POLICY(V_OUT,'SSS','TT_FVP_OCR_ADDRESS',7,1,0,24,'DAY');
DBMS_OUTPUT.PUT_LINE(V_OUT);
END;