Describing an SQL object using COMMENT ON
After you create an SQL object, such as a table or view, you can provide object information for future reference using the COMMENT ON statement.
The information can be the purpose of the object, who uses it, and anything unusual or special about it. You can also include similar information about each column of a table or view. A comment is especially useful if your names do not clearly indicate the contents of the columns or objects. In that case, use a comment to describe the specific contents of the column or objects. Usually, your comment must not be more than 2000 characters, but for sequences the maximum length is 500 characters. If the object already contains a comment, the old comment is replaced by the new one.
An example of using COMMENT ON follows:
COMMENT ON TABLE CORPDATA.EMPLOYEE IS 'Employee table. Each row in this table represents one employee of the company.'
Getting comments after running a COMMENT ON statement
After you run a COMMENT ON statement for a table, your comments are stored in the LONG_COMMENT column of SYSTABLES. Comments for the other objects are stored in the LONG_COMMENT column of the appropriate catalog table. The following example gets the comments that are added by the COMMENT ON statement in the previous example:
SELECT LONG_COMMENT FROM CORPDATA.SYSTABLES WHERE NAME = 'EMPLOYEE'
Parent topic:
Data definition language
Related reference
COMMENT