Using a WHERE Clause

A cache table definition in a CREATE CACHE GROUP statement can contain a WHERE clause to restrict the rows to cache in the TimesTen database for particular cache group types.

You can also specify a WHERE clause in a LOAD CACHE GROUP, UNLOAD CACHE GROUP, REFRESH CACHE GROUP or FLUSH CACHE GROUP statement for particular cache group types. Some statements, such as LOAD CACHE GROUP and REFRESH CACHE GROUP, may result in concatenated WHERE clauses in which the WHERE clause for the cache table definition is evaluated before the WHERE clause in the LOAD CACHE GROUP or REFRESH CACHE GROUP statement.

The following restrictions apply to WHERE clauses used in cache table definitions and cache group operations:

  • WHERE clauses can only be specified in the cache table definitions of a CREATE CACHE GROUP statement for read-only and user managed cache groups.

  • A WHERE clause can be specified in a LOAD CACHE GROUP statement except on a static cache group with autorefresh.

    See Manually Loading and Refreshing a Cache Group for more information about the LOAD CACHE GROUP.

  • A WHERE clause can be specified in a REFRESH CACHE GROUP statement except on a cache group with autorefresh.

    See Manually Loading and Refreshing a Cache Group for more information about the REFRESH CACHE GROUP statement.

  • A WHERE clause can be specified in a FLUSH CACHE GROUP statement on a user managed cache group that allows committed changes on the TimesTen cache tables to be flushed to the cached Oracle Database tables.

    See Flushing a User Managed Cache Group for more information about the FLUSH CACHE GROUP statement.

  • WHERE clauses in a CREATE CACHE GROUP statement cannot contain a subquery. Therefore, each WHERE clause cannot reference any table other than the one in its cache table definition. However, a WHERE clause in a LOAD CACHE GROUP, UNLOAD CACHE GROUP, REFRESH CACHE GROUP or FLUSH CACHE GROUP statement may contain a subquery.

  • A WHERE clause in a LOAD CACHE GROUP, REFRESH CACHE GROUP or FLUSH CACHE GROUP statement can reference only the root table of the cache group, unless the WHERE clause contains a subquery.

  • All tables and columns referenced in WHERE clauses when creating, loading, refreshing, unloading or flushing the cache group must be fully qualified. For example:

    owner.table_name and owner.table_name.column_name