oracle涉及到的主表、子表进行分区
先声明:oracle版本为:12.2
场景:主表每月千万级数据,子表嘛更多了
下面是单表进行分区的语句,是没问题的,根据月份分区
create table hgf_test_part
(
ID NUMBER(20) not null,
REMARK VARCHAR2(1000),
create_time DATE
)
PARTITION BY RANGE (CREATE_TIME)
INTERVAL (numtoyminterval(1, 'month'))
(partition hgf values less than(to_date('2020-01-01', 'yyyy-mm-dd')));
问题相关代码,请勿粘贴截图
create table pt_reference_father_test(
pid number(10),
pname varchar2(30),
create_date date,
constraint pk_black_pid primary key(pid)
)
PARTITION by (create_date)(
INTERVAL (numtoyminterval(1, 'month'))
(PARTITION pk_hgf values less than(to_date('2020-01-01', 'yyyy-mm-dd')));
-- 子表
create table pt_reference_son_test(
pid number(10) not null, -- 必须 not null,否则报错
item_id number(10),
constraint pk_black_item_id primary key(item_id),
constraint pk_black_pid foreign key(pid)
references pt_reference_father_test(pid)
) partition by reference(fk_black_pid)
enable row movement;