SQL System Catalog: Remarks

IBM’s DB2 products allow you to associate up to 254 characters of remarks with each table, view, and column defined in the database. The remarks allow you to store a brief description of the table or data item in the system catalog. The remarks are stored in the SYSCAT.TABLES and SYSCAT.COLUMNS system tables of the system catalog. Unlike the other elements of table and column definitions, the remarks and labels are not specified by the CREATE TABLE statement. Instead, the COMMENT statement is used. Its syntax is shown in Figure 16-2. Here are some examples:

Define remarks for the OFFICES table.

 COMMENT ON TABLE OFFICES

IS ‘This table stores data about our sales offices’

Associate some remarks with the TARGET and SALES columns of the OFFICES table.

COMMENT ON OFFICES

(TARGET IS ‘This is the annual sales target for the office’,

  SALES IS ‘This is the year-to-date sales for the office’)

Because this is a capability carried forward from some of the earliest IBM SQL products, Oracle also supports the COMMENT ON statement for attaching comments to tables and columns. The comments are not stored inline with other table and column information, however. They are accessible via the Oracle system views USER_TAB_COMMENTS and USER_COL_COMMENTS. The DB2 COMMENT capability has been expanded over the years to allow comments on constraints, stored procedures, schemas, tablespaces, triggers, and other DB2 database objects. This capability is not part of the SQL standard and has generally not been adopted by other major DBMS products.

Source: Liang Y. Daniel (2013), Introduction to programming with SQL, Pearson; 3rd edition.

Leave a Reply

Your email address will not be published. Required fields are marked *