搜尋
首頁資料庫mysql教程Mysql分區和Oracle10個分區的差異詳解

MySQL分割區常用的是:range、list、hash、key,Oracle10g分割區常用的是:range(範圍分割區)、list(清單分割區)、hash(雜湊分割區)、range- hash(範圍—哈希分區)、range-list(列表—複合分區)。以下透過本文詳細介紹Oracle10個分割區和Mysql分割區區別,一起看看

Oracle10g分割區常用的是:range(範圍分割區)、list(清單分割區)、hash(雜湊分割區)、range -hash(範圍—哈希分區)、range-list(列表—複合分區)。

Range分區:Range分區是應用範圍比較廣的表格分區方式,它是以列的值的範圍來做為分區的劃分條件,將記錄存放到列值所在的range分區中。

        如依時間劃分,2010年1月的資料放到a分區,2月的資料放到b分區,在建立的時候,則需要指定基於的列,以及分區的範圍值。

       以時間分區時,如果某些記錄暫無法預測範圍,可以建立maxvalue分區,所有不在指定範圍內的記錄都會儲存到maxvalue所在分區。如:

createtable pdba (id number, time date) partition by range (time)
(
partitionp1 values less than (to_date('2010-10-1', 'yyyy-mm-dd')),
partitionp2 values less than (to_date('2010-11-1', 'yyyy-mm-dd')),
partitionp3 values less than (to_date('2010-12-1', 'yyyy-mm-dd')),
partitionp4 values less than (maxvalue)
)

Hash分區:

  對於那些無法有效劃分範圍的表,可以使用hash分區,這樣對於提高效能還是會有一定的幫助。 hash分區會將表中的資料平均分配到你指定的幾個分區中,列所在分區是依據分區列的hash值自動分配,因此你並不能控制也不知道哪筆記錄會被放到哪個分區中,hash分區也可以支援多個依賴列。如:

createtable test
(
transaction_idnumber primary key,
item_idnumber(8) not null
)
partitionby hash(transaction_id)
(
partitionpart_01 tablespace tablespace01,
partitionpart_02 tablespace tablespace02,
partitionpart_03 tablespace tablespace03
);

在這裡,我們指定了每個分割區的表空間。

List分割區:

  List分割區也需要指定列的值,其分割區值必須明確指定,而分割區列只能有一個,不能像range或hash分區那樣同時指定多個列做為分區依賴列,但它的單一分區對應值可以是多個。

  在分區時必須確定分區列可能存在的值,一旦插入的列值不在分區範圍內,則插入/更新就會失敗,因此通常建議使用list分區時,若要建立default分割區儲存那些不在指定範圍內的記錄,類似range分割區中的maxvalue分割區。

     根據某字段,如城市代碼分區時,可以指定default,把非分區規則的數據,全部放到這個default分區。如:

createtable custaddr
(
idvarchar2(15 byte) not null,
areacodevarchar2(4 byte)
)
partitionby list (areacode)
(partition t_list025 values ('025'),
partitiont_list372 values ('372') ,
partitiont_list510 values ('510'),
partitionp_other values (default)
)

組合分區:

      若某表格依照某列分區之後,仍較大,或是一些其它的需求,也可以透過分區內再建子分區的方式將分區再分區,即組合分區的方式。

  組合分區呢在10g中有兩種:range-hash,range-list。注意順序,根分區只能是range分區,子分區可以是hash分區或list分區。

如:

createtable test
(
transaction_idnumber primary key,
transaction_datedate
)
partitionby range(transaction_date) subpartition by hash(transaction_id)
subpartitions3 store in (tablespace01,tablespace02,tablespace03)
(
partitionpart_01 values less than(to_date('2009-01-01','yyyy-mm-dd')),
partitionpart_02 values less than(to_date('2010-01-01','yyyy-mm-dd')),
partitionpart_03 values less than(maxvalue)
);
createtable emp_sub_template (deptno number, empname varchar(32), grade number)
partitionby range(deptno) subpartition by hash(empname)
subpartitiontemplate
(subpartitiona tablespace ts1,
subpartitionb tablespace ts2,
subpartitionc tablespace ts3,
subpartitiond tablespace ts4
)
(partitionp1 values less than (1000),
partitionp2 values less than (2000),
partitionp3 values less than (maxvalue)
);
createtable quarterly_regional_sales
(deptnonumber, item_no varchar2(20),
txn_datedate, txn_amount number, state varchar2(2))
tablespacets4
partitionby range (txn_date)
subpartitionby list (state)
(partitionq1_1999 values less than (to_date('1-apr-1999','dd-mon-yyyy'))
(subpartitionq1_1999_northwest values ('or', 'wa'),
subpartitionq1_1999_southwest values ('az', 'ut', 'nm'),
subpartitionq1_1999_northeast values ('ny', 'vm', 'nj'),
subpartitionq1_1999_southeast values ('fl', 'ga'),
subpartitionq1_1999_northcentral values ('sd', 'wi'),
subpartitionq1_1999_southcentral values ('ok', 'tx')
),
partitionq2_1999 values less than ( to_date('1-jul-1999','dd-mon-yyyy'))
(subpartitionq2_1999_northwest values ('or', 'wa'),
subpartitionq2_1999_southwest values ('az', 'ut', 'nm'),
subpartitionq2_1999_northeast values ('ny', 'vm', 'nj'),
subpartitionq2_1999_southeast values ('fl', 'ga'),
subpartitionq2_1999_northcentral values ('sd', 'wi'),
subpartitionq2_1999_southcentral values ('ok', 'tx')
),
partitionq3_1999 values less than (to_date('1-oct-1999','dd-mon-yyyy'))
(subpartitionq3_1999_northwest values ('or', 'wa'),
subpartitionq3_1999_southwest values ('az', 'ut', 'nm'),
subpartitionq3_1999_northeast values ('ny', 'vm', 'nj'),
subpartitionq3_1999_southeast values ('fl', 'ga'),
subpartitionq3_1999_northcentral values ('sd', 'wi'),
subpartitionq3_1999_southcentral values ('ok', 'tx')
),
partitionq4_1999 values less than ( to_date('1-jan-2000','dd-mon-yyyy'))
(subpartitionq4_1999_northwest values ('or', 'wa'),
subpartitionq4_1999_southwest values ('az', 'ut', 'nm'),
subpartitionq4_1999_northeast values ('ny', 'vm', 'nj'),
subpartitionq4_1999_southeast values ('fl', 'ga'),
subpartitionq4_1999_northcentral values ('sd', 'wi'),
subpartitionq4_1999_southcentral values ('ok', 'tx')
)
);

