CREATE TABLE test222
(
id int NOT NULL PRIMARY KEY,
name varchar(1000) DEFAULT NULL,
email varchar(1000) DEFAULT NULL,
phone varchar(1000) DEFAULT NULL
)
comment on column TEST222.NAME is '这是一个列注释';
例如:
comment on column TEST222.NAME is '姓名';
comment on column TEST222.EMAIL is '邮箱';
comment on column TEST222.PHONE is '电话';
create table student(
id int primary key,
name varchar2(1000),
email varchar2(1000),
phone varchar2(1000)
)
comment on column student.name is '姓名';
comment on column student.email is '邮箱';
comment on column student.phone is '电话';
comment on table student is '测试表'
openGauss和postgressql的SQL类似
CREATE TABLE test.student(
id int,
name varchar(1000),
email varchar(1000),
phone varchar(1000)
)
COMMENT ON COLUMN test.student."id" IS '编号';
COMMENT ON COLUMN test.student."name" IS '名称';
COMMENT ON COLUMN test.student."email" IS '邮箱';
COMMENT ON COLUMN test.student."phone" IS '手机';
参考:PostgreSQL 创建表时如何为列添加注释|极客笔记 (deepinout.com)
CREATE TABLE test (
id int,
name varchar(1000) ,
email varchar(1000) ,
phone varchar(1000) ,
CONSTRAINT test_pkey PRIMARY KEY (id)
);
单独执行sql添加注释:comment ON column 表名.列名 is '注释';
例如:
comment ON column regre.public.test.name is '名称';
comment ON column regre.public.test.email is '邮箱';
comment ON column regre.public.test.phone is '电话';
CREATE TABLE test(
id int,
name varchar(1000),
email varchar(1000),
phone varchar(1000)
)
alter table test change column name name varchar(1000) comment '姓名';
alter table test change column email email varchar(1000) comment '邮箱';
alter table test change column phone phone varchar(1000) comment '电话';
alter table test change column name name string comment '姓名';
CREATE TABLE test(
id int,
name varchar(1000) comment '姓名',
email varchar(1000) comment '邮箱',
phone varchar(1000) comment '电话'
)
更多【hive-DM、Oracle、GaussDB、Kingbase8(人大金仓数据库)和HIVE给列增加注释】相关视频教程:www.yxfzedu.com