<del id="d4fwx"><form id="d4fwx"></form></del>
      <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

            <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
          • oracle分區(qū)怎么建,oracle 建分區(qū)

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

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

            在大觀等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供做網(wǎng)站、成都做網(wǎng)站 網(wǎng)站設(shè)計(jì)制作定制網(wǎng)站制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),高端網(wǎng)站設(shè)計(jì),成都營銷網(wǎng)站建設(shè),外貿(mào)網(wǎng)站制作,大觀網(wǎng)站建設(shè)費(fèi)用合理。

            ---建表語句

            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ū)

            )

            ---模擬寫入測試數(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');

            --查詢數(shù)據(jù)

            select * from t_table;

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

            select *from t_table partition (mainpartition1);

            --查詢子分區(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'

            oracle11g自動(dòng)分區(qū)

            在Oracle10g中,沒有定義間隔分區(qū),只能通過范圍分區(qū)實(shí)現(xiàn)間隔分區(qū)功能,如果要實(shí)現(xiàn)自動(dòng)創(chuàng)建分區(qū),只能通過創(chuàng)建JOB或者scheduler來實(shí)現(xiàn);而在11g中,Oracle直接提供了間隔分區(qū)功能,大大簡化了間隔分區(qū)的實(shí)現(xiàn)。

            ----注:oracle11g雖然可以自動(dòng)分區(qū),但是分區(qū)的名字不能自定義,對于需要定時(shí)刪除分區(qū)時(shí)沒法處理,不如通過時(shí)間范圍來手工分區(qū)。詳見

            create table HIP_LOG_NODE_Part

            (

            ID?????????????????? VARCHAR2(32)???????? not null,

            RECORD_TIME????????? DATE

            )tablespace TB_HIP_LOG_NODE

            PARTITION BY RANGE (RECORD_TIME) interval (numtoyminterval(1, 'month'))

            STORE IN (TB_HIP_LOG_NODE)

            (

            partition hip_log_node_partition values less than (to_date('2019-08-01 00:00','yyyy-MM-dd HH24:mi')) tablespace TB_HIP_LOG_NODE

            );

            1、Oracle11g有間隔分區(qū)功能,對于使用Range分區(qū)的可以按年,月,日來自動(dòng)生成分區(qū)。

            2、2019-08-01前的數(shù)據(jù)(包含8月份的數(shù)據(jù))會(huì)放入hip_log_node_partition?分區(qū),8月1日后的數(shù)據(jù)每月只要有數(shù)據(jù),就會(huì)自動(dòng)創(chuàng)建一個(gè)分區(qū)。也就是從9月開始,開始新建分區(qū)。

            3、interval函數(shù)--將數(shù)值按標(biāo)準(zhǔn)換算為日期

            numtodsinterval、numtodsinterval函數(shù),將數(shù)字轉(zhuǎn)成年月,時(shí)分秒

            詳見:

            4、查看表分區(qū) select table_name,partition_name from user_tab_partitions where table_name='INTERVAL_SALES';

            5、插入數(shù)據(jù)再次查看分區(qū),詳見:

            6、修改分區(qū)、合并分區(qū)、拆分分區(qū),詳見 :

            7、創(chuàng)建索引(分區(qū)索引、全局索引) :

            非分區(qū)字段創(chuàng)建主鍵,則創(chuàng)建主鍵local索引時(shí)必須加上分區(qū)字段

            ALTER TABLE TEST ADD CONSTRAINT PK_TEST PRIMARY KEY (主鍵字段,分區(qū)字段) USING INDEX LOCAL;

            8、oracle 10g創(chuàng)建表分區(qū)

            9、刪除

            1.不保留,直接刪除:

            alter table table_name drop/truncate partition partition_name;

            具體用drop還是truncate,得你自己衡量,drop的話原來的分區(qū)和數(shù)據(jù)直接就沒有了,truncate的話,只是數(shù)據(jù)沒有了,分區(qū)還在。

            ORACLE表分區(qū)

            一.表分區(qū)策略

            1.識別大表

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

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

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

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

            要對每個(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,--銷售編號

            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ù)簡介

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

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

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

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

            4.提高查詢速度

            5.分區(qū)對用戶保持透明,用戶感覺不到分區(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,--記錄編號

            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

            網(wǎng)站標(biāo)題:oracle分區(qū)怎么建,oracle 建分區(qū)
            標(biāo)題網(wǎng)址:http://www.jbt999.com/article26/heeijg.html

            成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、面包屑導(dǎo)航、網(wǎng)站制作網(wǎng)站營銷

            廣告

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

            成都網(wǎng)頁設(shè)計(jì)公司

              <del id="d4fwx"><form id="d4fwx"></form></del>
              <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

                    <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
                  • 日批视频在线 | 黄色电影一级片和小说免费看 | 中文字幕一区二区三区润滑油 | 操鼻视频素材网站直接 | 97人妻人人揉人人躁 |