plsql 在oracle中创建表时添加注释使用comment字段。例如有以下表:
CREATE TABLE t1(
id varchar2(32) primary key,
name VARCHAR2(32) ,
age VARCHAR2(32)
)
添加表注释的命令为:
COMMENT ON table t1 IS '个人信息'
添加字段注释命令为:
comment on column t1.id is 'id'
comment on column t1.name is '姓名'
comment on column t1.age is '年龄'
扩展资料
plsql中查看表注释和字段注释方法介绍
查看当前用户下所有表注释:select * from user_tab_comments
结果: user_tab_comments:table_name,table_type,comments
查看当前用户下某表所有字段注释:select * from user_col_comments where TABLE_NAME='某表名称';
结果:user_col_comments:table_name,column_name,comments
ALTER TABLE table_name COMMENT='这是表的注释'1.给表加注释:
ALTER TABLE table_name COMMENT='这是表的注释'2.给列加注释:
ALTER table table_name MODIFY `column_name` datetime DEFAULT NULL COMMENT '这是字段的注释'表创建完成后使用下列命令添加列的注释: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
测试 来自客户
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)