René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

comment [Oracle SQL]

comment on table  some_table       is 'some hopefully meaningful comment for some_table';
comment on table  some_view        is 'Views can also be commented, yet the statement is still: comment on table';
comment on column some_table.col_1 is 'Be sure to really give some meaningful comment';
comment on column some_view.col_1  is 'Useless, or wrong comments, are worse than no comment at all';
The comment statement allows to store some comments about tables, views or columns in the data dictionary.
Even when views are commented, the syntax is comment on table.
The comments for tables and views can be retrieved with something like
column comments format a50
select table_name, comments from user_tab_comments where table_name like 'SOME%';
TABLE_NAME                     COMMENTS
------------------------------ --------------------------------------------------
SOME_TABLE                     some hopefully meaningful comment for some_table
SOME_VIEW                      Views can also be commented, yet the statement is
                               still: comment on table
Similarly, the comments for columns can be found with something like
column comments format a50
select table_name, column_name, comments from user_col_comments where table_name like 'SOME%';
TABLE_NAME                     COLUMN_NAME                    COMMENTS
------------------------------ ------------------------------ --------------------------------------------------
SOME_TABLE                     COL_1                          Be sure to really give some meaningful comment
SOME_TABLE                     COL_2
SOME_TABLE                     COL_3
SOME_VIEW                      COL_1                          Useless, or wrong comments, are worse than no comm
                                                              ent at all

SOME_VIEW                      COL_2
SOME_VIEW                      COL_3
See also comments (PL/SQL).