本文档介绍Hubble的注释语法。
该COMMENT ON语句将注释与数据库、表、列或索引相关联。
所需权限
用户必须对他们正在评论的对象具有CREATE特权。
语法图
- CommentStmt
参数介绍
| 参数 | 详情 |
|---|---|
database_name | 您正在查看的数据库的名称 |
schema_name | 您正在查看的架构的名称 |
table_name | 您正在查看的表的名称 |
column_name | 您正在查看的列的名称。 |
table_index_name | 您正在查看的索引的名称 |
comment_text | STRING您与对象关联的注释。 |
create database ora;
comment on database ora is '测试数据库';show databases with comment; database_name | owner | primary_region | regions | survival_goal | comment
----------------+--------+----------------+---------+---------------+-------------
ora | root | NULL | {} | NULL | 测试数据库create table person(
id int primary key,
name string
);
comment on table person is '用户信息表';show tables with comment; schema_name | table_name | type | owner | estimated_row_count | locality | comment
--------------+------------+----------+--------+---------------------+----------+-------------
public | person | table | hubble | 2 | NULL | 用户信息表
comment on column person.id is '唯一id';
comment on column person.name is '用户名';
show columns from person with comment; column_name | data_type | is_nullable | column_default | generation_expression | indices | is_hidden | comment
--------------+--------------+-------------+----------------+-----------------------+-----------+-----------+----------
id | INT8 | true | NULL | | {} | false | 唯一id
name | STRING | true | NULL | | {} | false | 用户名要从数据库中删除评论:
comment on database ora is null;-- 注释只能注释一行
select 1+10 as num; -- 注释文字 num
-------
11
(1 row)/* */注释既可以注释一行,更能注释多行
注释一行
select 1 /* 这是行内注释文字 */ - 19 as num; num
-------
-18注释多行
select 100+
/*
这个示例属于
多行注释
*/
1 as 求和; 求和
-------
101别名可以用中文