COMMENT ON
Use the COMMENT ON command to specify or replace a comment for an object.
- Specify a comment for a database object.
- Replace an existing comment.
- Delete a comment by specifying a null string.
Each object can have at most one comment. When you drop an object, the system automatically drops the corresponding comment.
Any user who is connected to a database can view all comments for objects in the database, so do not put security-critical or confidential information into comments.
Syntax
COMMENT ON [ <object_type> <object_name> |
COLUMN <table>.<col> ] IS '<text>'
Inputs
Input | Description |
---|---|
<object_type> | The type of object:
|
<object_name> | The name of the object. |
<table> | The name of the table. |
<col> | The name of the column. |
<text> | The comment text. |
Output
The COMMENT command has the following output:
Output | Description |
---|---|
Comment | The comment was successfully added or replaced. |
Privileges
You can specify comments for any objects that you own. For other objects, you must be the admin user, the owner of the database or schema where the object is defined, or your account must have the Alter privilege for theobject or for that class of objects.
Usage
- Add a comment to the table mytable:
MYDB.SCH1(USER)=> COMMENT ON my_table IS 'This is my table.';
- Add comments to a database, sequence, view, and column:
MYDB.SCH1(USER)=> COMMENT ON DATABASE my_database IS 'Development Database'; MYDB.SCH1(USER)=> COMMENT ON SEQUENCE my_sequence IS 'Used to generate primary keys'; MYDB.SCH1(USER)=> COMMENT ON VIEW my_view IS 'View of departmental costs'; MYDB.SCH1(USER)=> COMMENT ON COLUMN my_table.my_field IS 'Employee ID number';