Purpose
This statement adds comments about a table or table column, a view, or a view column to the data dictionary.
To delete 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 you omit schema., OceanBase Database assumes that the object to add the comment to is in the current schema. |
| column_name | The column name. |
| table_name | The table name. |
| view_name | The view name. |
| string | The text of the comment. If you set string to an empty string, the comment is deleted from the database. |
Examples
Add a comment to the
tbl1table. You can query theall_tab_comments,dba_tab_comments, oruser_tab_commentstable to obtain the comment of the table.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 theall_col_comments,dba_col_comments, oruser_col_commentstable to obtain the comment of the table column.obclient> COMMENT ON COLUMN tbl1.name IS 'Name of person in table tbl1'; Query OK, 0 rows affectedDelete the comment of the
namecolumn of thetbl1table from the database.obclient> COMMENT ON COLUMN tbl1.name IS ''; Query OK, 0 rows affectedAdd a comment to the
view1view. You can query theall_tab_comments,dba_tab_comments, oruser_tab_commentstable to obtain the comment of the view.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 theall_col_comments,dba_col_comments, oruser_col_commentstable to obtain the comment of the view column.obclient> COMMENT ON COLUMN view1.name IS 'Name of person in view view1'; Query OK, 0 rows affectedDelete the comment of the
namecolumn of theview1view from the database.obclient> COMMENT ON COLUMN view1.name IS ''; Query OK, 0 rows affected