Oracle資料庫--解決單張表中資料量巨大(大資料、資料量上百萬級別,後查詢,更新資料等耗時劇增)
(備註:range()指定資料庫表中的某一欄位作為資料儲存到不同表空間的判斷標準)
(備註:在最高的分割槽中,MAXVALUE被定義。MAXVALUE代表了一個不確定的值。這個值高於其它分割槽中的任何分割槽鍵的值, 也可以理解為高於任何分割槽中指定的VALUE LESS THEN的值,同時包括空值。) 3.以前的SQL查詢語句不變,一樣查詢資料 (備註:查詢資料時,不再全表掃面,只是根據條件掃描一個或多個表空間中的資料庫表,所以查詢效能會有很好的提升) 參考:https://www.2cto.com/database/201604/503199.html
事例:
create tablespace ADC_BACK_1 datafile 'F:\Oracle\tablespaces\ADC_BACK_1.dnf' size 100M autoextend on next 100m maxsize 20480m extent management local;
create tablespace ADC_BACK_2 datafile 'F:\Oracle\tablespaces\ADC_BACK_2.dnf' size 100M autoextend on next 100m maxsize 20480m extent management local;
create tablespace ADC_BACK_3 datafile 'F:\Oracle\tablespaces\ADC_BACK_3.dnf' size 100M autoextend on next 100m maxsize 20480m extent management local;
create tablespace ADC_BACK_4 datafile 'F:\Oracle\tablespaces\ADC_BACK_4.dnf' size 100M autoextend on next 100m maxsize 20480m extent management local;
create tablespace ADC_BACK_5 datafile 'F:\Oracle\tablespaces\ADC_BACK_5.dnf' size 100M autoextend on next 100m maxsize 20480m extent management local;
create table MON_PROCESS_RECORD_BACK(
INFOID VARCHAR2(36),
DIC_FLOWTYPE_ID VARCHAR2(36),
START_TIME DATE,
END_TIME DATE,
IS_SUCCESS CHAR(1),
ERROR_CODE VARCHAR2(2000),
DEL_FLAG CHAR(1),
ID VARCHAR2(36) PRIMARY KEY,
DEALWAY CHAR(1),
DETAIL VARCHAR2(4000),
DIC_EB_PLATFORM_ID VARCHAR2(36),
STATE VARCHAR2(100),
INSTRUCTION_ID VARCHAR2(36),
INSTRUCTION_NUM VARCHAR2(4),
EBI_INFO_CODE VARCHAR2(50),
IS_DISPLAY VARCHAR2(1)
)
partition by range(EBI_INFO_CODE)(
partition part_01 values less than('201608100000000000000') tablespace ADC_BACK_1,
partition part_02 values less than('201609100000000000000') tablespace ADC_BACK_2,
partition part_03 values less than('201610100000000000000') tablespace ADC_BACK_3,
partition part_04 values less than('201611100000000000000') tablespace ADC_BACK_4,
partition part_05 values less than('201612300000000000000') tablespace ADC_BACK_5,
partition part_06 values less than(maxvalue) tablespace USERS
);
轉移資料:
insert into MON_PROCESS_RECORD_BACK(
INFOID,
DIC_FLOWTYPE_ID,
START_TIME,
END_TIME,
IS_SUCCESS,
ERROR_CODE,
DEL_FLAG,
ID,
DEALWAY,
DETAIL,
DIC_EB_PLATFORM_ID,
STATE,
INSTRUCTION_ID,
INSTRUCTION_NUM,
EBI_INFO_CODE,
IS_DISPLAY
)
select
INFOID,
DIC_FLOWTYPE_ID,
START_TIME,
END_TIME,
IS_SUCCESS,
ERROR_CODE,
DEL_FLAG,
ID,
DEALWAY,
DETAIL,
DIC_EB_PLATFORM_ID,
STATE,
INSTRUCTION_ID,
INSTRUCTION_NUM,
EBI_INFO_CODE,
IS_DISPLAY
from MON_PROCESS_RECORD;