Purpose
This statement adds comments about tables or table columns, views, or view columns to the data dictionary.
Privilege requirements
To execute the COMMENT statement, the current user must have the COMMENT ANY TABLE privilege. For more information about OceanBase Database privileges, see Privilege classification in Oracle mode.
Syntax
-- Add a comment to a table or view
COMMENT ON TABLE
[schema.]{table_name | view_name} IS 'string';
-- 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 comments of tables and views by using the
ALL_TAB_COMMENTS,DBA_TAB_COMMENTS, orUSER_TAB_COMMENTSviews. - You can query the comments of all columns of tables and views by using the
ALL_COL_COMMENTS,DBA_COL_COMMENTS, orUSER_COL_COMMENTSviews. - The maximum length of a comment string is 4000 characters. If the length exceeds 4000, an error is returned.
- Comments support Chinese and English characters and special characters, such as
@#$%^&*()_+-=[]{}|;:'",.<>/?. - You can use an empty string
''to delete a comment.
Parameters
| Parameter | Description |
|---|---|
| schema | The schema. If you omit schema., OceanBase Database adds comments to the objects in the current schema by default. |
| table_name | The name of the table. |
| view_name | The name of the view. |
| column_name | The name of the column. |
| 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
employeestable.-- Assume that the employees table exists. obclient> COMMENT ON TABLE employees IS 'Comment of the employees';Add a comment to the
emp_namecolumn of theemployeestable.-- Assume that the employees table and the emp_name column exist. obclient> COMMENT ON COLUMN employees.emp_name IS 'Name of person in table employees';Delete the comment on the
emp_namecolumn of theemployeestable.-- Assume that the employees table and the emp_name column exist. obclient> COMMENT ON COLUMN employees.emp_name IS '';Add a comment to the
view1view.-- Assume that the view1 view exists. obclient> COMMENT ON TABLE view1 IS 'Comment of the view1';Add a comment to the
namecolumn of theview1view.-- Assume that the view1 view and the name column exist. obclient> COMMENT ON COLUMN view1.name IS 'Name of person in view view1';Delete the comment on the
namecolumn of theview1view.-- Assume that the view1 view and the name column exist. obclient> COMMENT ON COLUMN view1.name IS '';
