GBase 8a建表时哈希hash分布列支持的字段类型

GBase 8a 版本支持整形(int,bigint),字符型(varchar)和decimal类型的字段,作为哈希hash分布列。

测试版本

8.6.2.43-R35.5
9.5.3.28.18

整形分布列

原则上,哈希hash分布列,使用int和bigint即可。其它的smallint和tinyint虽然语法上没报错,但从实际生产环境看,不建议使用。

int

gbase> create table td_int(id int,name varchar(100))distributed by('id');
Query OK, 0 rows affected (Elapsed: 00:00:00.23)

gbase> show create table td_int;
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table  | Create Table                                                                                                                                                                   |
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| td_int | CREATE TABLE "td_int" (
  "id" int(11) DEFAULT NULL,
  "name" varchar(100) DEFAULT NULL
) ENGINE=EXPRESS DISTRIBUTED BY('id') DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' |
+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

bigint

gbase> create table td_bigint(id bigint,name varchar(100))distributed by('id');
Query OK, 0 rows affected (Elapsed: 00:00:00.21)

gbase> show create table td_bigint;
+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table     | Create Table                                                                                                                                                                         |
+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| td_bigint | CREATE TABLE "td_bigint" (
  "id" bigint(20) DEFAULT NULL,
  "name" varchar(100) DEFAULT NULL
) ENGINE=EXPRESS DISTRIBUTED BY('id') DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' |
+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

smallint

gbase> create table td_smallint(id smallint,name varchar(100))distributed by('id');
Query OK, 0 rows affected (Elapsed: 00:00:00.24)

gbase> show create table td_smallint;
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table       | Create Table                                                                                                                                                                            |
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| td_smallint | CREATE TABLE "td_smallint" (
  "id" smallint(6) DEFAULT NULL,
  "name" varchar(100) DEFAULT NULL
) ENGINE=EXPRESS DISTRIBUTED BY('id') DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' |
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

字符型分布列

仅支持varchar类型,不支持char类型和text类型。

gbase> create table td_char(id tinyint,name char(100))distributed by('name');
ERROR 1721 (HY000): (GBA-02DD-0003) Type of distributed column 'name' is incorrect.
gbase>
gbase> create table td_text(id tinyint,name text)distributed by('name');
ERROR 1721 (HY000): (GBA-02DD-0003) Type of distributed column 'name' is incorrect.
gbase>

varchar

gbase> create table td_varchar(id tinyint,name varchar(100))distributed by('name');
Query OK, 0 rows affected (Elapsed: 00:00:00.20)

gbase> show create table td_varchar;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table      | Create Table                                                                                                                                                                            |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| td_varchar | CREATE TABLE "td_varchar" (
  "id" tinyint(4) DEFAULT NULL,
  "name" varchar(100) DEFAULT NULL
) ENGINE=EXPRESS DISTRIBUTED BY('name') DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase>

decimal分布列

gbase> create table td_decimal(id decimal(18,3),name text)distributed by('id');
Query OK, 0 rows affected (Elapsed: 00:00:00.22)

gbase> show create table td_decimal;
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table      | Create Table                                                                                                                                                        |
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| td_decimal | CREATE TABLE "td_decimal" (
  "id" decimal(18,3) DEFAULT NULL,
  "name" text
) ENGINE=EXPRESS DISTRIBUTED BY('id') DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' |
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)