首页 / 数据库 / MySQL / Oracle 使用comment语句添加表注释
使用Oracle comment语句可以给表、字段、视图等对象添加备注信息。大致语法为:
comment on TABLE table_name IS "备注内容";权限要求:
默认情况下用户只能给属于自己的对象添加注释。
如果要想给其他用户对象添加注释需要拥有权限:COMMENT ANY TABLE相关数据字段视图:
USER_TAB_COMMENTS
DBA_TAB_COMMENTS
ALL_TAB_COMMENTS
USER_COL_COMMENTS
DBA_COL_COMMENTS
ALL_COL_COMMENTS示例如下:
drop table t;
create table t(id number);select * from user_tab_comments;TABLE_NAME TABLE_TYPE COMMENTS
------------------------------ ------------------------------ ------------------------------
T TABLEselect * from USER_COL_COMMENTS;SCOTT@orcl> select * from USER_COL_COMMENTS WHERE table_name="T";TABLE_NAME COLUMN_NAME COMMENTS
------------------------------ ------------------------------ ------------------------------
T ID--添加注释
SCOTT@orcl> comment on table t is "测试表T";注释已创建。SCOTT@orcl> comment on column t.id is "行ID";注释已创建。SCOTT@orcl> select * from user_tab_comments WHERE table_name="T";TABLE_NAME TABLE_TYPE COMMENTS
------------------------------ ------------------------------ ------------------------------
T TABLE 测试表TSCOTT@orcl> select * from USER_COL_COMMENTS WHERE table_name="T";TABLE_NAME COLUMN_NAME COMMENTS
------------------------------ ------------------------------ ------------------------------
T ID 行ID详细文章请参考:http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_4009.htm#i2119719更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12本文永久更新链接地址