Purpose
You can use this statement to add comments of tables, table columns, views, and view columns to the data dictionary.
Required privileges
To execute the COMMENT statement, you must have the COMMENT ANY TABLE privilege. For more information about OceanBase Database privileges, see Privilege types in Oracle mode.
Syntax
Add a comment to a column of a table or view
COMMENT ON COLUMN
[schema.]{table_name. | view_name.}column_name IS 'string';
Note
You can query the ALL_COL_COMMENTS, DBA_COL_COMMENTS, or USER_COL_COMMENTS view for the comments on all columns of tables and views.
Add a comment to a table or view
COMMENT ON TABLE
[schema.]{table_name | view_name} IS 'string';
Note
You can query the ALL_TAB_COMMENTS, DBA_TAB_COMMENTS, or USER_TAB_COMMENTS view for the comments on tables and views.
Parameters
| Parameter | Description |
|---|---|
| schema | The schema. If schema. is omitted, OceanBase Database considers that the objects such as tables for which comments are to be added are in the current schema. |
| table_name | The table name. |
| view_name | The view name. |
| column_name | The column name. |
| string | The text of the comment. To drop a comment from a database, you can set string to an empty string ''. |
Examples
Add a comment to the
tbl1table.obclient> COMMENT ON TABLE tbl1 IS 'Comment of the tbl1';Add a comment to the
namecolumn of thetbl1table.obclient> COMMENT ON COLUMN tbl1.name IS 'Name of person in table tbl1';Drop the comment from the
namecolumn of thetbl1table in the database.obclient> COMMENT ON COLUMN tbl1.name IS '';Add a comment to the
view1view.obclient> COMMENT ON TABLE view1 IS 'Comment of the view1';Add a comment to the
namecolumn of theview1view.obclient> COMMENT ON COLUMN view1.name IS 'Name of person in view view1';Drop the comment from the
namecolumn of theview1view.obclient> COMMENT ON COLUMN view1.name IS '';