Turn: http: //www.2cto.com/database/201109/106249.html
oracle be used to comment on the command table or field descriptions, the following syntax:
the COMMENT the ON
{TABLE [Schema.]
{Table | View}
| the COLUMN [Schema.]
{Table | View | materialized_view} column...
| OPERATOR [Schema .] operator
| INDEXTYPE [Schema] the indextype.
| MATERIALIZED the VIEW materialized_view
}
the iS 'text';
used as follows:
1. Description table
Comment table table_name iS oN 'comments_on_tab_information';
2. Description of the columns in the table
comment on column table iS .column_name 'comments_on_col_information';
3. Display description
the SQL> SELECT * WHERE TABLE_NAME = USER_TAB_COMMENTS from 'the EMPLOYEES';
TABLE_NAME TABLE_TYPE the 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
FIRST_NAME the EMPLOYEES
the EMPLOYEES LAST_NAME
the EMPLOYEES TITLE
the EMPLOYEES SALARY staff salaries
SQL> from the SELECT * Comments USER_COL_COMMENTS the WHERE IS not null;
TABLE_NAME COLUMN_NAME COMMENTS
------------------------- ----- ------------------------------ -------------
the EMPLOYEES SALARY staff salaries
5. we can also see the table and column level from the following description of these views:
ALL_COL_COMMENTS
USER_COL_COMMENTS
ALL_TAB_COMMENTS
USER_TAB_COMMENTS
6. delete table-level description, which is set to be empty
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
the COMMENT the ON
{TABLE [Schema.]
{Table | View}
| the COLUMN [Schema.]
{Table | View | materialized_view} column...
| OPERATOR [Schema .] operator
| INDEXTYPE [Schema] the indextype.
| MATERIALIZED the VIEW materialized_view
}
the iS 'text';
used as follows:
1. Description table
Comment table table_name iS oN 'comments_on_tab_information';
2. Description of the columns in the table
comment on column table iS .column_name 'comments_on_col_information';
3. Display description
the SQL> SELECT * WHERE TABLE_NAME = USER_TAB_COMMENTS from 'the EMPLOYEES';
TABLE_NAME TABLE_TYPE the 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
FIRST_NAME the EMPLOYEES
the EMPLOYEES LAST_NAME
the EMPLOYEES TITLE
the EMPLOYEES SALARY staff salaries
SQL> from the SELECT * Comments USER_COL_COMMENTS the WHERE IS not null;
TABLE_NAME COLUMN_NAME COMMENTS
------------------------- ----- ------------------------------ -------------
the EMPLOYEES SALARY staff salaries
5. we can also see the table and column level from the following description of these views:
ALL_COL_COMMENTS
USER_COL_COMMENTS
ALL_TAB_COMMENTS
USER_TAB_COMMENTS
6. delete table-level description, which is set to be empty
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