oracle怎么增加列注释

WBOY
WBOY 原创
2022-05-10 17:17:12 4561浏览

在oracle中,可以利用“comment on column 表名.列名 is '列注释';”增加列注释;comment是注释的意思, comment on命令用于给表或字段加以说明,也即添加注释,column用于设置列的数据内容。

本教程操作环境:Windows10系统、Oracle 11g版、Dell G3电脑。

oracle怎么增加列注释

给列加注释:

SQL>comment on column 表.列 is '列注释';

扩展:

1、给表填加注释:SQL>comment on table 表名 is '表注释";

2、给列加注释:SQL>comment on column 表.列 is '列注释';

3、读取表注释:SQL>select * from user_tab_comments where comments is not null;

4、读取列注释:SQL>select * from user_col_commnents where comments is not null and table_name='表名';

oracle中用comment on命令给表或字段加以说明,语法如下:

COMMENT ON
{ TABLE [ schema. ]
{ table | view }
| COLUMN [ schema. ]
{ table. | view. | materialized_view. } column
| OPERATOR [ schema. ] operator
| INDEXTYPE [ schema. ] indextype
| MATERIALIZED VIEW materialized_view
}
IS ‘text’ ;

用法如下:

1.对表的说明

comment on table table_name is ‘comments_on_tab_information’;

2.对表中列的说明

comment on column table.column_name is ‘comments_on_col_information’;

3.查看表的说明

SQL> select * from user_tab_comments where TABLE_NAME=’EMPLOYEES’;
TABLE_NAME TABLE_TYPE COMMENTS

添加注释的好处:

1.可以通过SQL语句快速查询,只要知道表名和字段名定位注释极方便快速。

2.注释内容是存储在字典表里的,只要表结构还在,那么SQL脚本即使没有了也可以定位查询。

3.不需要猜字段是什么意思,因为在简表的时候已经给了没有二意的注释,后期承接明确。

推荐教程:《Oracle视频教程

以上就是oracle怎么增加列注释的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。