首页 > 数据库 >GBase 8c 兼容性-oracle分区语法

GBase 8c 兼容性-oracle分区语法

时间:2024-09-19 17:24:46浏览次数:3  
标签:hash 8c partition list id range oracle subpartition GBase

GBase 8c 分布式版本支持 兼容oracle 分区表功能,支持二级分区,9种分区组合,interval 分区。

分区明显如下:

GBase 8c 兼容性-oracle分区语法_oracle

hash分区sql 示例,与oracle写法一致。

-- 一级 hash 分区
drop table if exists mea_hash cascade;
create table mea_hash ( city_id int,logdate timestamp,id int )  partition by hash(id) ( partition p1 , partition p2 );
--二级分区 hash-list,hash-hash, hash-range
drop table if exists mea_hash_list cascade;
create table mea_hash_list ( city_id int,logdate timestamp,id int)  partition by hash(id) subpartition by list(city_id) ( partition p1  (subpartition p12 values (10),subpartition p13 values (20) ));
drop table if exists mea_hash_hash cascade;
create table mea_hash_hash ( city_id int,logdate timestamp,id int)  partition by hash(id) subpartition by hash(city_id) ( partition id_1  (subpartition p12 ,subpartition p13) );
drop table if exists mea_hash_range cascade;
create table mea_hash_range ( city_id int,logdate timestamp,id int)  partition by hash(id) subpartition by range(logdate) ( partition meas_y2021  (subpartition p12 values less than ('2021-02-04 12:00:00'),subpartition p13 values less than ('2021-02-04 20:00:00') ));

range分区sql 示例,与oracle写法一致。

drop table if exists mea_range cascade;
create table mea_range ( city_id int,logdate timestamp)  partition by range(logdate) ( partition meas_y2021 values less than  ('2021-01-01') );
--二级 range-range, range-hash,range-list
drop table if exists mea_range_range cascade;
create table mea_range_range ( city_id int,logdate timestamp,id int)  partition by range(logdate) subpartition  by range(id) ( partition meas_y2021 values less than ('2021-02-04 21:00:00') (subpartition p12 values less than (1),subpartition p13 values less than (10) ));
drop table if exists mea_range_hash cascade;
create table mea_range_hash ( city_id int,logdate timestamp,id int)  partition by range(logdate) subpartition by hash(city_id) ( partition id_1 values less than ('2021-02-01 01:00:00') (subpartition p12,subpartition p13) );
drop table if exists mea_range_list cascade;
create table mea_range_list ( city_id int,logdate timestamp,id int)  partition by range(logdate) subpartition by list(city_id) ( partition p1 values less than  ('2021-02-01 01:00:00') (subpartition p12 values (1),subpartition p13 values (20) ));

list 分区sql 示例,与oracle写法一致。

drop table if exists mea_list cascade;
create table mea_list ( city_id int,logdate timestamp,id int )  partition by list(id) ( partition p1 values (1), partition p2 values (2) );
--期望支持.成功执行
-- 二级 list-list,list-range,list-hash 分区
drop table if exists mea_list_list cascade;
create table mea_list_list ( city_id int,logdate timestamp,id int)  partition by  list(id) subpartition by list(city_id) ( partition p1 values (1) (subpartition p12 values (10),subpartition p13 values (20) ));
drop table if exists mea_list_range cascade;
create table mea_list_range ( city_id int,logdate timestamp,id int)  partition by  list(id) subpartition by range(logdate) ( partition meas_y2021 values ('202102') (subpartition p12 values less than ('2021-02-04 12:00:00'),subpartition p13 values less than ('2021-02-04 20:00:00') ));
drop table if exists mea_list_hash cascade;
create table mea_list_hash ( city_id int,logdate timestamp,id int)  partition by  list(id) subpartition by hash(city_id) ( partition id_1 values (2021) (subpartition p12,subpartition p13) );

其他分区语法,drop子分区,rename,拆分子分区等兼容新oracle语法。

-- 创建分区表,分区键是integer类型
CREATE TABLE tpcds.startend_pt (c1 INT, c2 INT) 
TABLESPACE startend_tbs1 
PARTITION BY RANGE (c2) (
   PARTITION p1 START(1) END(1000) EVERY(200) TABLESPACE startend_tbs2,
   PARTITION p2 END(2000),
   PARTITION p3 START(2000) END(2500) TABLESPACE startend_tbs3,
   PARTITION p4 START(2500),
   PARTITION p5 START(3000) END(5000) EVERY(1000) TABLESPACE startend_tbs4
)
ENABLE ROW MOVEMENT;
-- 查看分区表信息
SELECT relname, boundaries, spcname FROM pg_partition p JOIN pg_tablespace t ON p.reltablespace=t.oid and p.parentid='tpcds.startend_pt'::regclass ORDER BY 1;

-- 导入数据,查看分区数据量
INSERT INTO tpcds.startend_pt VALUES (GENERATE_SERIES(0, 4999), GENERATE_SERIES(0, 4999));
SELECT COUNT(*) FROM tpcds.startend_pt PARTITION FOR (0);

