comment on column 表名.字段名 is '注释'表的注释:yang@rac1desc user_col_comments
Name Null? Type
-------------------------- -------- ------------
TABLE_NAME NOT NULL VARCHAR2(30)
COLUMN_NAME NOT NULL VARCHAR2(30)
COMMENTS VARCHAR2(4000)
yang@rac1comment on table tchar is ' 这是一个测试表'
Comment created.
yang@rac1select table_name ,comments from user_tab_comments
TABLE_NAME COMMENTS
------------------------------ -----------------------
TCHAR 这是一个测试表
表中字段的注释:
yang@rac1desc user_col_comments
Name Null? Type
------------------------ -------- ----------------------------
TABLE_NAME NOT NULL VARCHAR2(30)
COLUMN_NAME NOT NULL VARCHAR2(30)
COMMENTS VARCHAR2(4000)
yang@rac1comment on column tchar.val is ' 测试 来自客户 '
Comment created.
yang@rac1col comments for a45
yang@rac1select comments from user_col_comments where table_name='TCHAR' and column_name='VAL'COMMENTS
测试 来自客户
comment on column命令为字段加上注释,举例如下,
1、创建数据表,
create table test_date(v_date date,v_date1 date,v_date2 date,
v_date3 date,v_date4 date,v_date5 date)
2、查看该表的字段注释,可以发现‘注释’列为空,
3、添加字段注释,
-- Add comments to the columns
comment on column TEST_DATE.v_date is '日期'
comment on column TEST_DATE.v_date1 is '日期1'
comment on column TEST_DATE.v_date2 is '日期2'
comment on column TEST_DATE.v_date3 is '日期3'
comment on column TEST_DATE.v_date4 is '日期4'
comment on column TEST_DATE.v_date5 is '日期5'
4、再次查看该表属性,可以发现字段已添加上注释,
通过设置模板来设置。在ORACLE中给表列增加注释以及读取注释,给表填加注释:SQL>commentonable表名is表注释,给列加注释:SQL>commentoncolumn表.列is列注释,读取表注释:SQL>select*fromuser_tab_commentswherecommentsisnotnull,读取列注释:SQL>select*fromuser_col_commnentswherecommentsisnotnullandable_name='表名。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)