Purpose
You can use this statement to add comments of tables, table columns, views, and view columns to the data dictionary.
To drop a comment from the database, set it to an empty string ''.
Syntax
/*Add a comment to a column.*/
COMMENT ON COLUMN
[ schema. ] { table_name.| view_name. } column_name IS 'string';
/*Add a comment to a table or view.*/
COMMENT ON TABLE
[ schema. ] {table_name | view_name } IS 'string';
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. |
| column_name | The name of the column. |
| table_name | The name of the table. |
| view_name | The name of the view. |
| string | The text of the comment. If you specify an empty string for string, the comment is dropped from the database. |
Examples
Add a comment to the
tbl1table. You can query the table comment in theall_tab_comments,dba_tab_comments, oruser_tab_commentstable.obclient> COMMENT ON TABLE tbl1 IS 'Comment of the tbl1'; Query OK, 0 rows affectedAdd a comment to the
namecolumn of thetbl1table. You can query the table column comment in theall_col_comments,dba_col_comments, oruser_col_commentstable.obclient> COMMENT ON COLUMN tbl1.name IS 'Name of person in table tbl1'; Query OK, 0 rows affectedDrop the comment from the
namecolumn of thetbl1table in the database.obclient> COMMENT ON COLUMN tbl1.name IS ''; Query OK, 0 rows affectedAdd a comment to the
view1view. You can query the view comment in theall_tab_comments,dba_tab_comments, oruser_tab_commentstable.obclient> CREATE VIEW view1 AS SELECT * FROM tbl1; Query OK, 0 rows affected obclient> COMMENT ON TABLE view1 IS 'Comment of the view1'; Query OK, 0 rows affectedAdd a comment to the
namecolumn of theview1view. You can query the view column comment in theall_col_comments,dba_col_comments, oruser_col_commentstable.obclient> COMMENT ON COLUMN view1.name IS 'Name of person in view view1'; Query OK, 0 rows affectedDrop the comment from the
namecolumn of theview1view.obclient> COMMENT ON COLUMN view1.name IS ''; Query OK, 0 rows affected