SELECT COUNT(*) FROM tpcds.startend_pt PARTITION (p3);
-- 增加分区: [5000, 5300), [5300, 5600), [5600, 5900), [5900, 6000)
ALTER TABLE tpcds.startend_pt ADD PARTITION p6 START(5000) END(6000) EVERY(300) TABLESPACE startend_tbs4;
-- 增加MAXVALUE分区: p7
ALTER TABLE tpcds.startend_pt ADD PARTITION p7 END(MAXVALUE);
-- 重命名分区p7为p8
ALTER TABLE tpcds.startend_pt RENAME PARTITION p7 TO p8;
-- 删除分区p8
ALTER TABLE tpcds.startend_pt DROP PARTITION p8;
-- 重命名5950所在的分区为:p71
ALTER TABLE tpcds.startend_pt RENAME PARTITION FOR(5950) TO p71;
-- 分裂4500所在的分区[4000, 5000)
ALTER TABLE tpcds.startend_pt SPLIT PARTITION FOR(4500) INTO(PARTITION q1 START(4000) END(5000) EVERY(250) TABLESPACE startend_tbs3);
-- 修改分区p2的表空间为startend_tbs4
ALTER TABLE tpcds.startend_pt MOVE PARTITION p2 TABLESPACE startend_tbs4;

标签:hash,8c,partition,list,id,range,oracle,subpartition,GBase
From: https://blog.51cto.com/u_17026136/12058060

相关文章

  • GBase 8s 自定义split_part函数
    gbase数据该函数的功能:以第二个参数separator_in分隔第一个参数str_in,返回第三个参数field_in指定字段。dropfunctionifexistssplit_part2;createfunctionsplit_part2(str_inlvarchar(2048),separator_inchar(1),field_inint)returningvarchar(255);def......
  • GBase 8s数据库连接 – Perl(DBD::ODBC)
    软件需求:1,GBase8sCSDK2,perl-5.16.3及perl-devel-5.16.33,unixODBC-2.3.14,DBD-ODBC-1.60###1,系统环境确认####1.1perl、perl-devel及unixODBC版本Linux下root用户通过rpm确认perl、perl-devel,unixODBC、unixODBC-devel均已经安装,如下:[root@rhel7u6~]#rpm-qaperlperl......
  • 提升IT效率:Oracle数据库一键安装,让运维变得简单又快速!
    此脚本针对11.2.0,其他版本oracle类似。脚本执行的所有步骤定义Oracle安装所需的变量。打印本机主机名、内存大小、OracleSID以及为内核shmmax和shmall设置的值。提示用户将Oracle数据库安装包放置在特定目录。创建swap空间。安装EPEL仓库和NTP服务,同步时间。关......
  • Oracle静态监听中SID_NAME区分大小写吗?
    如果静态监听中ORACLE_SID不注意大小写的话,可能导致数据库连接不上的问题。如下案例所示:$ sqlplus system/***@GPSUATSQL*Plus: Release 19.0.0.0.0 - Production on Wed Sep 18 15:48:37 2024Version 19.24.0.0.0Copyright (c) 1982, 2024, Oracle.  All r......
  • GBase8a数据库nmon监控CPU利用率
    实时监控[gbase@xxx-node-1~]$nmon交互命令:h:帮助q:退出c:监控CPU利用率m:监控内存使用情况d:监控磁盘使用率V:监控虚拟内存n:监控网络k:监控内核后台监控上面的快捷命令只能将当前的系统资源实时显示在屏幕下,无法保存到文件中,如果要将结果保存到文件进行分析,需要用到命令行......
  • GBase 8a数据库清理日志释放空间
    日志清理的目的是为了释放磁盘存储空间。对于重要日志信息,运维人员可以先考虑备份后再做清理。日常巡检中,考虑清理的日志有:1、所有管理节点的gc_recover日志gc_recover进程服务是集群数据一致性同步服务,在各gcluster节点上运行。集群在执行DDL、DML语句时,因某种原因,出现......
  • GBase 8a数据库故障排查思路
    GBase8a数据库故障排查思路一、监控进程集群默认运行gcmonit进程用来监控gcluster、gcware、gcrecover、gcmmonit、gbase、syncserver进程,当这些进程意外down掉,gcmonit进程会自动将这些进程拉起。同时,gcmmonit进程又会监控gcmonit进程,当gcmonit进程down掉,gcmmoni......
  • GBase 8a数据库关键日志
    GBase8a关键日志1、System日志:记录数据库服务启动、停止等重要操作,并可记录数据库服务宕机等异常情况的程序堆栈,可辅助开发人员查错。默认开启。System日志分类及默认存放位置:gcluster系统日志:$GCLUSTER_BASE/log/gcluster/system.loggnode系统日志:$GBASE_BASE/log/gba......
  • GBase 8a MPP Cluster 数据库产品的巡检
    GBase8aMPPCluster产品的巡检一般包含以下几个方面工作:1、检查数据库的接入情况2、检查数据库状态3、检查Core文件或dump文件4、检查系统情况(1)查看数据库连接巡检的第一步就是要验证数据库是否可访问。数据库可访问代表数据库客户端和服务端的网络端口和服务正常。......
  • GBase 8a数据库集群部署硬件环境需求
    GBase8aMPPCluster具有多样化的平台选择,可完全使用低成本的x86架构的PCServer;也支持云平台、虚拟机环境的部署。随着国产服务器、国产CPU的发展,也支持在申威、龙芯、兆芯、鲲鹏、飞腾等的国产服务器上部署。GBase8aMPPCluster支持64位计算机操作系统平台上,支......