--建表
create table A_TT
(
A VARCHAR2(10),
B DATE
)
partition by range (A)
(
partition PART_1 values less than ('10')
tablespace SMCRPT_HOME
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 80K
next 1M
minextents 1
maxextents unlimited
),
partition PART_2 values less than ('20')
tablespace SMCRPT_HOME
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 80K
next 1M
minextents 1
maxextents unlimited
)
}
;
create table A_BB
(
A VARCHAR2(10),
B DATE
);
--存储过程中组装分区交互执行语句
v_SQL := 'ALTER TABLE ' || v_ToTblName ||
' Exchange SUBPARTITION '|| sSubParitionName ||
' WITH TABLE ' || v_InTblName ||
' INCLUDING INDEXES WITHOUT VALIDATION';
EXECUTE IMMEDIATE v_SQL;
--将a_bb表中的信息与a_tt表中的信息进行分区交互,指定分区是a_tt表中的PART_1分区
alter table a_TT Exchange PARTITION PART_1 WITH TABLE a_BB INCLUDING INDEXES WITHOUT VALIDATION;
--创建数据
INSERT INTO A_BB (A)
SELECT OBJECT_ID FROM ALL_OBJECTS
SELECT COUNT(1) FROM A_BB
INSERT /*+ APEEND */ INTO A_BB
SELECT * FROM A_BB
INSERT INTO a_tt
SELECT * FROM A_BB
--查看结果
select t.*, t.rowid from a_tt PARTITION(PART_1) t ; --分区