This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

COMMENT ON statements

COMMENT ON statements let you create comments on database objects, such as schemas, tables, and libraries.

COMMENT ON statements let you create comments on database objects, such as schemas, tables, and libraries. Each object can have one comment. Comments are stored in the system table COMMENTS.

1 - COMMENT ON AGGREGATE FUNCTION

Adds, revises, or removes a comment on an aggregate function.

Adds, revises, or removes a comment on an aggregate function. Each object can have one comment. Comments are stored in the system table COMMENTS.

Syntax

COMMENT ON AGGREGATE FUNCTION [[database.]schema.]function (function-args) IS { 'comment' | NULL };

Parameters

[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

function
The name of the aggregate function with which to associate the comment.
function-args
The function arguments.
comment
Specifies the comment text to add. If a comment already exists for this function, this overwrites the previous one.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment to the APPROXIMATE_MEDIAN(x FLOAT) function:

=> COMMENT ON AGGREGATE FUNCTION APPROXIMATE_MEDIAN(x FLOAT) IS 'alias of APPROXIMATE_PERCENTILE with 0.5 as its parameter';

The following example removes a comment from the APPROXIMATE_MEDIAN(x FLOAT) function:

=> COMMENT ON AGGREGATE FUNCTION APPROXIMATE_MEDIAN(x FLOAT) IS NULL;

2 - COMMENT ON ANALYTIC FUNCTION

Adds, revises, or removes a comment on an analytic function.

Adds, revises, or removes a comment on an analytic function. Each object can have one comment. Comments are stored in the system table COMMENTS.

Syntax

COMMENT ON ANALYTIC FUNCTION [[database.]schema.]function (function-args) IS { 'comment' | NULL };

Parameters

[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

function
The name of the analytic function with which to associate the comment.
function-args
The function arguments.
comment
Specifies the comment text to add. If a comment already exists for this function, this overwrites the previous one.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment to the user-defined an_rank() function:

=> COMMENT ON ANALYTIC FUNCTION an_rank() IS 'built from the AnalyticFunctions library';

The following example removes a comment from the user-defined an_rank() function:

=> COMMENT ON ANALYTIC FUNCTION an_rank() IS NULL;

3 - COMMENT ON CONSTRAINT

Adds, revises, or removes a comment on a constraint.

Adds, revises, or removes a comment on a constraint. Each object can have one comment. Comments are stored in the system table COMMENTS.

Syntax

COMMENT ON CONSTRAINT constraint ON [[database.]schema.]table IS ... {'comment' | NULL };

Parameters

constraint
The name of the constraint associated with the comment.
[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

table
The name of the table constraint with which to associate a comment.
comment
Specifies the comment text to add. If a comment already exists for this constraint, this comment overwrites the previous one.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment to the constraint_x constraint on the promotion_dimension table:

=> COMMENT ON CONSTRAINT constraint_x ON promotion_dimension IS 'Primary key';

The following example removes a comment from the constraint_x constraint on the promotion_dimension table:

=> COMMENT ON CONSTRAINT constraint_x ON promotion_dimension IS NULL;

4 - COMMENT ON FUNCTION

Adds, revises, or removes a comment on a function.

Adds, revises, or removes a comment on a function. Each object can have one comment. Comments are stored in the system table COMMENTS.

Syntax

COMMENT ON FUNCTION [[database.]schema.]function (function-args) IS { 'comment' | NULL };

Parameters

[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

function
The name of the function with which to associate the comment.
function-args
The function arguments.
comment
Specifies the comment text to add. If a comment already exists for this function, this overwrites the previous one.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment to the macros.zerowhennull (x INT) function:

=> COMMENT ON FUNCTION macros.zerowhennull(x INT) IS 'Returns a 0 if not NULL';

The following example removes a comment from the macros.zerowhennull (x INT) function:

=> COMMENT ON FUNCTION macros.zerowhennull(x INT) IS NULL;

5 - COMMENT ON LIBRARY

Adds, revises, or removes a comment on a library.

Adds, revises, or removes a comment on a library . Each object can have one comment. Comments are stored in the system table COMMENTS.

Syntax

COMMENT ON LIBRARY [[database.]schema.]library IS {'comment' | NULL}

Parameters

[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

*library*
The name of the library associated with the comment.
*comment*
Specifies the comment text to add. If a comment already exists for this library, this comment overwrites the previous one.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment to the library MyFunctions:

=> COMMENT ON LIBRARY MyFunctions IS 'In development';

The following example removes a comment from the library MyFunctions:

=> COMMENT ON LIBRARY MyFunctions IS NULL;

See also

6 - COMMENT ON NODE

Adds, revises, or removes a comment on a node.

Adds, revises, or removes a comment on a node. Each object can have one comment. Comments are stored in the system table COMMENTS.

Dropping an object drops all comments associated with the object.

Syntax

COMMENT ON NODE node-name IS  { 'comment' | NULL }

Parameters

node-name
The name of the node associated with the comment.
comment
Specifies the comment text to add. If a comment already exists for this node, this comment overwrites the previous one.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment for the initiator node:

=> COMMENT ON NODE initiator IS 'Initiator node';

The following example removes a comment from the initiator node:

=> COMMENT ON NODE initiator IS NULL;

See also

COMMENTS

7 - COMMENT ON PROJECTION

Adds, revises, or removes a comment on a projection.

Adds, revises, or removes a comment on a projection. Each object can have one comment. Comments are stored in the system table COMMENTS.

Dropping an object drops all comments associated with the object.

Syntax

COMMENT ON PROJECTION [[database.]schema.]projection IS { 'comment' | NULL }

Parameters

[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

projection
The name of the projection associated with the comment.
comment
Specifies the text of the comment to add. If a comment already exists for this projection, the comment you enter here overwrites the previous comment.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment to the customer_dimension_vmart_node01 projection:

=> COMMENT ON PROJECTION customer_dimension_vmart_node01 IS 'Test data';

The following example removes a comment from the customer_dimension_vmart_node01 projection:

=> COMMENT ON PROJECTION customer_dimension_vmart_node01 IS NULL;

See also

COMMENTS

8 - COMMENT ON PROJECTION COLUMN

Adds, revises, or removes a projection column comment.

Adds, revises, or removes a projection column comment. Each object can have one comment. Comments are stored in the system table COMMENTS.

Syntax

COMMENT ON COLUMN [[database.]schema.]projection.column IS {'comment' | NULL}

Parameters

[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

projection.column
The name of the projection and column with which to associate the comment.
comment
Specifies the comment text to add. If a comment already exists for this column, this comment overwrites the previous comment.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment to the customer_name column in the customer_dimension projection:

=> COMMENT ON COLUMN customer_dimension_vmart_node01.customer_name IS 'Last name only';

The following example removes a comment from the customer_name column in the customer_dimension projection:

=> COMMENT ON COLUMN customer_dimension_vmart_node01.customer_name IS NULL;

9 - COMMENT ON SCHEMA

Adds, revises, or removes a comment on a schema.

Adds, revises, or removes a comment on a schema. Each object can have one comment. Comments are stored in the system table COMMENTS.

Syntax

COMMENT ON SCHEMA schema-name IS {'comment' | NULL}

Parameters

*schema-name*
The schema associated with the comment.
*comment*
Text of the comment to add. If a comment already exists for this schema, the comment you enter here overwrites the previous comment.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment to the public schema:

=> COMMENT ON SCHEMA public  IS 'All users can access this schema';

The following example removes a comment from the public schema.

=> COMMENT ON SCHEMA public IS NULL;

10 - COMMENT ON SEQUENCE

Adds, revises, or removes a comment on a sequence.

Adds, revises, or removes a comment on a sequence. Each object can have one comment. Comments are stored in the system table COMMENTS.

Syntax

COMMENT ON SEQUENCE [[database.]schema.]sequence IS { 'comment' | NULL }

Parameters

[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

*sequence*
The name of the sequence associated with the comment.
*comment*
Specifies the text of the comment to add. If a comment already exists for this sequence, this comment overwrites the previous one.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment to the sequence called prom_seq.

=> COMMENT ON SEQUENCE prom_seq IS 'Promotion codes';

The following example removes a comment from the prom_seq sequence.

=> COMMENT ON SEQUENCE prom_seq IS NULL;

11 - COMMENT ON TABLE

Adds, revises, or removes a comment on a table.

Adds, revises, or removes a comment on a table. Each object can have one comment. Comments are stored in the system table COMMENTS.

Syntax

COMMENT ON TABLE [[database.]schema.]table IS { 'comment' | NULL }

Parameters

[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

table
The name of the table with which to associate the comment.
comment
Specifies the text of the comment to add. Enclose the text of the comment within single-quotes. If a comment already exists for this table, the comment you enter here overwrites the previous comment.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes a previously added comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment to the promotion_dimension table:

=> COMMENT ON TABLE promotion_dimension IS '2011 Promotions';

The following example removes a comment from the promotion_dimension table:

=> COMMENT ON TABLE promotion_dimension IS NULL;

12 - COMMENT ON TABLE COLUMN

Adds, revises, or removes a table column comment.

Adds, revises, or removes a table column comment. Each object can have one comment. Comments are stored in the system table COMMENTS.

Syntax

COMMENT ON COLUMN [[database.]schema.]table.column IS {'comment' | NULL}

Parameters

[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

table.column
The name of the table and column with which to associate the comment.
comment
Specifies the comment text to add. If a comment already exists for this column, this comment overwrites the previous comment.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment to the transaction_time column in the store_sales_fact table in the store schema:

=> COMMENT ON COLUMN store.store_sales_fact.transaction_time IS 'GMT';

The following example removes a comment from the transaction_time column in the store_sales_fact table in the store schema:

=> COMMENT ON COLUMN store.store_sales_fact.transaction_time IS NULL;

13 - COMMENT ON TRANSFORM FUNCTION

Adds, revises, or removes a comment on a user-defined transform function.

Adds, revises, or removes a comment on a user-defined transform function. Each object can have one comment. Comments are stored in the system table COMMENTS.

Syntax

COMMENT ON TRANSFORM FUNCTION [[database.]schema.]tfunction
...( [ tfunction-arg-name tfunction-arg-type ][,...] ) IS {'comment' | NULL}

Parameters

[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

*tfunction*
The name of the transform function with which to associate the comment.
tfunction-arg-name tfunction-arg-type
The names and data types of one or more transform function arguments. If you supply argument names and types, each type must match the type specified in the library used to create the original transform function.
*comment*
Specifies the comment text to add. If a comment already exists for this transform function, this comment overwrites the previous one.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment to the macros.zerowhennull (x INT) UTF function:

=> COMMENT ON TRANSFORM FUNCTION macros.zerowhennull(x INT) IS 'Returns a 0 if not NULL';

The following example removes a comment from the acros.zerowhennull (x INT) function by using the NULL option:

=> COMMENT ON TRANSFORM FUNCTION macros.zerowhennull(x INT) IS NULL;

14 - COMMENT ON VIEW

Adds, revises, or removes a comment on a view.

Adds, revises, or removes a comment on a view. Each object can have one comment. Comments are stored in the system table COMMENTS.

Syntax

COMMENT ON VIEW [[database.]schema.]view IS { 'comment' | NULL }

Parameters

[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

*view*
The name of the view with which to associate the comment.
*comment*
Specifies the text of the comment to add. If a comment already exists for this view, this comment overwrites the previous one.

Comments can be up to 8192 characters in length. If a comment exceeds that limitation, Vertica truncates the comment and alerts the user with a message.

NULL
Removes an existing comment.

Privileges

Non-superuser: object owner

Examples

The following example adds a comment from the curr_month_ship view:

=> COMMENT ON VIEW curr_month_ship IS 'Shipping data for the current month';

The following example removes a comment from the curr_month_ship view:

=> COMMENT ON VIEW curr_month_ship IS NULL;