The COMMENT ON statement adds or replaces comments in the catalog descriptions of tables, views, aliases, user-defined types, functions, packages, parameters, procedures, indexes, or columns.
This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared.
To comment on a table, view, alias, index, column, user-defined type, or package, the privileges held by the authorization ID of the statement must include at least one of the following:
The authorization ID of the statement has the ALTER privilege on the table, view, alias, index, user-defined type, or package when:
To comment on a function, the privileges held by the authorization ID of the statement must include at least one of the following:
To comment on a procedure, the privileges held by the authorization ID of the statement must include at least one of the following:
To comment on a parameter, the privileges held by the authorization ID of the statement must include at least one of the following:
The authorization ID of the statement has the UPDATE privilege on a table when:
Notes:
>>-COMMENT ON--------------------------------------------------->
>-----+--+-ALIAS--alias-name-------------------------------------------------------+---IS--string-constant--+>
| +-COLUMN--+-table-name.column-name-+--------------------------------------+ |
| | '-view-name.column-name--' | |
| +-+---------------+---TYPE--type-name-------------------------------------+ |
| | | (1) | | |
| | '-DISTINCT------' | |
| +--+-FUNCTION-+--function-name--+------------------------------------+----+ |
| | '-ROUTINE--' '-(--+------------------------+---)--' | |
| | | .-,----------------. | | |
| | | V | | | |
| | '----parameter-type---+--' | |
| +-INDEX--index-name-------------------------------------------------------+ |
| | (2) | |
| +-PACKAGE-------package-name----------------------------------------------+ |
| +-PARAMETER--+-routine-name.parameter-name-----------------------------+--+ |
| | '-SPECIFIC--+-FUNCTION--+---specific-name.parameter-name--' | |
| | +-PROCEDURE-+ | |
| | '-ROUTINE---' | |
| +--+-PROCEDURE-+---procedure-name--+------------------------------------+-+ |
| | '-ROUTINE---' '-(--+------------------------+---)--' | |
| | | .-,----------------. | | |
| | | V | | | |
| | '----parameter-type---+--' | |
| +-SPECIFIC--+-FUNCTION--+---specific-name---------------------------------+ |
| | +-PROCEDURE-+ | |
| | '-ROUTINE---' | |
| '-TABLE--+-table-name-+---------------------------------------------------' |
| '-view-name--' |
+-multiple-columns------------------------------------------------------------------------------------+
'-multiple-parameters---------------------------------------------------------------------------------'
>--------------------------------------------------------------><
multiple-columns
.-,-----------------------------------.
.-COLUMN-. V |
|---+--------+----+-table-name-+---(-----column-name--IS--string-constant---+---)-->
'-view-name--'
>---------------------------------------------------------------|
multiple-parameters
|---PARAMETER--+-SPECIFIC--+-FUNCTION--+---specific-name-----------------------------+->
| +-PROCEDURE-+ |
| '-ROUTINE---' |
| .-ROUTINE---. |
'-+-----------+--routine-name--+------------------------------------+-'
+-FUNCTION--+ '-(--+------------------------+---)--'
'-PROCEDURE-' | .-,----------------. |
| V | |
'----parameter-type---+--'
.-,--------------------------------------.
V |
>---(-----parameter-name--IS--string-constant---+---)-----------|
type.
If an unqualified distinct type name is specified, DB2 searches the SQL path to resolve the collection name for the distinct type.
For data types that have a length, precision or scale attribute, you can specify a value or use a set of empty parentheses.
For data types with a subtype or CCSID attribute, specifying the FOR DATA clause or CCSID clause is optional. Omission of either clause indicates that DB2 ignores the attribute when determining whether the data types match. If you specify either clause, it must match the value that was implicitly or explicitly specified in the CREATE FUNCTION statement.
If an unqualified distinct type name is specified, DB2 searches the SQL path to resolve the collection name for the distinct type.
For data types that have a length, precision or scale attribute, you can specify a value or use a set of empty parentheses.
For data types with a subtype or CCSID attribute, specifying the FOR DATA clause or CCSID clause is optional. Omission of either clause indicates that DB2 ignores the attribute when determining whether the data types match. If you specify either clause, it must match the value that was implicitly or explicitly specified in the CREATE PROCEDURE statement.
To comment on more than one column in a table or view, specify the table or view name and then, in parenthesis, a list of the form:
column-name IS string-constant, column-name IS string-constant, ...
The column name must not be qualified, each name must identify a column of the specified table or view, and that table or view must exist at the current server.
To comment on more than one parameter in a procedure or function, specify the procedure name, function name, or specific name, and then, in parenthesis, a list of the form:
parameter-name IS string-constant, parameter-name IS string-constant, ...
The parameter name must not be qualified, each name must identify a parameter of the specified procedure or function, and that procedure or function must exist at the current server.
Insert a comment for the EMPLOYEE table.
COMMENT ON TABLE EMPLOYEE
IS 'Reflects first quarter 1981 reorganization'
Insert a comment for the EMP_VIEW1 view.
COMMENT ON TABLE EMP_VIEW1
IS 'View of the EMPLOYEE table without salary information'
Insert a comment for the EMPNO column of the EMPLOYEE table.
COMMENT ON COLUMN EMPLOYEE.EMPN
IS 'Highest grade level passed in school'
Enter comments on two columns in the CORPDATA.DEPARTMENT table.
COMMENT ON CORPDATA.DEPARTMENT
(MGRNO IS 'EMPLOYEE NUMBER OF DEPARTMENT MANAGER',
ADMRDEPT IS 'DEPARTMENT NUMBER OF ADMINISTERING DEPARTMENT')
Insert a comment for the CORPDATA.PAYROLL package.
COMMENT ON PACKAGE CORPDATA.PAYROLL
IS 'This package is used for distributed payroll processing.'