Comments to Describe Tables and Views
When working with tables and views in applications, it is helpful to include commentary about the structure and uses of tables and views.
Tables and views can be commented with:
• Comment lines in SQL or a host language, for example, “/*comment*/” or “--comment”
• Comments specified with the COMMENT ON statement
When using Director, you can see the definition of a view at a glance, as well as its rows and the grants that have been defined. For a table, you can view its rows and columns, as well as properties, statistics, and other pertinent information.
The COMMENT ON Statement
The COMMENT ON statement lets you add commentary to SQL programs. Using this statement, you can create a comment for the table, view, and for individual columns in the table.
For example, to add a remark on the name column and on the status column of the employee table:
COMMENT ON employee IS
'This is the ALL Employees table including managers and their direct reports';
COMMENT ON COLUMN employee.status IS
'valid codes are:
01, exempt; 02, non-exempt; 03, temp';
To show a comment, use the HELP COMMENT statement. For example, the comment on the status column can be shown by the statement:
HELP COMMENT COLUMN employee status;
To delete a comment, specify an empty string. For example, the comment on the status column can be deleted by the statement:
COMMENT ON COLUMN employee.status IS '';
For complete details, see the COMMENT ON statement in the SQL Language Guide.
Last modified date: 06/28/2024