当前位置:网站首页>gbase8s创建RANGE分片表
gbase8s创建RANGE分片表
2022-08-04 18:15:00 【wangwei830】
创建RANGE分片表
CREATE TABLE employee
(
id INTEGER,
name CHAR(32),
basepay DECIMAL (10,2),
varpay DECIMAL (10,2),
dept CHAR(2),
hiredate DATE)
FRAGMENT BY RANGE (id)
INTERVAL (100) STORE IN (datadbs01)
PARTITION p0 VALUES IS NULL IN datadbs01,
PARTITION p1 VALUES < 200 IN datadbs01,
PARTITION p2 VALUES < 400 IN datadbs01;
插入数据
drop procedure IF EXISTS proc8;
create procedure proc8(p_in int) ;
define i int;
let i = 1;
while(i<=p_in) loop
insert into employee values(
i,
'aa',
3.14,
31.4,
'bb',
current
);
exit when i = p_in;
let i = i + 1;
end loop;
end procedure;
分片结果
#分片表达式
FRAGMENT BY RANGE (id)
INTERVAL (100) STORE IN (datadbs01)
PARTITION p0 VALUES IS NULL IN datadbs01,
PARTITION p1 VALUES < 200 IN datadbs01,
PARTITION p2 VALUES < 400 IN datadbs01;
#执行这样两次插入
> call proc8(10);
> call proc8(1000);
#结果如下:
gbasedbt[hdr2]$oncheck -pt db01:employee |grep partitio
Table fragment partition p0 in DBspace datadbs01
Table fragment partition p1 in DBspace datadbs01
Table fragment partition p2 in DBspace datadbs01
Table fragment partition sys_p3 in DBspace datadbs01
Table fragment partition sys_p4 in DBspace datadbs01
Table fragment partition sys_p5 in DBspace datadbs01
Table fragment partition sys_p6 in DBspace datadbs01
Table fragment partition sys_p7 in DBspace datadbs01
Table fragment partition sys_p8 in DBspace datadbs01
Table fragment partition sys_p9 in DBspace datadbs01
gbasedbt[hdr2]$
gbasedbt[hdr2]$oncheck -pt db01:employee |grep "Number of rows"
Number of rows 0
Number of rows 209
Number of rows 200
Number of rows 100
Number of rows 100
Number of rows 100
Number of rows 100
Number of rows 100
Number of rows 100
Number of rows 1
gbasedbt[hdr2]$
#这个一行数据是1000
gbasedbt[hdr2]$oncheck -pP 3 4928
addr stamp chksum nslots flag type frptr frcnt next prev
3:4928 402653 3798 1 801 DATA 78 16298 0 0
slot ptr len flg
1 24 54 0
slot 1:
0: 0 0 3 e8 61 61 20 20 20 20 20 20 20 20 20 20 ...haa
16: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
32: 20 20 20 20 c1 3 e 0 0 0 c1 1f 28 0 0 0 A.....A.(...
48: 62 62 0 0 ae e3 bb...c..........
gbasedbt[hdr2]$printf "%d\n" 0x3e8
1000
gbasedbt[hdr2]$
小结: RANGE分片表,自动扩充分片。range规则是一说,指定规则则是更高优先级的一说。
边栏推荐
猜你喜欢
随机推荐
情绪的波动起伏
July 31, 2022 Summary of the third week of summer vacation
Babbitt | Metaverse daily must-read: Weibo animation will recruit all kinds of virtual idols around the world and provide support for them...
2022年7月31日 暑假第三周总结
什么是网站监控,网站监控软件有什么用?
npm配置国内镜像(淘宝镜像)
老电脑怎么重装系统win10
Iptables防火墙基础知识介绍
FE01_OneHot-Scala Application
巴比特 | 元宇宙每日必读:微博动漫将招募全球各类虚拟偶像并为其提供扶持...
Google AppSheet: 无需编程构建零代码应用
2019年海淀区青少年程序设计挑战活动小学组复赛试题详细答案
DOM Clobbering的原理及应用
合宙Cat1 4G模块Air724UG配置RNDIS网卡或PPP拨号,通过RNDIS网卡使开发板上网(以RV1126/1109开发板为例)
Interval greedy (interval merge)
Flask framework implementations registered encryption, a Flask enterprise class learning 】 【
EasyCVR calls the cloud recording API and returns an error and no recording file is generated. What is the reason?
Thrift installation configuration
PT100铂热电阻三种测温方法介绍
OpenInfra Days China 2022|SelectDB与你共享 Apache Doris 在互联网广告业务中的实践