创建分区表+分区表的分类+创建散列分区表+查看散列分区表分区中的数据+创建列表分区表+查看列表分区表分区中的数据...
創(chuàng)建分區(qū)表
分區(qū)表的分類(lèi)
范圍分區(qū):對(duì)數(shù)據(jù)表的某個(gè)值的范圍進(jìn)行分區(qū),需要使用partition by range字句。
散列分區(qū):
1通過(guò)hash算法均勻分布數(shù)據(jù)的一種分區(qū)類(lèi)型。
2通過(guò)在I/O設(shè)備上進(jìn)行散列分區(qū),可以使得分區(qū)的大小一致。
3創(chuàng)建散列分區(qū)需要使用partition by hash字句。
列表分區(qū):
1適用于分區(qū)列的值為非數(shù)字或者日期數(shù)據(jù)類(lèi)型,并且分區(qū)列的取值范圍較少時(shí)使用。
舉例:成績(jī)表的科目列取值較少,就可以使用列表分區(qū)。
2需要使用partition by list字句。
3分區(qū)時(shí),需要為每個(gè)分區(qū)指定取值列表,分區(qū)列的取值處于同一個(gè)列表中的行將被存儲(chǔ)到同一個(gè)分區(qū)中。
組合范圍散列分區(qū):
組合范圍列表分區(qū):
舉例
創(chuàng)建散列分區(qū)表
create table student_hash(
sno varchar2(10) ,
sname varchar2(20),
sage number(2),
score number(2)
)partition by hash(sno)–散列分區(qū)表
(
partition part1 tablespace myspace,
partition part2 tablespace users
);
insert into student_hash values(‘1’,’我叫分區(qū)1’,12,55);
insert into student_hash values(‘2’,’我叫分區(qū)1’,12,56);
insert into student_hash values(‘3’,’我叫分區(qū)2’,12,76);
insert into student_hash values(‘4’,’我叫分區(qū)3’,12,86);
查看散列分區(qū)表分區(qū)中的數(shù)據(jù)
select * from student_hash partition(part1);
select * from student_hash partition(part2);
創(chuàng)建列表分區(qū)表
create table student_list(
sno varchar2(10) ,
ssex varchar2(2),
sage number(2),
score number(2)
)partition by list(ssex)–列表分區(qū)表
(
partition part1 values(‘男’) tablespace myspace,
partition part2 values(‘女’) tablespace users
);
insert into student_list values(‘1’,’男’,12,55);
insert into student_list values(‘2’,’男’,12,56);
insert into student_list values(‘3’,’女’,12,76);
insert into student_list values(‘4’,’女’,12,86);
查看列表分區(qū)表分區(qū)中的數(shù)據(jù)
select * from student_list partition(part1);
select * from student_list partition(part2);
轉(zhuǎn)載于:https://www.cnblogs.com/feiZhou/p/9344281.html
總結(jié)
以上是生活随笔為你收集整理的创建分区表+分区表的分类+创建散列分区表+查看散列分区表分区中的数据+创建列表分区表+查看列表分区表分区中的数据...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 看完你就知道什么是 HTTPS 了
- 下一篇: #每日播报# 8月6日 Github 热