普通range分区表
create table test_part_update_indexes_range(id int primary key)
PARTITION by range(id)(
partition p1 VALUES LESS THAN (202000) nocompress,
partition p2 VALUES LESS THAN (202001) compress,
partition p3 VALUES LESS THAN (202002)
);
ALTER TABLE test_part_update_indexes_range TRUNCATE PARTITION p1;
drop table test_part_update_indexes_range;
create table test_part_update_indexes_range(id int primary key)
PARTITION by range(id)(
partition p1 VALUES LESS THAN (202000) nocompress,
partition p2 VALUES LESS THAN (202001) compress,
partition p3 VALUES LESS THAN (202002)
);
ALTER TABLE test_part_update_indexes_range TRUNCATE PARTITION p1 update indexes;
drop table test_part_update_indexes_range;
普通list分区表
CREATE TABLE test_part_update_indexes_list(
LOG_ID NUMBER(20) PRIMARY KEY,
LOG_DATE DATE,
LOG_DESC VARCHAR2(20)
)
PARTITION BY LIST(LOG_ID)
(
PARTITION PART_LOG_01 VALUES (1),
PARTITION PART_LOG_02 VALUES (2),
PARTITION PART_LOG_03 VALUES (3),
PARTITION PART_LOG_04 VALUES (4),
PARTITION PART_LOG_05 VALUES (5),
PARTITION PART_LOG_06 VALUES (6),
PARTITION PART_LOG_07 VALUES (7)
);
ALTER TABLE test_part_update_indexes_list TRUNCATE PARTITION PART_LOG_01;
drop table test_part_update_indexes_list;
CREATE TABLE test_part_update_indexes_list(
LOG_ID NUMBER(20) PRIMARY KEY,
LOG_DATE DATE,
LOG_DESC VARCHAR2(20)
)
PARTITION BY LIST(LOG_ID)
(
PARTITION PART_LOG_01 VALUES (1),
PARTITION PART_LOG_02 VALUES (2),
PARTITION PART_LOG_03 VALUES (3),
PARTITION PART_LOG_04 VALUES (4),
PARTITION PART_LOG_05 VALUES (5),
PARTITION PART_LOG_06 VALUES (6),
PARTITION PART_LOG_07 VALUES (7)
);
ALTER TABLE test_part_update_indexes_list TRUNCATE PARTITION PART_LOG_01 update indexes;
drop table test_part_update_indexes_list;
普通hash分区表
CREATE TABLE test_part_update_indexes_hash(
LOG_ID NUMBER(20) PRIMARY KEY,
LOG_DATE DATE,
LOG_DESC VARCHAR2(20)
)
PARTITION BY HASH(LOG_ID)
(
PARTITION PART_LOG_01,
PARTITION PART_LOG_02,
PARTITION PART_LOG_03,
PARTITION PART_LOG_04,
PARTITION PART_LOG_05,
PARTITION PART_LOG_06,
PARTITION PART_LOG_07
);
ALTER TABLE test_part_update_indexes_hash TRUNCATE PARTITION PART_LOG_01;
drop table test_part_update_indexes_hash;
CREATE TABLE test_part_update_indexes_hash(
LOG_ID NUMBER(20) PRIMARY KEY,
LOG_DATE DATE,
LOG_DESC VARCHAR2(20)
)
PARTITION BY HASH(LOG_ID)
(
PARTITION PART_LOG_01,
PARTITION PART_LOG_02,
PARTITION PART_LOG_03,
PARTITION PART_LOG_04,
PARTITION PART_LOG_05,
PARTITION PART_LOG_06,
PARTITION PART_LOG_07
);
ALTER TABLE test_part_update_indexes_hash TRUNCATE PARTITION PART_LOG_01 update indexes;
drop table test_part_update_indexes_hash;
range+list的二级分区表
CREATE TABLE test_part_upd_idx_range_list
(
a int,
b float,
c varchar(20),
d date,
e timestamp,
primary key(a,b)
) PARTITION BY RANGE(a)
SUBPARTITION BY LIST (b)
SUBPARTITION TEMPLATE
(
SUBPARTITION p1 VALUES (1.1, 2.1, 3.1) COMPRESS ,
SUBPARTITION p2 VALUES (4.1) NOCOMPRESS
)
(
PARTITION p1 VALUES LESS THAN(10) COMPRESS ,
PARTITION p2 VALUES LESS THAN(20) NOCOMPRESS ,
PARTITION p3 VALUES LESS THAN(30)
);
ALTER TABLE test_part_upd_idx_range_list TRUNCATE PARTITION p1;
drop table test_part_upd_idx_range_list;
CREATE TABLE test_part_upd_idx_range_list
(
a int,
b float,
c varchar(20),
d date,
e timestamp,
primary key(a,b)
) PARTITION BY RANGE(a)
SUBPARTITION BY LIST (b)
SUBPARTITION TEMPLATE
(
SUBPARTITION p1 VALUES (1.1, 2.1, 3.1) COMPRESS ,
SUBPARTITION p2 VALUES (4.1) NOCOMPRESS
)
(
PARTITION p1 VALUES LESS THAN(10) COMPRESS ,
PARTITION p2 VALUES LESS THAN(20) NOCOMPRESS ,
PARTITION p3 VALUES LESS THAN(30)
);
ALTER TABLE test_part_upd_idx_range_list TRUNCATE PARTITION p1 update indexes;
drop table test_part_upd_idx_range_list;
range+hash的二级分区表
create table test_part_upd_idx_range_hash
(
transaction_id number,
item_id number(8) not null,
item_description varchar(300),
transaction_date DATE,
primary key(transaction_date,transaction_id)
)
partition by range(transaction_date)
subpartition by hash(transaction_id)
subpartitions 2
(
partition p1 values less than(to_date('2020-01-01','yyyy-mm-dd')) COMPRESS ,
partition p2 values less than(to_date('2021-01-01','yyyy-mm-dd')) NOCOMPRESS ,
partition p3 values less than(to_date('2022-01-01','yyyy-mm-dd'))
);
ALTER TABLE test_part_upd_idx_range_hash TRUNCATE PARTITION p1;
drop table test_part_upd_idx_range_hash;
create table test_part_upd_idx_range_hash
(
transaction_id number,
item_id number(8) not null,
item_description varchar(300),
transaction_date DATE,
primary key(transaction_date,transaction_id)
)
partition by range(transaction_date)
subpartition by hash(transaction_id)
subpartitions 2
(
partition p1 values less than(to_date('2020-01-01','yyyy-mm-dd')) COMPRESS ,
partition p2 values less than(to_date('2021-01-01','yyyy-mm-dd')) NOCOMPRESS ,
partition p3 values less than(to_date('2022-01-01','yyyy-mm-dd'))
);
ALTER TABLE test_part_upd_idx_range_hash TRUNCATE PARTITION p1 update indexes;
drop table test_part_upd_idx_range_hash;
list+hash的二级分区表
create table test_part_upd_idx_list_hash
(
transaction_id number,
item_id number(8) not null,
item_description varchar(300),
transaction_date DATE,
primary key(transaction_date,transaction_id)
)
partition by list(transaction_id)
subpartition by hash(transaction_date)
subpartitions 2
(
partition p1 values (1) COMPRESS ,
partition p2 values (2,3,4) NOCOMPRESS ,
partition p3 values (5,6)
);
ALTER TABLE test_part_upd_idx_list_hash TRUNCATE PARTITION p1;
drop table test_part_upd_idx_list_hash;
create table test_part_upd_idx_list_hash
(
transaction_id number,
item_id number(8) not null,
item_description varchar(300),
transaction_date DATE,
primary key(transaction_date,transaction_id)
)
partition by list(transaction_id)
subpartition by hash(transaction_date)
subpartitions 2
(
partition p1 values (1) COMPRESS ,
partition p2 values (2,3,4) NOCOMPRESS ,
partition p3 values (5,6)
);
ALTER TABLE test_part_upd_idx_list_hash TRUNCATE PARTITION p1 update indexes;
drop table test_part_upd_idx_list_hash;