oracle comment命令用法示例分享
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
------------------------------ ----------- ----------
employees table 员工表
sql> select * from user_tab_comments where comments is not null;
table_name table_type comments
------------------------------ ----------- --------------------------
employees table 员工表
4.查看表中列的说明
sql> select * from user_col_comments where table_name='employees';
table_name column_name comments
------------------------------ ------------------------------ ------------
employees employee_id
employees manager_id
employees first_name
employees last_name
employees title
employees salary 员工薪水
sql> select * from user_col_comments where comments is not null;
table_name column_name comments
------------------------------ ------------------------------ -------------
employees salary 员工薪水
5.我们也可以从下面这些视图中查看表级和列级说明:
all_col_comments
user_col_comments
all_tab_comments
user_tab_comments
6.删除表级说明,也就是将其置为空
sql> comment on table employees is '';
comment added
sql> select * from user_tab_comments where table_name='employees';
table_name table_type comments
------------------------------ ----------- -------------
employees table
7.删除列级说明,也是将其置为空
sql> comment on column employees.salary is '';
comment added
sql> select * from user_col_comments where table_name='employees';
table_name column_name comments
------------------------------ ------------------------------ -------------
employees employee_id
employees manager_id
employees first_name
employees last_name
employees title
employees salary