The comment on command in Oracle is used to describe the table or field, and the syntax is as follows:
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 ';
Usage is as follows:
1. Description of the table
Comment on table table_name is ' comments_on_tab_information ';
2. Description of the columns in the table
Comment on column table.column_name is ' comments_on_col_information ';
3. View the description of the table
Sql> SELECT * from user_tab_comments where table_name= ' EMPLOYEES ';
TABLE_NAME Table_type COMMENTS
------------------------------ ----------- ----------
EMPLOYEES Table Employee Tables
Sql> SELECT * from user_tab_comments where comments isn't null;
TABLE_NAME Table_type COMMENTS
------------------------------ ----------- --------------------------
EMPLOYEES Table Employee Tables
4. View the description of the column in the table
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 Staff Salary
Sql> SELECT * from user_col_comments where comments isn't null;
TABLE_NAME column_name COMMENTS
------------------------------ ------------------------------ -------------
EMPLOYEES SALARY Staff Salary
5. We can also view table-level and column-level descriptions from the following views:
All_col_comments
User_col_comments
All_tab_comments
User_tab_comments
6. Delete the table-level description, which is to place it blank
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. Delete the column level description, but also place it as empty
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
Ext: http://www.2cto.com/database/201109/106249.html