Wednesday, September 14, 2011

Adding a Comment to a Column Description



This simple example, tested on an Oracle 9 database, shows how to add a comment to a column description. First create a table:
 
SQL> create table blah (col1 varchar2(1))
  2  /
 
Table created.
 
SQL>
 
And check that there are no comments on it:
 
SQL> select column_name, comments
  2  from user_col_comments
  3  where table_name = 'BLAH'
  4  /
 
COLUMN_NAME          COMMENTS
-------------------- --------------------
COL1
 
SQL>
 
Then add a comment to column col1 restrospectively and query user_col_comments again:
 
SQL> comment on column blah.col1 is 'Column 1'
  2  /
 
Comment created.
 
SQL> select column_name, comments
  2  from user_col_comments
  3  where table_name = 'BLAH'
  4  /
 
COLUMN_NAME          COMMENTS
-------------------- --------------------
COL1                 Column 1
 
SQL>

No comments: