oracle怎么新增分區(qū),oracle新增分區(qū)后索引失效,重啟有用嗎?

ORACLE表分區(qū)

一.表分區(qū)策略

成都創(chuàng)新互聯(lián)是一家專業(yè)提供武勝企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站建設(shè)、成都網(wǎng)站制作、H5開發(fā)、小程序制作等業(yè)務(wù)。10年已為武勝眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)絡(luò)公司優(yōu)惠進(jìn)行中。

1.識(shí)別大表

采用ANALYZE TABLE語(yǔ)句進(jìn)行分析,然后查詢數(shù)據(jù)字典獲得相應(yīng)的數(shù)據(jù)量。

2.大表如何分區(qū)

可根據(jù)月份,季度以及年份等進(jìn)行分區(qū);

3.分區(qū)的表空間規(guī)劃

要對(duì)每個(gè)表空間的大小進(jìn)行估計(jì)

二.創(chuàng)建表分區(qū)

a.創(chuàng)建范圍分區(qū)的關(guān)鍵字是'RANGE'

1.范圍分區(qū)

create table ware_retail_part --創(chuàng)建一個(gè)描述商品零售的數(shù)據(jù)表

(

id integer primary key,--銷售編號(hào)

retail_date date,--銷售日期

ware_name varchar2(50)--商品名稱

)

partition by range(retail_date)

(

--2011年第一個(gè)季度為part_01分區(qū)

partition par_01 values less than(to_date('2011-04-01','yyyy-mm-dd')) tablespace TEMP01,

--2011年第二個(gè)季度為part_02分區(qū)

partition par_02 values less than(to_date('2011-07-01','yyyy-mm-dd')) tablespace TEMP01,

--2011年第三個(gè)季度為part_03分區(qū)

partition par_03 values less than(to_date('2011-10-01','yyyy-mm-dd')) tablespace TEMP01,

--2011年第四個(gè)季度為part_04分區(qū)

partition par_04 values less than(to_date('2012-01-01','yyyy-mm-dd')) tablespace TEMP01

);

2.創(chuàng)建散列分區(qū)

3.組合分區(qū):

4.interval 分區(qū)

三.創(chuàng)建索引分區(qū)

索引分區(qū)分為本地索引分區(qū)和全局索引分區(qū),全局索引不反應(yīng)基礎(chǔ)表的結(jié)構(gòu),要分區(qū)只能進(jìn)行范圍分區(qū)。

創(chuàng)建索引分區(qū)要參照表分區(qū)

四.分區(qū)技術(shù)簡(jiǎn)介

優(yōu)點(diǎn):

1.減少維護(hù)工作量

2.增強(qiáng)數(shù)據(jù)的可用性

3.均衡I/O,提升性能

4.提高查詢速度

5.分區(qū)對(duì)用戶保持透明,用戶感覺不到分區(qū)的存在。

五,管理表分區(qū)

1.添加表分區(qū)

ALTER TABLE...ALTER PARATITION

2.合并表分區(qū)

3.刪除分區(qū)

ALTER TABLE...DROP PARTITION

刪除分區(qū)時(shí),里面的數(shù)據(jù)也會(huì)被刪除。

-創(chuàng)建表和分區(qū)

create table sales--創(chuàng)建一個(gè)銷售記錄表

(

id number primary key,--記錄編號(hào)

goodsname varchar2(10),--商品名

saledate date--銷售日期

)

partition by range(saledate)--按照日期分區(qū)

(

--第一季度數(shù)據(jù)

partition part_sea1 values less than(to_date('2011-04-01','yyyy-mm-dd')) tablespace tbsp_1,

--第二季度數(shù)據(jù)

partition part_sea2 values less than(to_date('2011-07-01','yyyy-mm-dd')) tablespace tbsp_2,

--第三季度數(shù)據(jù)

partition part_sea3 values less than(to_date('2011-10-01','yyyy-mm-dd')) tablespace tbsp_1,

--第四季度數(shù)據(jù)

partition part_sea4 values less than(to_date('2012-01-01','yyyy-mm-dd')) tablespace tbsp_2

);

--創(chuàng)建局部索引

create index index_3_4 on sales(saledate)

local(

partition part_seal tablespace tbsp_1,

partition part_sea2 tablespace tbsp_2,

partition part_sea3 tablespace tbsp_1,

partition part_sea4 tablespace tbsp_2

);

--并入分區(qū)

alter table sales merge partitions part_sea3,part_sea4 into partition part_sea4;

--重建局部索引

alter table sales modify partition part_sea4 rebuild unusable local indexes;

六.管理索引分區(qū)

刪除索引:DROP PARTITION

重建分區(qū):REBUILT PARTITION

更名索引分區(qū):RENAME PARTITION

分割索引分區(qū):SPLIT PARTITION

Oracle創(chuàng)建分區(qū)表操作

1、創(chuàng)建語(yǔ)句

create table p(id number)

partition by range(id)

(partition p1 values less than(100) tablespace t1,

partition p2 values less than(200) tablespace t2,

partition p3 values less than(300) tablespace t3);

2、添加分區(qū)

alter table p add partition p4 values less than (400) tablespace t4;

3、清除分區(qū)數(shù)據(jù)

alter table p trunc partition p1;

4、刪除分區(qū)

alter table p drop partition p1;

Oracle 分區(qū)表如何添加分區(qū)

增加分區(qū)表的分區(qū)

ALTER TABLE AA ADD PARTITION SYS_P421 VALUES LESS THAN(TO_DATE('2017-05-21 00:00:00','YYYY-MM-DD HH24:MI:SS')) TABLESPACE USERS;

網(wǎng)站欄目:oracle怎么新增分區(qū),oracle新增分區(qū)后索引失效,重啟有用嗎?
文章鏈接:http://www.muchs.cn/article40/hssseo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、網(wǎng)站設(shè)計(jì)公司、企業(yè)建站、品牌網(wǎng)站制作、品牌網(wǎng)站設(shè)計(jì)、

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)