Preparing TimesTen Users and Tables

Perform procedures to create users and the target tables on the TimesTen that support GoldenGate replication.

  1. Create the TimesTen database cache administration user cacheadmin whose name will be same as the Oracle database cache administration user and it will also be a GoldenGate user.

    To create these users in your TimesTen database, connect, using the ttIsql utility, to the TimesTen database as the instance administrator user and execute:

    Command>CREATE USER cacheadmin IDENTIFIED BY ttpwd;
    User created.
  2. To create a cache table user oratt whose name is same as the Oracle database schema user of the tables to be cached in the TimesTen database:
    Command>CREATE USER oratt IDENTIFIED BY ttpwd;
    User created.
  3. 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;
  4. Create the target tables in the TimesTen database. Make the tables owned by the user cacheadmin. Connect to the database, using ttIsql, as the user cacheadmin:

    $ ttIsql -connStr "DSN=cache1;UID=cacheadmin;PWD=ttpwd"
  5. Execute the following SQL statements to create the tables on both TimesTen and Oracle databases:

    Command>CREATE TABLE customer
    (
        custid     VARCHAR2(10) NOT NULL,
        firstname  VARCHAR2(20) NOT NULL,
        lastname   VARCHAR2(20) NOT NULL,
        address    VARCHAR2(128) NOT NULL,
        phone      VARCHAR2(16) NOT NULL,
        PRIMARY KEY (custid)
    );
    Table created.
    Command>CREATE TABLE orders
    (
        orderid    NUMBER(10,0) NOT NULL,
        custid     VARCHAR2(10) NOT NULL,
        orderdate  DATE NOT NULL,
        priority   CHAR(1),
        amount     NUMBER(12,2) NOT NULL,
        PRIMARY KEY (orderid),
        FOREIGN KEY (custid) REFERENCES customer(custid)
    );
    Table created.
    Command>CREATE TABLE item
    (
        itemno     NUMBER(4,0) NOT NULL,
        orderid    NUMBER(10,0) NOT NULL,
        itemcode   VARCHAR2(10) NOT NULL,
        quantity   NUMBER(4,0) NOT NULL,
        price      NUMBER(6,2) NOT NULL,
        totalvalue NUMBER(10,2) NOT NULL,
        PRIMARY KEY (orderid,itemno),
        FOREIGN KEY (orderid) REFERENCES order(orderid)
    );
    Table created.
    quit;