Home >Database >Oracle >How to add column comments in oracle

How to add column comments in oracle

WBOY
WBOYOriginal
2022-05-10 17:17:127659browse

In Oracle, you can use "comment on column table name. Column name is 'column comment';" to add column comments; comment means comment, and the comment on command is used to explain tables or fields. That is, add comments, and column is used to set the data content of the column.

How to add column comments in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How to add column comments in Oracle

Add comments to columns:

SQL>comment on column 表.列 is '列注释';

Extension:

1. Add comments to the table: SQL>comment on table Table name is 'Table Comment';

2. Add a comment to the column: SQL>comment on column table. Column is 'Column Comment';

3. Read the table comment: SQL> select * from user_tab_comments where comments is not null;

4. Read column comments: SQL>select * from user_col_commnents where comments is not null and table_name='table name';

oracle Use the comment on command to describe the table or field. 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’ ;

The 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 Description

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

Benefits of adding comments:

1. You can quickly query through SQL statements, as long as you know the table name and field name to locate the comment pole Convenient and fast.

2. The annotation content is stored in the dictionary table. As long as the table structure is still there, the SQL script can still locate the query even if it is gone.

3. No need to guess fields What does it mean? Because clear comments have been given when the table is simplified, and it will be made clear later.

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of How to add column comments in oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn