Comment Definition

Comments on SQL objects are effective means to convey information, such as metric scales and one-liner documentation. Comments are only allowed on persistent objects.

comment-statement:
   COMMENT ON SCHEMA schema_name IS  { 'comment text' | NULL | '' }
   COMMENT ON TABLE [ schema_name . ] table_name IS  { 'comment text' | NULL | '' }
   COMMENT ON VIEW [ schema_name . ] view_name IS  { 'comment text' | NULL | '' }
   COMMENT ON COLUMN [ schema_name . ] table_or_view_name . column_name IS  { 'comment text' | NULL | '' }
   COMMENT ON INDEX [ schema_name . ] index_name IS  { 'comment text' | NULL | '' }
   COMMENT ON SEQUENCE [ schema_name . ] sequence_name IS  { 'comment text' | NULL | '' }
   COMMENT ON FUNCTION [ schema_name . ] function_name IS  { 'comment text' | NULL | '' }
   COMMENT ON PROCEDURE [ schema_name . ] procedure_name IS  { 'comment text' | NULL | '' }
   COMMENT ON AGGREGATE [ schema_name . ] aggregate_name IS  { 'comment text' | NULL | '' }
   COMMENT ON FILTER FUNCTION [ schema_name . ] function_name IS  { 'comment text' | NULL | '' }
   COMMENT ON LOADER [ schema_name . ] function_name IS  { 'comment text' | NULL | '' }
   COMMENT ON WINDOW [ FUNCTION ] [ schema_name . ] window_name IS  { 'comment text' | NULL | '' }

By specifying IS NULL or IS '' you remove the comment for the SQL object. For functions, procedures, aggregates, filter functions, loader functions and window functions it may be necessary to include the argument types to uniquely identify an overloaded function. See examples below for 2 filter functions.

Associated system table: sys.comments

It is not allowed or possible to add comments for columns of temporary tables in schema "tmp".

If an SQL object is removed (via DROP command), the associated comment(s) are also removed implicitly.

Examples

-- setting comment for prj4
COMMENT ON SCHEMA prj4 IS 'schema of new project 4';

-- removing comment for prj0 and prjX
COMMENT ON SCHEMA prj0 IS '';
COMMENT ON SCHEMA prjX IS NULL;

COMMENT ON TABLE sys.comments IS 'contains comments on all db objects';

COMMENT ON COLUMN sys.tables.name IS 'name of the table or view. It must be unique within the schema.';

COMMENT ON INDEX mysch.article_id IS 'unique index of id key column of article table';

COMMENT ON SEQUENCE mysch.article_id_seq IS 'sequence for article id column';

COMMENT ON FUNCTION sys.upper IS 'converts text into uppercase';

COMMENT ON AGGREGATE sys.std_dev IS 'computes the standard deviation of a group of numeric values';

COMMENT ON FILTER FUNCTION sys."ilike"(clob, clob) IS 'case insensitive pattern matching';
COMMENT ON FILTER FUNCTION sys."ilike"(clob, clob, clob)
  IS 'case insensitive pattern matching with user specified escape character';

COMMENT ON WINDOW FUNCTION sys.stddev IS 'computes the standard deviation of a group of numeric values';

SELECT * FROM sys.comments WHERE id IN (SELECT id FROM sys.ids WHERE table_name = 'mytable');