Task 3: Create TimesTen Users and Tables
You can carry out procedures to create users and target tables in TimesTen to enable support for GoldenGate replication. Performing these procedures prepares TimesTen to securely and efficiently handle data replicated by GoldenGate, ensuring smooth and reliable synchronization between systems.
- Configure TimesTen as a cache for an Oracle Database. You must define the database connection settings. For details, see Specify Database Connection Definition for Cache.
- Create the TimesTen database cache administration user
cacheadmin, whose name in this example matches the Oracle cache administration user. This user also serves as a GoldenGate administration user.Create a cache table user
oratt, whose name matches the Oracle Database schema owner of the tables to be cached in the TimesTen database.The following example creates the TimesTen users. It uses thettIsqlutility to connect to thecache1DSN as the instance administrator:Command> CREATE USER cacheadmin IDENTIFIED BY ttpwd; User created. Command> CREATE USER oratt IDENTIFIED BY ttpwd; User created.
- Assign privileges to the TimesTen users (see Grant Privileges to the TimesTen Users):
Command> GRANT CREATE SESSION, CACHE_MANAGER, CREATE ANY TABLE TO cacheadmin; Command> GRANT CREATE SESSION, CREATE ANY TABLE TO oratt;
- Two tables
customerandordersare created in the Oracle database. In TimesTen, create a log-based, read-only cache group for thecustomerandorderstables.- To create a log-based cache group for the
customerandorderstables, connect ascacheadminuser:$ ttIsql -connStr "DSN=cache1;UID=cacheadmin;PWD=ttpwd;OraclePwd=ttpwd” Command> call ttcacheuidpwdset('cacheadmin','ttpwd'); Command> call ttcachestart(); Command> CREATE DYNAMIC READONLY CACHE GROUP customer_orders FROM oratt.customer (cust_num NUMBER(6) NOT NULL, region VARCHAR2(10), name VARCHAR2(50), address VARCHAR2(100), PRIMARY KEY(cust_num)), oratt.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 oratt.customer(cust_num))method log; 1 cachegroup created.Cache groups can only be created with autorefresh state paused. In this state, all operations from GoldenGate wait until the autorefresh state is set to on and ensure that GoldenGate replicat can begin at the lowest load SCN for all of your cache groups, provided that you have the same initial data on both sides (Oracle and TimesTen). Next, you configure GoldenGate to capture data from Oracle database and apply it to TimesTen. See Task 4: Prepare TimesTen Database for GoldenGate Replication.
- GoldenGate refreshes cache tables in TimesTen with modified
data. Thus, before starting a GoldenGate Replicat process for continuous
replication, you need to perform an initial load of data to populate the
cached tables in the TimesTen database with the rows from the source
database tables. The cache group initial load is performed.
Command> LOAD CACHE GROUP customer_orders COMMIT EVERY 1000 ROWS; 200000 cache instances affected.
TimesTen uses the current SCN from Oracle database when performing a cache group load. This SCN is important because it tells you exactly when the data was loaded from the Oracle database. Once the load completes, the autorefresh state will be set to on, allowing GoldenGate operations on the cache group's tables to proceed provided their SCN is greater than the SCN used for the initial load. This behavior applies to both static and dynamic read-only cache groups.
- Before starting the Replicat process, get the initial load
SCN:
Command> cachegroups; Cache Group cacheadmin.customer_orders: Cache Group Type: Log-Based Read Only Autorefresh: Yes Autorefresh State: On Load SCN: 1827747 Aging: No aging defined Root Table: oratt.customer Child Table: oratt.orders Table Type: Read OnlyAn alternative method to retrieve the SCN is by using the built-in procedurettCacheLoadSCNGetor a system view (see SYS.V$CACHE_GROUP_LOAD_STATUS):Command> CALL ttCacheLoadSCNGet('cacheadmin', 'customer_orders'); Load_SCN –---------- 1827747 - Before you initiate Replicat at the specified SCN, you need to prepare TimesTen database for the GoldenGate replication. For details, see Task 4: Prepare TimesTen Database for GoldenGate Replication.
- To create a log-based cache group for the