随笔 - 136, 文章 - 0, 评论 - 14, 阅读 - 13万
  首页  :: 新随笔  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

OceanBase表分组

Posted on   高&玉  阅读(78)  评论(0编辑  收藏  举报

创建表分组

创建表分组

mysql> create tablegroup my_group partition by hash partitions 6;
Query OK, 0 rows affected (2.33 sec)

查看表分组:可以看到该表分组属于哪个数据库、表分组中包含哪些表信息

mysql> show tablegroups where tablegroup_name='my_group';
+-----------------+------------+---------------+
| Tablegroup_name | Table_name | Database_name |
+-----------------+------------+---------------+
| my_group        | NULL       | NULL          |
+-----------------+------------+---------------+

查看表分组create语句

mysql> show create tablegroup my_group;
+------------+-------------------------------------------------------------------------------+
| Tablegroup | Create Tablegroup                                                             |
+------------+-------------------------------------------------------------------------------+
| my_group   | CREATE TABLEGROUP IF NOT EXISTS `my_group` 
  partition by hash partitions 6
 |
+------------+-------------------------------------------------------------------------------+

创建表指定表分组

创建表时指定表分组

创建表并指定表分组

mysql> create table t1(id int not null auto_increment primary key,name varchar(30)) tablegroup my_group partition by hash(id) partitions 6;

查看表分组:可以看到该表分组属于哪个数据库、表分组中包含哪些表信息

mysql> show tablegroups where tablegroup_name='my_group';
+-----------------+------------+---------------+
| Tablegroup_name | Table_name | Database_name |
+-----------------+------------+---------------+
| my_group        | t1         | oceanbase     |
+-----------------+------------+---------------+

ALTER TABLE指定表分组

创建表

create table t2(id int not null primary key,name varchar(30)) partition by hash(id) partitions 6;

查看表分组my_group

mysql> show tablegroups where tablegroup_name='my_group';
+-----------------+------------+---------------+
| Tablegroup_name | Table_name | Database_name |
+-----------------+------------+---------------+
| my_group        | t1         | oceanbase     |
+-----------------+------------+---------------+

添加表t2到表分组my_group中

alter table t2 tablegroup='my_group';

查看表分组my_group

mysql> show tablegroups where tablegroup_name='my_group';
+-----------------+------------+---------------+
| Tablegroup_name | Table_name | Database_name |
+-----------------+------------+---------------+
| my_group        | t1         | oceanbase     |
| my_group        | t2         | oceanbase     |
+-----------------+------------+---------------+

ALTER TABLEGROUP指定表分组 

创建表

create table t3(id int not null primary key,name varchar(30)) partition by hash(id) partitions 6;

查看表分组my_group

mysql> show tablegroups where tablegroup_name='my_group';
+-----------------+------------+---------------+
| Tablegroup_name | Table_name | Database_name |
+-----------------+------------+---------------+
| my_group        | t1         | oceanbase     |
| my_group        | t2         | oceanbase     |
+-----------------+------------+---------------+

 添加表t3到表分组my_group中

alter tablegroup my_group add t3;

查看表分组my_group

mysql> show tablegroups where tablegroup_name='my_group';
+-----------------+------------+---------------+
| Tablegroup_name | Table_name | Database_name |
+-----------------+------------+---------------+
| my_group        | t1         | oceanbase     |
| my_group        | t2         | oceanbase     |
| my_group        | t3         | oceanbase     |
+-----------------+------------+---------------+

 

相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示