欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

oracle怎么建立分區(qū),oracle 建立分區(qū)表

ORACLE表分區(qū)

一.表分區(qū)策略

成都創(chuàng)新互聯(lián)是一家專(zhuān)注于成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作與策劃設(shè)計(jì),六安網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專(zhuān)注于網(wǎng)站建設(shè)十多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專(zhuān)業(yè)建站公司;建站業(yè)務(wù)涵蓋:六安等地區(qū)。六安做網(wǎng)站價(jià)格咨詢(xún):18980820575

1.識(shí)別大表

采用ANALYZE TABLE語(yǔ)句進(jìn)行分析,然后查詢(xú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,--銷(xiāo)售編號(hào)

retail_date date,--銷(xiāo)售日期

ware_name varchar2(50)--商品名稱(chēng)

)

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.提高查詢(xún)速度

5.分區(qū)對(duì)用戶(hù)保持透明,用戶(hù)感覺(jué)不到分區(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è)銷(xiāo)售記錄表

(

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

goodsname varchar2(10),--商品名

saledate date--銷(xiāo)售日期

)

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如何按照mod建分區(qū)

根據(jù)數(shù)據(jù)表字段值的范圍進(jìn)行分區(qū)。

創(chuàng)建完分區(qū)表后向表中添加一些數(shù)據(jù),declarenamevarchar2(10)。fractionnumber(5)。gradenumber(5)。inumber(8):=1。begin。foriin1。100000LOOP。當(dāng)我們的查詢(xún)語(yǔ)句不指定分區(qū)的時(shí)候,如果分區(qū)字段出現(xiàn)在where條件之后,Oracle會(huì)自動(dòng)根據(jù)字段值的范圍掃描響應(yīng)的分區(qū)。

oracle根據(jù)多字段創(chuàng)建分區(qū)表

最近有業(yè)務(wù)場(chǎng)景需要用多個(gè)字段做分區(qū)表,數(shù)據(jù)量比較大,保存時(shí)間也較長(zhǎng),經(jīng)過(guò)學(xué)習(xí)與實(shí)踐,算是基本完成,以下內(nèi)容為實(shí)踐樣例:

---建表語(yǔ)句

create table t_table

(

areacode varchar2(10),

appdate date,

text varchar(10)

)

partition by range(appdate)--根據(jù)字段 appdate 創(chuàng)建主分區(qū)

interval(numtoyminterval(1,'MONTH')) --主分區(qū)按 月 自動(dòng)創(chuàng)建分區(qū)

subpartition by list(areacode) --再按 地區(qū) 創(chuàng)建子分區(qū)

subpartition template( --指定明確的子分區(qū)信息

subpartition sub1 values('101'),

subpartition sub2 values('201'),

subpartition sub3 values('301')

)

(

partition mainpartition1 values less than(to_date('2019-04-01','yyyy-mm-dd'))--2019年4月1日前的放入mainpartition1分區(qū),之后的自動(dòng)分區(qū)

)

---模擬寫(xiě)入測(cè)試數(shù)據(jù)

insert into t_table values('101',to_date('2019-03-03','yyyy-mm-dd'),'a');

insert into t_table values('101',to_date('2019-02-03','yyyy-mm-dd'),'a');

insert into t_table values('101',to_date('2019-04-03','yyyy-mm-dd'),'a');

insert into t_table values('201',to_date('2019-03-03','yyyy-mm-dd'),'a');

insert into t_table values('201',to_date('2019-05-03','yyyy-mm-dd'),'a');

insert into t_table values('301',to_date('2019-04-01','yyyy-mm-dd'),'a');

--查詢(xún)數(shù)據(jù)

select * from t_table;

--查詢(xún)主分區(qū)數(shù)據(jù)

select *from t_table partition (mainpartition1);

--查詢(xún)子分區(qū)數(shù)據(jù)

select *from t_table subpartition (mainpartition1_sub1);

--查看自動(dòng)創(chuàng)建的主分區(qū)

select * from user_tab_partitions where table_name='T_TABLE'

當(dāng)前標(biāo)題:oracle怎么建立分區(qū),oracle 建立分區(qū)表
URL鏈接:http://chinadenli.net/article18/hescdp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google服務(wù)器托管網(wǎng)站排名ChatGPT定制網(wǎng)站域名注冊(cè)

廣告

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

搜索引擎優(yōu)化