Example of oracle comment command usage

Source: Internet
Author: User

In oracle, the comment on command is used to describe tables or fields. The syntax is as follows:
Copy codeThe Code 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 ';

The usage is as follows:

1. Description of the table
Copy codeThe Code is as follows:
Comment on table table_name is 'comments _ on_tab_information ';

2. Description of the columns in the table
Copy codeThe Code is as follows:
Comment on column table. column_name is 'comments _ on_col_information ';

3. View table description
Copy codeThe Code is as follows:
SQL> select * from user_tab_comments where TABLE_NAME = 'ployees ';

Copy codeThe Code is as follows:
TABLE_NAME TABLE_TYPE COMMENTS
---------------------------------------------------
Employees table employee TABLE

SQL> select * from user_tab_comments where comments is not null;

TABLE_NAME TABLE_TYPE COMMENTS
-------------------------------------------------------------------
Employees table employee TABLE

4. view the description of the columns in the table.
Copy codeThe Code is as follows:
SQL> select * from user_col_comments where TABLE_NAME = 'ployees ';

Copy codeThe Code is as follows:
TABLE_NAME COLUMN_NAME COMMENTS
------------------------------------------------------------------------
EMPLOYEES EMPLOYEE_ID
EMPLOYEES MANAGER_ID
EMPLOYEES FIRST_NAME
EMPLOYEES LAST_NAME
EMPLOYEES TITLE
SALARY of SALARY EMPLOYEES


SQL> select * from user_col_comments where comments is not null;

TABLE_NAME COLUMN_NAME COMMENTS
-------------------------------------------------------------------------
SALARY of SALARY EMPLOYEES

5. You can also view the table-level and column-level descriptions from the following views:
Copy codeThe Code is as follows:
ALL_COL_COMMENTS
USER_COL_COMMENTS
ALL_TAB_COMMENTS
USER_TAB_COMMENTS

6. Delete table-level description, that is, leave it blank
Copy codeThe Code is as follows:
SQL> comment on table employees is '';
Comment added

SQL> select * from user_tab_comments where TABLE_NAME = 'ployees ';

TABLE_NAME TABLE_TYPE COMMENTS
------------------------------------------------------
EMPLOYEES TABLE

7. Delete the column-level description and leave it empty.
Copy codeThe Code is as follows:
SQL> comment on column employees. salary is '';
Comment added

SQL> select * from user_col_comments where TABLE_NAME = 'ployees ';

TABLE_NAME COLUMN_NAME COMMENTS
-------------------------------------------------------------------------
EMPLOYEES EMPLOYEE_ID
EMPLOYEES MANAGER_ID
EMPLOYEES FIRST_NAME
EMPLOYEES LAST_NAME
EMPLOYEES TITLE
EMPLOYEES SALARY

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.