The COMMENT statement adds or replaces comments in the catalog descriptions of various database objects.
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, distinct type, package, or sequence, the privileges held by the authorization ID of the statement must include at least one of the following:
To comment on a trigger, the privileges held by the authorization ID of the statement must include at least one of the following:
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:
To comment on a sequence, the privileges held by the authorization ID of the statement must also include at least one of the following:
For information on the system authorities corresponding to SQL privileges, see Corresponding System Authorities When Checking Privileges to a Table or View, Corresponding System Authorities When Checking Privileges to a Distinct Type, Corresponding System Authorities When Checking Privileges to a Sequence, and Corresponding System Authorities When Checking Privileges to a Package.
>>-COMMENT--ON--------------------------------------------------> >--+-+-ALIAS--alias-name----------------------------------------------------+--IS--string-constant-+->< | +-COLUMN--+-table-name.column-name-+-----------------------------------+ | | | '-view-name.column-name--' | | | +-+----------+--TYPE--distinct-type-name-------------------------------+ | | | '-DISTINCT-' | | | +-+-+-FUNCTION-+--function-name--+------------------------------+-+----+ | | | | '-ROUTINE--' '-(--+--------------------+--)-' | | | | | | | .-,--------------. | | | | | | | | V | | | | | | | | '---parameter-type-+-' | | | | | '-SPECIFIC--+-FUNCTION-+--specific-name-------------------------' | | | | '-ROUTINE--' | | | +-INDEX--index-name----------------------------------------------------+ | | +-PACKAGE--package-name--+-------------------------+-------------------+ | | | | .-VERSION-. | | | | | '-+---------+--version-id-' | | | +-PARAMETER--+-routine-name.parameter-name---------------------------+-+ | | | '-SPECIFIC--+-FUNCTION--+--specific-name.parameter-name-' | | | | +-PROCEDURE-+ | | | | '-ROUTINE---' | | | +-+-+-PROCEDURE-+--procedure-name--+------------------------------+-+--+ | | | | '-ROUTINE---' '-(--+--------------------+--)-' | | | | | | | .-,--------------. | | | | | | | | V | | | | | | | | '---parameter-type-+-' | | | | | '-SPECIFIC--+-PROCEDURE-+--specific-name--------------------------' | | | | '-ROUTINE---' | | | +-SEQUENCE--sequence-name----------------------------------------------+ | | +-TABLE--+-table-name-+------------------------------------------------+ | | | '-view-name--' | | | '-TRIGGER--trigger-name------------------------------------------------' | +-multiple-column-list--------------------------------------------------------------------------+ '-multiple-parameter-list-----------------------------------------------------------------------'
multiple-column-list: .-,--------------------------------. .-COLUMN-. V | |--+--------+--+-table-name-+--(----column-name--IS--string-constant-+--)--| '-view-name--' multiple-parameter-list: |--PARAMETER--+-SPECIFIC--+-FUNCTION--+--specific-name------------------------+--> | +-PROCEDURE-+ | | '-ROUTINE---' | | .-ROUTINE---. | '-+-----------+--routine-name--+------------------------------+-' +-FUNCTION--+ '-(--+--------------------+--)-' '-PROCEDURE-' | .-,--------------. | | V | | '---parameter-type-+-' .-,-----------------------------------. V | >--(----parameter-name--IS--string-constant-+--)----------------| parameter-type: |----data-type--+------------+----------------------------------| '-AS LOCATOR-' data-type: |--+-built-in-type------+---------------------------------------| '-distinct-type-name-'
built-in-type: |--+-+---SMALLINT---+----------------------------------------------------------------------------------------------+--| | +-+-INTEGER-+--+ | | | '-INT-----' | | | '---BIGINT-----' | | .-(5,0)----------------------------. | +-+-+-DECIMAL-+-+--+----------------------------------+---------------------------------------------------------+ | | '-DEC-----' | '-(--+------------------------+--)-' | | '-NUMERIC-----' '-integer--+-----------+-' | | '-, integer-' | | .-(53)----------. | +-+-FLOAT--+---------------+-+----------------------------------------------------------------------------------+ | | '-(--integer--)-' | | | +-REAL---------------------+ | | | .-PRECISION-. | | | '-DOUBLE--+-----------+----' | | .-(1)---------------. | +-+-+-+-CHARACTER-+--+-------------------+--------------+--+----------------+---------------------------------+-+ | | | '-CHAR------' '-(--+---------+--)-' | +-FOR BIT DATA---+ | | | | | '-integer-' | +-FOR SBCS DATA--+ | | | | '---+-+-CHARACTER-+--VARYING-+--(--+---------+--)---' +-FOR MIXED DATA-+ | | | | | '-CHAR------' | '-integer-' '-CCSID--integer-' | | | | '-VARCHAR----------------' | | | | .-(1M)---------------------. | | | '-----+-+-CHARACTER-+--LARGE OBJECT-+------+--------------------------+--+----------------+--+------------+-' | | | '-CHAR------' | '-(--+---------+--+---+--)-' +-FOR SBCS DATA--+ '-AS LOCATOR-' | | '-CLOB------------------------' '-integer-' +-K-+ +-FOR MIXED DATA-+ | | +-M-+ '-CCSID--integer-' | | '-G-' | | .-(1)---------------. | +-+-+---GRAPHIC----+-------------------+---------+--+----------------+-----------+------------------------------+ | | | '-(--+---------+--)-' | '-CCSID--integer-' | | | | | '-integer-' | | | | | '---+-VARGRAPHIC------+--(--+---------+--)---' | | | | '-GRAPHIC VARYING-' '-integer-' | | | | .-(1M)---------------------. | | | '---DBCLOB----+--------------------------+--+----------------+--+------------+-' | | '-(--+---------+--+---+--)-' '-CCSID--integer-' '-AS LOCATOR-' | | '-integer-' +-K-+ | | +-M-+ | | '-G-' | | .-(1)---------------. | +-+-+-BINARY--+-------------------+---------+---------------------------------+---------------------------------+ | | | '-(--+---------+--)-' | | | | | | '-integer-' | | | | | '-+-BINARY VARYING-+--(--+---------+--)-' | | | | '-VARBINARY------' '-integer-' | | | | .-(1M)---------------------. | | | '---+-BLOB----------------+----+--------------------------+--+------------+-' | | '-BINARY LARGE OBJECT-' '-(--+---------+--+---+--)-' '-AS LOCATOR-' | | '-integer-' +-K-+ | | +-M-+ | | '-G-' | +-+---DATE-----------------+------------------------------------------------------------------------------------+ | | .-(--0--)-. | | | +-TIME--+---------+------+ | | | .-(--6--)-. | | | '-TIMESTAMP--+---------+-' | | .-(200)-------------. | +---DATALINK--+-------------------+--+----------------+---------------------------------------------------------+ | '-(--+---------+--)-' '-CCSID--integer-' | | '-integer-' | '---ROWID-------------------------------------------------------------------------------------------------------'
If function-name () is specified, the function identified must have zero parameters.
If an unqualified distinct type name is specified, the database manager searches the SQL path to resolve the schema name for the distinct type.
For data types that have a length, precision, or scale attribute, use one of the following:
Specifying the FOR DATA clause or CCSID clause is optional. Omission of either clause indicates that the database manager ignores the attribute when determining whether the data types match. If either clause is specified, it must match the value that was implicitly or explicitly specified in the CREATE FUNCTION statement.
If procedure-name () is specified, the procedure identified must have zero parameters.
If an unqualified distinct type name is specified, the database manager searches the SQL path to resolve the schema name for the distinct type.
For data types that have a length, precision, or scale attribute, use one of the following:
Specifying the FOR DATA clause or CCSID clause is optional. Omission of either clause indicates that the database manager ignores the attribute when determining whether the data types match. If either clause is specified, 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.
Syntax alternatives: The following keywords are synonyms supported for compatibility to prior releases. These keywords are non-standard and should not be used:
Example 1: Insert a comment for the EMPLOYEE table.
COMMENT ON TABLE EMPLOYEE IS 'Reflects first quarter 2000 reorganization'
Example 2: Insert a comment for the EMP_VIEW1 view.
COMMENT ON TABLE EMP_VIEW1 IS 'View of the EMPLOYEE table without salary information'
Example 3: Insert a comment for the EDLEVEL column of the EMPLOYEE table.
COMMENT ON COLUMN EMPLOYEE.EDLEVEL IS 'Highest grade level passed in school'
Example 4: Enter comments on two columns in the DEPARTMENT table.
COMMENT ON DEPARTMENT (MGRNO IS 'EMPLOYEE NUMBER OF DEPARTMENT MANAGER', ADMRDEPT IS 'DEPARTMENT NUMBER OF ADMINISTERING DEPARTMENT')
Example 5: Insert a comment for the PAYROLL package.
COMMENT ON PACKAGE PAYROLL IS 'This package is used for distributed payroll processing.'