Task 3: Create a Static Read-Only Cache Group on the TimesTen Database
Create a static read-only cache group with autorefresh on the TimesTen database.
-
As the TimesTen cache administration user, create a static read-only cache group on a TimesTen database with the
CREATE READONLY CACHE GROUPSQL statement. Use the unique index columns as the primary key definition.The following example shows how the
salescustomersandorderstables on the Oracle database will be cached in a cache group calledcustomer_orders.% ttIsql "DSN=cache1;UID=cacheadmin;PwdWallet=/wallets/cacheadminwallet" Command> CREATE READONLY CACHE GROUP customer_orders AUTOREFRESH FROM sales.customers (cust_num NUMBER(6) NOT NULL, region VARCHAR2(10), name VARCHAR2(50), 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.customers(cust_num));Note:
This SQL statement creates the cache group and the cache tables on the TimesTen database. Autorefresh is added by default for read-only cache groups. Autorefresh defaults to incremental autorefresh running every 5 minutes.
When you choose data types for columns in the TimesTen cache tables, consider the data types of the columns in the Oracle Database tables and choose an equivalent or compatible data type for the columns in the cache tables. See Mappings Between Oracle Database and TimesTen Data Types
-
Exit the
ttIsqlutility that is connected as the TimesTen cache administration user. Then, restart thettIsqlutility and connect to thecache1DSN as the instance administrator.Grant the
SELECTprivilege on thesales.customersandsales.orderscache tables to the TimesTen cache administration user so that this user can issueSELECTqueries on these tables.Command> exit; Disconnecting... Done. % ttIsql cache1 Command> GRANT SELECT ON sales.customers TO cacheadmin; Command> GRANT SELECT ON sales.orders TO cacheadmin; Command> exit; Disconnecting... Done.