在oracle中有时候需要用到字段注释,那么就需要用到comment,那么comment的语法是怎样的呢,现在我来总结一下,以备以后使用的时候方便查看:
先创建一个表,例如:
create table AA(
a_id number primary key not null,
a_name varchar(20)
);
comment on table AA is '我的表';---------表注释
comment on column AA.a_id is '编号'; -------列注释
测试效果:
select * from user_tab_comments where comments is not null;
TABLE_NAME TABLE_TYPE COMMENTS
------------------------------ ----------- --------------------------------------------------------------------------------
select * from user_tab_comments where table_name is '我的表';
TABLE_NAME TABLE_TYPE COMMENTS
------------------------------ ----------- --------------------------------------------------------------------------------
AA TABLE 我的表
select * from user_column_comments where comments is not null;
TABLE_NAME COLUMN_NAME COMMENTS
------------------------------ ------------------------------ --------------------------------------------------------------------------------
AA AID 编号