GBase 8a的注释comment 功能介绍,更新注释的方法,最大长度限制 您所在的位置:网站首页 修改字段注释的sql GBase 8a的注释comment 功能介绍,更新注释的方法,最大长度限制

GBase 8a的注释comment 功能介绍,更新注释的方法,最大长度限制

2024-06-29 03:17| 来源: 网络整理| 查看: 265

GBase 8a数据库集群支持表的注释comment ,字段的注释,本文介绍表创建时的注释以及表注释和字段注释的装修。

建表

在建表语句里,直接在字段和表定义后面,加上comment 关键字,后面加上字符串即可。

根据现有规定,comment的最大长度是2000个字符。

gbase> create table testcomment(id int comment '编号', name varchar(100) comment '姓名') comment '测试注释'; Query OK, 0 rows affected (Elapsed: 00:00:00.29) gbase> show create table testcomment; +-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | testcomment | CREATE TABLE "testcomment" ( "id" int(11) DEFAULT NULL COMMENT '编号', "name" varchar(100) DEFAULT NULL COMMENT '姓名' ) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' COMMENT='测试注释' | +-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (Elapsed: 00:00:00.00) gbase>

更改表注释

用alter table TABLENAME comment '新的注释内容’对表的注释进行修改。

gbase> alter table testcomment comment '测试表注释修改'; Query OK, 0 rows affected (Elapsed: 00:00:00.12) gbase> show create table testcomment; +-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | testcomment | CREATE TABLE "testcomment" ( "id" int(11) DEFAULT NULL COMMENT '编号', "name" varchar(100) DEFAULT NULL COMMENT '姓名' ) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' COMMENT='测试表注释修改' | +-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (Elapsed: 00:00:00.00)

更改列注释

用alter table TABLENAME modify 列名字 列定义 comment进行修改。

注意列的原有定义要保持,包括类型,NOT NULL, default等。

gbase> alter table testcomment modify id int comment '测试编号修改'; Query OK, 0 rows affected (Elapsed: 00:00:00.14) Records: 0 Duplicates: 0 Warnings: 0 gbase> show create table testcomment; +-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | testcomment | CREATE TABLE "testcomment" ( "id" int(11) DEFAULT NULL COMMENT '测试编号修改', "name" varchar(100) DEFAULT NULL COMMENT '姓名' ) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' COMMENT='测试表注释修改' | +-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (Elapsed: 00:00:00.00)

添加注释

添加注释和修改定时完全一样的操作。

gbase> desc t1; +-------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+----------+------+-----+---------+-------+ | id | int(11) | YES | MUL | NULL | | | value | int(11) | YES | | NULL | | | birth | datetime | YES | | NULL | | +-------+----------+------+-----+---------+-------+ 3 rows in set (Elapsed: 00:00:00.01) gbase> alter table t1 comment '添加数值'; Query OK, 0 rows affected (Elapsed: 00:00:00.15) gbase> show create table t1; +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE "t1" ( "id" int(11) DEFAULT NULL, "value" int(11) DEFAULT NULL, "birth" datetime DEFAULT NULL, KEY "idx_id" ("id") KEY_BLOCK_SIZE=4096 USING HASH GLOBAL ) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' COMMENT='添加数值' | +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (Elapsed: 00:00:00.00) gbase> alter table t1 modify id int comment '添加注释'; Query OK, 0 rows affected (Elapsed: 00:00:00.16) Records: 0 Duplicates: 0 Warnings: 0 gbase> show create table t1; +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE "t1" ( "id" int(11) DEFAULT NULL COMMENT '添加注释', "value" int(11) DEFAULT NULL, "birth" datetime DEFAULT NULL, KEY "idx_id" ("id") KEY_BLOCK_SIZE=4096 USING HASH GLOBAL ) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' COMMENT='添加数值' | +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (Elapsed: 00:00:00.00)

原文参考 https://www.gbase8.cn/1739

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有