Perform Operations On Cache Group Tables

The examples in this section perform operations on the oratt.readtab and the oratt.writetab tables to verify that TimesTen Cache is working properly.

Perform Operations on the oratt.readtab Table

This section performs operations on the oratt.readtab table.

  1. Create a shell from which you can access your Oracle Database and then use SQL*Plus to connect to the Oracle Database as the schema user (oratt, in this example). Then, insert a new row, delete an existing row, and update an existing row in the oratt.readtab table of the Oracle Database and commit the changes.
    % sqlplus oratt/oraclepwd@oracache;
    
    SQL> INSERT INTO oratt.readtab VALUES (3,'Welcome');
     
    1 row created.
     
    SQL> DELETE FROM oratt.readtab WHERE keyval=2;
     
    1 row deleted.
     
    SQL> UPDATE oratt.readtab SET str='Hi' WHERE keyval=1;
     
    1 row updated.
     
    SQL> COMMIT;
     
    Commit complete.
    

    Since the read-only cache group was created with an autorefresh interval of 5 seconds, the TimesTen oratt.readtab cache table in the readcache cache group is automatically refreshed after 5 seconds with the committed updates from the cached oratt.readtab table of the Oracle Database. The next step is to test that the data was correctly propagated from the Oracle Database to the TimesTen database.

  2. Use the kubectl exec -it command to invoke the shell in the container of the Pod that is running the TimesTen active database (cachetest-0, in this example).
    % kubectl exec -it cachetest-0 -c tt -- /bin/bash
  3. Use the TimesTen ttIsql utility to connect to the cachetest database. Query the TimesTen oratt.readtab table to verify that the table has been updated with the committed updates from the Oracle Database.
    % ttIsql cachetest;
     
    Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
    Type ? or "help" for help, type "exit" to quit ttIsql.
     
     
     
    connect "DSN=cachetest";
    Connection successful: DSN=cachetest;UID=timesten;DataStore=/tt/home/timesten/datastore/cachetest;
    DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=AL32UTF8;AutoCreate=0;
    PermSize=200;OracleNetServiceName=Oracache;DDLReplicationLevel=3;
    ForceDisconnectEnabled=1;
    (Default setting AutoCommit=1)
    
    Command> SELECT * FROM oratt.readtab;
    < 1, Hi >
    < 3, Welcome >
    2 rows found.
    

You have verified that TimesTen Cache is working correctly for the oratt.readtab table and the readcache cachegroup.

Perform Operations on the oratt.writetab Table

This example performs operations on the oratt.writetab table.

  1. Use the kubectl exec -it command to invoke the shell in the container of the Pod that is running the TimesTen active database (cachetest-0, in this example).
    % kubectl exec -it cachetest-0 -c tt -- /bin/bash
  2. Use the TimesTen ttIsql utility to connect to the cachetest database as the cache manager user (cacheuser2, in this example). Issue a SELECT statement on the TimesTen oratt.writetab table. Recall that the writecache cache group is a dynamic cache group. Thus by issuing the SELECT statement, the cache instance is automatically loaded from the cached Oracle Database table, if the data is not found in the TimeTen cache table.
    % ttIsql "DSN=cachetest;UID=cacheuser2;PWD=ttpwd;OraclePWD=oraclepwd";
     
    Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
    Type ? or "help" for help, type "exit" to quit ttIsql.
     
     
     
    connect "DSN=cachetest;UID=cacheuser2;PWD=********;OraclePWD=********";
    Connection successful: DSN=cachetest;UID=cacheuser2;DataStore=/tt/home/timesten/datastore/cachetest;
    DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=AL32UTF8;AutoCreate=0;
    PermSize=200;OracleNetServiceName=Oracache;DDLReplicationLevel=3;
    ForceDisconnectEnabled=1;
    (Default setting AutoCommit=1)
    
    Command> SELECT * FROM oratt.writetab WHERE pk=100;
    < 100, TimesTen >
    1 row found.
    
  3. Use ttIsql to insert a new row, delete an existing row, and update an existing row in the TimesTen oratt.writetab cache table, and commit the changes.
    Command> INSERT INTO oratt.writetab VALUES (102,'Cache');
    1 row inserted.
    Command> DELETE FROM oratt.writetab WHERE pk=101;
    1 row deleted.
    Command> UPDATE oratt.writetab SET attr='Oracle' WHERE pk=100;
    1 row updated.
    Command> COMMIT;
    

    The committed updates on the TimesTen oratt.writetab cache table in the writecache cache group should automatically be propagated to the oratt.writetab table in the Oracle Database.

  4. Create a shell from which you can access your Oracle Database and then use SQL*Plus to connect to the Oracle database as the schema user (oratt, in this example). Then query the contents of the oratt.writetab table in the Oracle Database to verify the committed updates from the TimesTen database have been propagated to the oratt.writetab table of the Oracle Database.
    % sqlplus oratt/oraclepwd@orapcache;
    
    SQL> SELECT * FROM oratt.writetab ORDER BY pk;
     
            PK ATTR
    ---------- ----------------------------------------
           100 Oracle
           102 Cache
    

You have verified that TimesTen Cache is working correctly for the oratt.writetab table and the writecache cachegroup.