COMMENT

2024-03-05 01:54:27  Updated

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 tbl1 table. You can query the table comment in the all_tab_comments, dba_tab_comments, or user_tab_comments table.

    obclient> COMMENT ON TABLE tbl1 IS 'Comment of the tbl1';
    Query OK, 0 rows affected
    
  • Add a comment to the name column of the tbl1 table. You can query the table column comment in the all_col_comments, dba_col_comments, or user_col_comments table.

    obclient> COMMENT ON COLUMN tbl1.name IS 'Name of person in table tbl1';
    Query OK, 0 rows affected
    
  • Drop the comment from the name column of the tbl1 table in the database.

    obclient> COMMENT ON COLUMN tbl1.name IS '';
    Query OK, 0 rows affected
    
  • Add a comment to the view1 view. You can query the view comment in the all_tab_comments, dba_tab_comments, or user_tab_comments table.

    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 affected
    
  • Add a comment to the name column of the view1 view. You can query the view column comment in the all_col_comments, dba_col_comments, or user_col_comments table.

    obclient> COMMENT ON COLUMN view1.name IS 'Name of person in view view1';
    Query OK, 0 rows affected
    
  • Drop the comment from the name column of the view1 view.

    obclient> COMMENT ON COLUMN view1.name IS '';
    Query OK, 0 rows affected
    

Contact Us