CREATE CACHE Statement
This statement populates the cache with a
You can define cache for use by a single query with the WITH clause in the SELECT statement or for use by multiple queries in a session with the CREATE CACHE statement. For more information, see Using WITH to Create Caches.
BNF
<create-cache-statement> ::= CREATE <optional-scope> <create-cache-subset> [<create-cache-subset>...]
<create-cache-subset> ::= CACHE FOR <cube-name> AS '(<set-expression> [,<set-expression>...])'
<optional-scope> ::= <empty> | SESSION
<cube name> ::= CURRENTCUBE | <Cube Identifier>
Remarks
Each <set-expression> token must contain members from only one dimension. Each member must be distinct. Each <set-expression> token must be from a different dimension.
The <set-expression> token can contain functions that support Multidimensional Expressions (MDX) syntax. The <set-expression> token cannot contain measures.
A cache created with CREATE CACHE without an <optional-scope> value token has session scope.
It is an error to specify a cube other than that to which it is currently connected. Therefore, you should use CURRENTCUBE in place of a cube name to denote the current cube.
Scope
Cache can occur within one of the following scopes:
Query scope
The lifetime of the cache is limited to the query. The cache is defined in an individual query. Query scope overrides session scope. For more information, see Using WITH to Create Caches.
Session scope
The lifetime of the cache is limited to the session in which it is created. The CREATE CACHE statement is used to create cache with session scope.
Examples
Creating a Cache with Session Scope
The following example creates a cache with session scope:
CREATE SESSION CACHE FOR Warehouse AS '({USA,Canada})'