意见箱
恒创运营部门将仔细参阅您的意见和建议,必要时将通过预留邮箱与您保持联络。感谢您的支持!
意见/建议
提交建议

oracle怎么增加列注释

来源:恒创科技 编辑:恒创科技编辑部
2023-12-05 05:50:59

在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怎么增加列注释的详细内容,更多请关注恒创科技其它相关文章!

上一篇: mysql直接拷贝data目录下数据库源文件还原数据库方法 下一篇: oracle怎么查询表总数