Usage of Oracle comment on ____oracle

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.