您好,登錄后才能下訂單哦!
1.提高查詢性能:只需要搜索特定分區,而非整張表,提高了查詢速度。
2.節約維護時間:單個分區的數據裝載,索引重建,備份,維護遠遠小于整張表的維護時間。
下面就讓我們來創建一張分區表
SELECT NAME FROM v$datafile;--如果是你熟悉的環境則省略這一步,目的是查看當前文件路徑
--創建表空間,如果有專人維護表空間盡量關閉自動增長,長時間無人維護則開啟自動增長,AUTOEXTEND ON SIZE
CREATE TABLESPACE partition_p_Name1 DATAFILE '/oradata/orawms/partition_p_Name1.dbf' SIZE 200m AUTOEXTEND OFF;
CREATE TABLESPACE partition_p_Name2 DATAFILE '/oradata/orawms/partition_p_Name2.dbf' SIZE 200m AUTOEXTEND OFF;
CREATE TABLESPACE partition_p_Name3 DATAFILE '/oradata/orawms/partition_p_Name3.dbf' SIZE 200m AUTOEXTEND OFF;
CREATE TABLESPACE partition_p_Name4 DATAFILE '/oradata/orawms/partition_p_Name4.dbf' SIZE 200m AUTOEXTEND OFF;
CREATE TABLESPACE partition_p_Name5 DATAFILE '/oradata/orawms/partition_p_Name5.dbf' SIZE 200m AUTOEXTEND OFF;
CREATE TABLESPACE goods_inf_max DATAFILE '/oradata/orawms/partition_p_max.dbf' SIZE 200m AUTOEXTEND OFF;
create table partition_tab_Name
(create_date DATE,
create_man VARCHAR2(64),
modify_date DATE,
modify_man VARCHAR2(64),
create_org VARCHAR2(20),
create_orgseq VARCHAR2(512),
create_role VARCHAR2(50),
fields1 VARCHAR2(200),
fields2 VARCHAR2(200),
fields3 VARCHAR2(200),
fields4 VARCHAR2(200),
fields5 VARCHAR2(200),
fields6 VARCHAR2(200),
fields7 VARCHAR2(200),
fields8 VARCHAR2(200),
fields9 VARCHAR2(200),
fields10 VARCHAR2(200)
)
PARTITION BY RANGE(create_date)
--range(分區字段,這里以創建時間做范圍分區)
(
PARTITION partition_p_Name1 VALUES LESS THAN (TO_date('2015-01-01','YYYY-MM-DD')) TABLESPACE partition_p_Name1,
PARTITION partition_p_Name2 VALUES LESS THAN (TO_date('2016-01-01','YYYY-MM-DD')) TABLESPACE partition_p_Name2,
PARTITION partition_p_Name3 VALUES LESS THAN (TO_date('2017-01-01','YYYY-MM-DD')) TABLESPACE partition_p_Name3,
PARTITION partition_p_Name4 VALUES LESS THAN (TO_date('2018-01-01','YYYY-MM-DD')) TABLESPACE partition_p_Name4,
PARTITION partition_p_Name5 VALUES LESS THAN (TO_date('2019-01-01','YYYY-MM-DD')) TABLESPACE partition_p_Name5,
PARTITION partition_p_max VALUES LESS THAN (MAXVALUE) TABLESPACE partition_p_max
);
INSERT INTO partition_tab_Name SELECT * FROM ‘源表名’;
SELECT * FROM goods_inf_r1 PARTITION(partition_p_Name1);--partition_p_Name2,partition_p_Name3~~~
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。