GBase 8a集群v953版本自增列介绍

GBase 8a集群验证版本

GBase8a_MPP_Cluster-NoLicense-9.5.3.23.2-redhat7-x86_64.tar.bz2

集群拓扑结果

[gbase@localhost ~]$ gcadmin showdistribution vc vc1

                                 Distribution ID: 1 | State: new | Total segment num: 2

             Primary Segment Node IP                   Segment ID                 Duplicate Segment node IP
========================================================================================================================
|                 192.168.255.3                  |         1          |                 192.168.255.2                  |
------------------------------------------------------------------------------------------------------------------------
|                 192.168.255.2                  |         2          |                 192.168.255.3                  |
========================================================================================================================

自增列功能

简要介绍

GBase 8a集群自增列是指定 auto_increment 属性的列,自增列的列值单调递增(不保证连续)。自增列支持在以下数据类型的列上使用:tinyint、smallint、int、bigint。自增列可以唯一识别表中每一条记录,可方便用于查询、修改、删除等操作。

  • 自增起始值:空表插入时,自增列的第一个值。
  • 自增基值:自增列前一次插入的最大值。
  • 自增步长:自增列数据入库时,下一行数据针对前一行数据的增量值。

集群自增列不允许指定自增列起始值,基值,步长参数,由集群自动维护。

自增列创建语法

自增列创建的语法如下:

create [temporary] table [if not exists] tbl_name (create_definition,...)
create_definition:
	col_name column_definition
	column_definition:
		data_type [not null] [default default_value]
		[auto_increment] [primary key]

创建自增列

创建自增列:

gbase> create table test_auto_increment(test_col int auto_increment primary key);
Query OK, 0 rows affected (Elapsed: 00:00:00.07)
gbase> show create table test_auto_increment;
+---------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table               | Create Table                                                                                                                                                                    |
+---------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| test_auto_increment | CREATE TABLE "test_auto_increment" (
  "test_col" int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY ("test_col")
) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' |
+---------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)
  • 非tinyint、smallint、int、bigint类型创建自增列报错:
gbase> create table test_auto_increment(test_col varchar(10) auto_increment);
ERROR 1063 (42000): Incorrect column specifier for column 'test_col'
gbase> create table test_auto_increment
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值