Describe an SQL object using COMMENT ON

After you create an SQL object such as a table, view, index, package, procedure, parameter, user-defined type, function, trigger, or sequence, you can supply information about it for future reference. You can add information by 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.

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.'

Get comments after running a COMMENT ON statement

After running 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. If the indicated row had already contained a comment, the old comment is replaced by the new one. The following example gets the comments added by the COMMENT ON statement in the previous example:

   SELECT LONG_COMMENT
     FROM CORPDATA.SYSTABLES
     WHERE NAME = 'EMPLOYEE'
Related information
COMMENT ON