Application Development Guide

Accessing Data Source Tables and Views

This section provides information to help you access and use data source tables and views. The topics covered are:

Working with Nicknames

A nickname is an identifier by which an application can reference a data source table or view. This section:

Cataloging Information about Data Source Tables and Views

When a nickname is created for a data source table or view, DB2 updates the global catalog with information that the optimizer can use in planning how to retrieve data from the table or view. This information includes, for example, the name of the table or view and the names and attributes of the table's or view's columns.

In the case of a table, the information also includes:

To find out what information about a data source table is stored in the global catalog, query the SYSCAT.TABLES and SYSCAT.COLUMNS catalog view. To find out what information about a table's index is stored in the catalog, or what a particular index specification contains, query the SYSCAT.INDEXES catalog view. For descriptions of these views, see the SQL Reference. For further discussion about updating the global catalog with information about tables and indexes, see the Administration Guide: Implementation.

Considerations and Restrictions

There are several considerations and restrictions to bear in mind when you:

Defining, Changing, and Dropping Nicknames

For documentation on the CREATE NICKNAME, CREATE ALIAS, and DROP NICKNAME statements, see the SQL Reference.

Referencing Tables and Views by Nickname

Performing Operations on Tables and Views That Have Nicknames

Defining Column Options

When you define a nickname for a table or view, you can provide the global catalog with information about particular columns in the table or view. You specify this information in the form of values that you assign to parameters called column options. You can specify any of these values in either upper- or lowercase. Table 27 describes the column options and their values.


Table 27. Column Options and Their Settings
Option Valid Settings Default Setting
numeric_string

'y'
Yes, this column contains only strings of numeric data. IMPORTANT: If this column contains only numeric strings followed by trailing blanks, it is inadvisable to specify 'y'.

'n'
No, this column is not limited to strings of numeric data.

By setting numeric_string to 'y' for a column, you are informing the optimizer that this column contains no blanks that could interfere with sorting of the column's data.

'n'
varchar_no_trailing_blanks Indicates whether trailing blanks are absent from a specific VARCHAR column:

'y'
Yes, trailing blanks are absent from this VARCHAR column.

'n'
No, trailing blanks are not absent from this VARCHAR column.

If data source VARCHAR columns contain no padded blanks, then the optimizer's strategy for accessing them depends in part on whether they contain trailing blanks. By default, the optimizer "assumes" that they actually do contain trailing blanks. On this assumption, it develops an access strategy that involves modifying queries so that the values returned from these columns are the ones that the user expects. If, however, a VARCHAR column has no trailing blanks, and you let the optimizer know this, it can develop a more efficient access strategy. To tell the optimizer that a specific column has no trailing blanks, specify that column in the ALTER NICKNAME statement (for guidelines, see the SQL Reference).

'n'

You set column options in the ALTER NICKNAME statement. For information about this statement, see the SQL Reference.

Using Nicknames with Views

You can use nicknames with views in two main ways:

Views do not have statistics or indexes of their own because they are not actual tables located in a database. This statement is true even when a view is identical in structure and content to a single base table. For more information about statistics and indexes, see Administration Guide: Implementation.

Using Isolation Levels to Maintain Data Integrity

You can maintain data integrity for a data source table by requesting that the table's rows be locked at a specific isolation level. For example, to ensure that you have sole access to a row, you would specify the repeatable read (RR) isolation level for that row.

The federated server maps the isolation level you request to a corresponding one at the data source. To illustrate this, Table 28 lists:


Table 28. Comparable Isolation Levels between the Federated Server and Oracle Data Sources.
Federated Server (DB2) CS RR RS UR
Oracle Default Transaction read-only Transaction read-only Same as cursor stability


[ Top of Page | Previous Page | Next Page ]