Proper Placement of WHERE Clause in a CREATE CACHE GROUP Statement
In a multiple-table cache group, a WHERE
clause in a particular table definition should not reference any table in the cache group other than the table itself. For example, the following CREATE CACHE GROUP
statements are valid:
CREATE READONLY CACHE GROUP customer_orders FROM sales.customer (cust_num NUMBER(6) NOT NULL, region VARCHAR2(10), name VARCHAR2(50), address VARCHAR2(100), PRIMARY KEY(cust_num)) WHERE (sales.customer.cust_num < 100), sales.orders (ord_num NUMBER(10) NOT NULL, cust_num NUMBER(6) NOT NULL, when_placed DATE NOT NULL, when_shipped DATE NOT NULL, PRIMARY KEY(ord_num), FOREIGN KEY(cust_num) REFERENCES sales.customer(cust_num));
CREATE READONLY CACHE GROUP customer_orders FROM sales.customer (cust_num NUMBER(6) NOT NULL, region VARCHAR2(10), name VARCHAR2(50), address VARCHAR2(100), PRIMARY KEY(cust_num)), sales.orders (ord_num NUMBER(10) NOT NULL, cust_num NUMBER(6) NOT NULL, when_placed DATE NOT NULL, when_shipped DATE NOT NULL, PRIMARY KEY(ord_num), FOREIGN KEY(cust_num) REFERENCES sales.customer(cust_num)) WHERE (sales.orders.cust_num < 100);
The following statement is not valid because the WHERE
clause in the child table's definition references its parent table:
CREATE READONLY CACHE GROUP customer_orders FROM sales.customer (cust_num NUMBER(6) NOT NULL, region VARCHAR2(10), name VARCHAR2(50), address VARCHAR2(100), PRIMARY KEY(cust_num)), sales.orders (ord_num NUMBER(10) NOT NULL, cust_num NUMBER(6) NOT NULL, when_placed DATE NOT NULL, when_shipped DATE NOT NULL, PRIMARY KEY(ord_num), FOREIGN KEY(cust_num) REFERENCES sales.customer(cust_num)) WHERE (sales.customer.cust_num < 100);
Similarly, the following statement is not valid because the WHERE
clause in the parent table's definition references its child table:
CREATE READONLY CACHE GROUP customer_orders FROM sales.customer (cust_num NUMBER(6) NOT NULL, region VARCHAR2(10), name VARCHAR2(50), address VARCHAR2(100), PRIMARY KEY(cust_num)) WHERE (sales.orders.cust_num < 100), sales.orders (ord_num NUMBER(10) NOT NULL, cust_num NUMBER(6) NOT NULL, when_placed DATE NOT NULL, when_shipped DATE NOT NULL, PRIMARY KEY(ord_num), FOREIGN KEY(cust_num) REFERENCES sales.customer(cust_num));