Use the LABEL ON statement

Normally, the column name is used as the column heading when showing the output of a SELECT statement in interactive SQL. By using the LABEL ON statement, you can create a more descriptive label for the column name. Because you run your examples in interactive SQL, you use the LABEL ON statement to change the column headings. Even though the column names were descriptive, it is easier to read if the column headings show each part of the name on a single line. It also allows you to see more columns of data on a single display.

To change the labels for your columns, follow these steps:

  1. Enter LABEL ON COLUMN on the Enter SQL Statements display.
  2. Press F4 (Prompt). The following display appears:
                              Specify LABEL ON Statement
     
    Type choices, press Enter.
     
      Label on . . . .   2                          1=Table or view
                                                    2=Column
                                                    3=Package
                                                    4=Alias
     
      Table or view      INVENTORY_LIST______       Name, F4 for list
        Collection . .     SAMPLECOLL__             Name, F4 for list
     
      Option . . . . .   1                          1=Column heading
                                                    2=Text
     
     
     
     
     
     
     
     
    F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F20=Display full names
    F21=Display statement
  3. Type in the name of the table and schema containing the columns for which you want to add labels.
  4. Press Enter. The following display is shown, prompting you for each of the columns in the table.
                              Specify LABEL ON Statement
     
    Type information, press Enter.
     
                           Column Heading
    Column                 ....+....1....+....2....+....3....+....4....+....5....
    ITEM_NUMBER           'ITEM                NUMBER'___________________________
    ITEM_NAME             'ITEM                NAME'_____________________________
    UNIT_COST             'UNIT                COST'_____________________________
    QUANTITY_ON_HAND      'QUANTITY            ON                  HAND'_________
    LAST_ORDER_DATE       'LAST                ORDER               DATE'_________
    ORDER_QUANTITY        'NUMBER              ORDERED'__________________________
     
     
     
     
     
     
     
     
                                                                            Bottom
    F3=Exit           F5=Refresh   F6=Insert line   F10=Copy line   F12=Cancel
    F14=Delete line   F19=Display system column names   F24=More keys
     
     
  5. Type the column headings for each of the columns. Column headings are defined in 20 character sections. Each section is displayed on a different line when showing the output of a SELECT statement. The ruler across the top of the column heading entry area can be used to easily space the headings correctly.
  6. Press Enter.
The following message indicates that the LABEL ON statement was successful:
LABEL ON for INVEN00001 in SAMPLECOLL completed.
The table name in the message is the system table name for this table, not the name that was actually specified in the statement. DB2 Universal Database™ for iSeries™ maintains two names for tables with names longer than ten characters. For more information about system table names, see the CREATE TABLE statement in the SQL Reference topic.
Note: The LABEL ON statement can also be typed in directly on the Enter SQL statements display as follows:
LABEL ON SAMPLECOLL.INVENTORY_LIST
(ITEM_NUMBER       IS ’ITEM 						NUMBER ’,
ITEM_NAME          IS ’ITEM 						NAME ’,
UNIT_COST          IS ’UNIT 						COST ’,
QUANTITY_ON_HAND   IS ’QUANTITY 				ON 						HAND ’,
LAST_ORDER_DATE    IS ’LAST 						ORDER 					DATE ’,
ORDER_QUANTITY     IS ’NUMBER 					ORDERED ’)