Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » SQL Anywhere Server - SQL Reference » SQL statements » Alphabetical list of SQL statements

COMMENT statement

Stores a comment for a database object in the system tables.

Syntax
COMMENT ON {
    COLUMN [ owner.]table-name.column-name
   | CERTIFICATE certificate-name
   | DBSPACE dbspace-name
   | EVENT [ owner.]event-name
   | EXTERNAL ENVIRONMENT environment-name
   | EXTERNAL [ ENVIRONMENT ] OBJECT object-name
   | FOREIGN KEY [ owner.]table-name.key-name
   | INDEX [ [ owner.] table.]index-name
   | INTEGRATED LOGIN integrated-login-id
   | JAVA CLASS java-class-name
   | JAVA JAR java-jar-name
   | KERBEROS LOGIN "client-Kerberos-principal"
   | LDAP SERVER ldapua-server-name
   | LOGIN POLICY policy-name
   | MATERIALIZED VIEW [ owner.]materialized-view-name
   | MIRROR SERVER mirror-server-name
   | ODATA PRODUCER name
   | PRIMARY KEY ON [ owner.]table-name
   | PROCEDURE [ owner.]procedure-name
   | PUBLICATION [ owner.] publication-name
   | REMOTE MESSAGE TYPE remote-message-type-name
   | ROLE role-name
   | SEQUENCE sequence-name
   | SERVICE web-service-name
   | SPATIAL REFERENCE SYSTEM srs-name 
   | SPATIAL UNIT OF MEASURE uom-identifier 
   | SYNCHRONIZATION PROFILE synchronization-profile-name
   | TABLE [ owner.]table-name
   | TEXT CONFIGURATION [ owner.]text-config-name
   | TEXT INDEX text-index-name ON [ owner.]table-name
   | TIME ZONE name 
   | TRIGGER [ [ owner.]tablename.]trigger-name
   | USER userid
   | VIEW [ owner.]view-name
}
IS comment
comment : string | NULL
environment-name : 
JAVA
| PERL
| PHP
| CLR
| C_ESQL32
| C_ESQL64
| C_ODBC32
| C_ODBC64
Remarks

The COMMENT statement allows you to set a remark (comment) for an object in the database. The COMMENT statement updates remarks listed in the ISYSREMARK system table. You can remove a comment by setting it to NULL. For a comment on an index or trigger, the owner of the comment is the owner of the table on which the index or trigger is defined.

You cannot add comments for local temporary tables.

If you use the Database Documentation Wizard to document your database, you have the option to include the comments for procedures, functions, triggers, events, and views in the output.

Privileges

If you have the COMMENT ANY OBJECT system privilege, you can comment on any you can create with the CREATE ANY OBJECT system privilege. If you do not have the COMMENT ANY OBJECT system privilege, you must have the equivalent as noted below:

  • For database objects, at least one of the following must be true:

    • you own the object

    • you have the ability to create or alter objects of the same type owned by other users (for example, CREATE ANY TABLE, or ALTER ANY OBJECT)

    • you have the ability to manage objects of that type (for example, MANAGE ANY USER)

  • For system roles, you must have the administrative privilege over the role.

  • For user-defined roles, you must have the MANAGE ROLES system privilege, or have administrative privilege over the role.

  • For Kerberos or integrated logins, you must have the MANAGE ANY USER system privilege.

  • For Java classes or jars, you must have the MANAGE ANY EXTERNAL OBJECT system privilege.

Side effects

Automatic commit.

Standards
  • ANSI/ISO SQL Standard

    Not in the standard.

  • Transact-SQL

    Not supported by Adaptive Server Enterprise.

Example

The following examples show how to add and remove a comment.

  1. Add a comment to the Employees table:

    COMMENT ON TABLE GROUPO.Employees
    IS 'Employee information';
  2. Remove the comment from the Employees table:

    COMMENT
    ON TABLE GROUPO.Employees
    IS NULL;

To view the comment set for an object, use a SELECT statement. The following statement retrieves the comment set for the ViewSalesOrders view in the SQL Anywhere sample database.

SELECT remarks 
FROM SYSTAB t, SYSREMARK r 
WHERE t.object_id = r.object_id 
AND t.table_name = 'ViewSalesOrders';