MySQL分區常用的是:range、list、hash、key

     RANGE分區(portioning):根據列值所屬的範圍區間,將元群組分配到各個分區。

    LIST分區:類似於按RANGE分區,差異在於LIST分區是基於列值來匹配一個離散值集合中的某個值來進行選擇。

    HASH分區:根據使用者定義的函數的回傳值來進行選擇的分區,該表達式使用將要插入表中的這些行的列值進行計算。這個函數可以包含MySQL 中有效的、產生非負整數值的任何表達式。

    KEY分區:類似依HASH分區,差別在於KEY分區只支援計算一列或多列,且MySQL 伺服器提供自己的雜湊函數。

以上是Mysql分區和Oracle10個分區的差異詳解的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
在MySQL中使用視圖的局限性是什麼?在MySQL中使用視圖的局限性是什麼?May 14, 2025 am 12:10 AM

mysqlviewshavelimitations:1)他們不使用Supportallsqloperations,限制DatamanipulationThroughViewSwithJoinsOrsubqueries.2)他們canimpactperformance,尤其是withcomplexcomplexclexeriesorlargedatasets.3)

確保您的MySQL數據庫:添加用戶並授予特權確保您的MySQL數據庫:添加用戶並授予特權May 14, 2025 am 12:09 AM

porthusermanagementinmysqliscialforenhancingsEcurityAndsingsmenting效率databaseoperation.1)usecReateusertoAddusers,指定connectionsourcewith@'localhost'or@'%'。

哪些因素會影響我可以在MySQL中使用的觸發器數量?哪些因素會影響我可以在MySQL中使用的觸發器數量?May 14, 2025 am 12:08 AM

mysqldoes notimposeahardlimitontriggers,butacticalfactorsdeterminetheireffactective:1)serverConfiguration impactactStriggerGermanagement; 2)複雜的TriggerSincreaseSySystemsystem load; 3)largertablesslowtriggerperfermance; 4)highConconcConcrencerCancancancancanceTigrignecentign; 5); 5)

mysql:存儲斑點安全嗎?mysql:存儲斑點安全嗎?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

mySQL:通過PHP Web界面添加用戶mySQL:通過PHP Web界面添加用戶May 14, 2025 am 12:04 AM

通過PHP網頁界面添加MySQL用戶可以使用MySQLi擴展。步驟如下:1.連接MySQL數據庫,使用MySQLi擴展。 2.創建用戶,使用CREATEUSER語句,並使用PASSWORD()函數加密密碼。 3.防止SQL注入,使用mysqli_real_escape_string()函數處理用戶輸入。 4.為新用戶分配權限,使用GRANT語句。

mysql:blob和其他無-SQL存儲,有什麼區別?mysql:blob和其他無-SQL存儲,有什麼區別?May 13, 2025 am 12:14 AM

mysql'sblobissuitableForStoringBinaryDataWithInareLationalDatabase,而ilenosqloptionslikemongodb,redis和calablesolutionsolutionsolutionsoluntionsoluntionsolundortionsolunsonstructureddata.blobobobissimplobisslowdeperformberbutslowderformandperformancewithlararengedata;

mySQL添加用戶:語法,選項和安全性最佳實踐mySQL添加用戶:語法,選項和安全性最佳實踐May 13, 2025 am 12:12 AM

toaddauserinmysql,使用:createUser'username'@'host'Indessify'password'; there'showtodoitsecurely:1)choosethehostcarecarefullytocon trolaccess.2)setResourcelimitswithoptionslikemax_queries_per_hour.3)usestrong,iniquepasswords.4)Enforcessl/tlsconnectionswith

MySQL:如何避免字符串數據類型常見錯誤?MySQL:如何避免字符串數據類型常見錯誤?May 13, 2025 am 12:09 AM

toAvoidCommonMistakeswithStringDatatatPesInMysQl,CloseStringTypenuances,chosethirtightType,andManageEngencodingAndCollat​​ionsEttingSefectery.1)usecharforfixed lengengtrings,varchar forvariable-varchar forbariaible length,andtext/blobforlargerdataa.2 seterters seterters seterters

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。