Purpose
Retrieves a previously placed comment on a database object or definition.
For information about the comment-placing form of this SQL statement, see “COMMENT (Comment-Placing Form)” in SQL Data Definition Language .
Required Privileges
None.
Privileges Granted Automatically
None.
Syntax
Syntax Elements
- object_kind_1
- Mandatory database object kind specification.
- object_kind_2
- Optional database object kind specification.
- database_name
- user_name
- Containing database or user for object_name if it is not contained by the current database or user.
- object_name
- Name of the object for which a comment is to be retrieved, including:
- Parameter in a macro, stored procedure, or user-defined function.
- Column in a user base table, error table, hash index, join index, or view.
- Specific function, macro, profile, role, stored procedure, base table, error table, hash index, join index, trigger, or view name contained by a database or user.
- Database or user.
- UDT. You can retrieve a comment on a particular attribute of a structured UDT by specifying database_name.udt_name.attribute_name.
- A method. You must use the specific method name.
- A GLOP set.
ANSI Compliance
COMMENT is a Teradata extension to the ANSI SQL:2011 standard.
Rules for Using COMMENT (Comment-Retrieving Form)
These rules apply to using the comment-retrieving form of the COMMENT statement:
- COMMENT (Comment-Retrieving Form) is treated as a DML statement for transaction processing, so it can be used in 2PC session mode. For a brief description of the two-phase commit protocol, see
Introduction to Teradata
.
You can specify a COMMENT (Comment-Retrieving Form) request at any point within the boundaries of an explicit transaction in Teradata session mode.
- To retrieve a comment, do not specify a comment string following the specification of the object name.
IF you … | THEN the system … |
---|---|
specify a comment string | does one of the following things:
|
do not specify a comment string | does one of the following things:
|
- You cannot specify a containing database or user name if the object kind you specify is GROUP.
Example: Retrieving a Comment
Suppose you have placed the following comment describing the name column in the employee table:
COMMENT ON COLUMN employee.name IS 'Employee name, last name followed by first initial';
The following request retrieves this comment:
COMMENT ON COLUMN employee.name;
The request returns the comment string as created by the previous request:
Employee name, last name followed by first initial
Note that because the object kind for this request is COLUMN, you must specify the keyword COLUMN when you code it.
Example: Placing a Comment
Suppose you have defined a hash index named ord_hidx defined on the orders table, which is contained in the accounting database.
Because the object kind for this request is TABLE, representing a hash index, you are not required to specify TABLE in the request.
You could type the following comment-placing COMMENT request to define a comment on the hash index ord_hidx:
COMMENT accounting.ord_hidx AS 'hash index on Orders';
Then if you were to perform the following comment-retrieving COMMENT request, the text that follows would be returned to you:
COMMENT accounting.ord_hidx; hash index on orders