暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

GBase 8a分区表指定特定分区的查询方法

墨天轮DB 2022-04-29
1050

语法

TABLENAME partition(PARTITION_NAME[,P2...])

说明

在表名字后面,通过partition关键字,指定分区名字,多个分区用逗号分割。

样例

表结构

CREATE TABLE "t_key_int" ( "id" int(11) DEFAULT NULL, "name" varchar(100) DEFAULT NULL, "birth" date DEFAULT NULL ) PARTITION BY KEY (id) (PARTITION p01 TABLESPACE = 'sys_tablespace' ENGINE = EXPRESS, PARTITION p02 TABLESPACE = 'sys_tablespace' ENGINE = EXPRESS)

数据

gbase> select * from t_key_int; +------+--------------------+------------+ | id | name | birth | +------+--------------------+------------+ | 7 | 444444444444444444 | 2021-03-08 | | 2 | 444444444444444444 | 2021-03-08 | | 4 | 444444444444444444 | 2021-03-08 | +------+--------------------+------------+ 3 rows in set (Elapsed: 00:00:00.01)

查询指定一个分区

gbase> select * from t_key_int partition(p01); +------+--------------------+------------+ | id | name | birth | +------+--------------------+------------+ | 7 | 444444444444444444 | 2021-03-08 | +------+--------------------+------------+ 1 row in set (Elapsed: 00:00:00.01) gbase> select * from t_key_int partition(p01) where id<10; +------+--------------------+------------+ | id | name | birth | +------+--------------------+------------+ | 7 | 444444444444444444 | 2021-03-08 | +------+--------------------+------------+ 1 row in set (Elapsed: 00:00:00.00)

查询指定多个分区

gbase> select * from t_key_int partition(p01,p02) where id<10; +------+--------------------+------------+ | id | name | birth | +------+--------------------+------------+ | 7 | 444444444444444444 | 2021-03-08 | | 2 | 444444444444444444 | 2021-03-08 | | 4 | 444444444444444444 | 2021-03-08 | +------+--------------------+------------+ 3 rows in set (Elapsed: 00:00:00.01)
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论