在awt的cg环境下,TimesTen端数据发生变化能同步到oracle端,这个是自动实现的;
而oracle端数据发生变化后,TimesTen端数据并不能随着发生变化,需要使用load/refresh来实现数据的同步。
下面来说说load/refresh在使用上有啥区别:
1、搭建测试环境
ORACLE端创建表T1:
SQL> create table t1 (x int,y varchar2(20));
Table created.
增加主键,否则tt端无法创建cg:
SQL> alter table t1 add constraint pk_t1_x primary key(x);
Table altered.
TimesTen端创建CG_T1:
Command> create asynchronous writethrough cache group OKAYLEO.CG_T1
> from
> OKAYLEO.T1 (
> X TT_BIGINT INLINE NOT NULL,
> Y VARCHAR2(20) INLINE ,
> primary key (X));
Command>
启动TimesTen的复制代理:
-bash-3.2# ttadmin -repstart emay
RAM Residence Policy : inUse
Replication Agent Policy : manual
Replication Manually Started : True
Cache Agent Policy : manual
Cache Agent Manually Started : True
2、TimesTen端操作,看ORACLE端有啥变化
TimesTen端插入数据:
Command> insert into t1 values(1,'aaa');
1 row inserted.
Command>
Command> insert into t1 values(2,'bbb');
1 row inserted.
Command>
Command> select * from t1;
< 1, aaa >
< 2, bbb >
2 rows found.
ORACLE端查询:
SQL> select * from t1;
X Y
---------- --------------------
1 aaa
2 bbb
--数据自动同步
TimesTen端修改数据:
Command> update t1 set y='xxx' where x=1;
1 row updated.
Command>
Command> select * from t1;
< 1, xxx >
< 2, bbb >
2 rows found.
ORACLE端查询
SQL> select * from t1;
X Y
---------- --------------------
1 xxx
2 bbb
--数据也是自动同步到ORACLE
3、ORACLE端操作,看TimesTen端有啥变化
ORACLE端插入一条数据:
SQL> insert into t1 values(3,'ccc');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t1;
X Y
---------- --------------------
1 xxx
2 bbb
3 ccc
TimesTen端查询:
Command> select * from t1;
< 1, xxx >
< 2, bbb >
2 rows found.
--没有变化
使用load:
Command> load cache group cg_t1 commit every 0 rows;
1 cache instance affected.
--显示一行发生了变化;
Command> select * from t1;
< 1, xxx >
< 2, bbb >
< 3, ccc >
3 rows found.
--数据已经刷新过来
ORACLE端再插入一条数据:
SQL> insert into t1 values(4,'ddd');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t1;
X Y
---------- --------------------
1 xxx
2 bbb
3 ccc
4 ddd
TimesTen端查询:
Command> select * from t1;
< 1, xxx >
< 2, bbb >
< 3, ccc >
3 rows found.
--数据还是没过来;
使用refresh:
Command> refresh cache group cg_t1 commit every 0 rows;
4 cache instances affected.
--显示4行记录被刷新
Command>
Command> select * from t1;
< 1, xxx >
< 2, bbb >
< 3, ccc >
< 4, ddd >
4 rows found.
--有数据了
ORACLE端修改:
SQL> update t1 set y='yyy' where x=2;
1 row updated.
SQL> commit;
Commit complete.
SQL> select * from t1;
X Y
---------- --------------------
1 xxx
2 yyy
3 ccc
4 ddd
TimesTen端查询:
Command> select * from t1;
< 1, xxx >
< 2, bbb >
< 3, ccc >
< 4, ddd >
4 rows found.
--依然没有变化
使用load:
Command> load cache group cg_t1 commit every 0 rows;
1 cache instance affected.
--显示1条数据被影响
Command> select * from t1;
< 1, xxx >
< 2, bbb >
< 2, yyy >
< 3, ccc >
< 4, ddd >
4 rows found.
--与tt不同的一行被load过来
使用refresh:
Command> refresh cache group cg_t1 commit every 0 rows;
4 cache instances affected.
--4行记录被刷新
Command> select * from t1;
< 1, xxx >
< 2, yyy >
< 3, ccc >
< 4, ddd >
4 rows found.
--记录重新与oracle一致
而oracle端数据发生变化后,TimesTen端数据并不能随着发生变化,需要使用load/refresh来实现数据的同步。
下面来说说load/refresh在使用上有啥区别:
1、搭建测试环境
ORACLE端创建表T1:
SQL> create table t1 (x int,y varchar2(20));
Table created.
增加主键,否则tt端无法创建cg:
SQL> alter table t1 add constraint pk_t1_x primary key(x);
Table altered.
TimesTen端创建CG_T1:
Command> create asynchronous writethrough cache group OKAYLEO.CG_T1
> from
> OKAYLEO.T1 (
> X TT_BIGINT INLINE NOT NULL,
> Y VARCHAR2(20) INLINE ,
> primary key (X));
Command>
启动TimesTen的复制代理:
-bash-3.2# ttadmin -repstart emay
RAM Residence Policy : inUse
Replication Agent Policy : manual
Replication Manually Started : True
Cache Agent Policy : manual
Cache Agent Manually Started : True
2、TimesTen端操作,看ORACLE端有啥变化
TimesTen端插入数据:
Command> insert into t1 values(1,'aaa');
1 row inserted.
Command>
Command> insert into t1 values(2,'bbb');
1 row inserted.
Command>
Command> select * from t1;
< 1, aaa >
< 2, bbb >
2 rows found.
ORACLE端查询:
SQL> select * from t1;
X Y
---------- --------------------
1 aaa
2 bbb
--数据自动同步
TimesTen端修改数据:
Command> update t1 set y='xxx' where x=1;
1 row updated.
Command>
Command> select * from t1;
< 1, xxx >
< 2, bbb >
2 rows found.
ORACLE端查询
SQL> select * from t1;
X Y
---------- --------------------
1 xxx
2 bbb
--数据也是自动同步到ORACLE
3、ORACLE端操作,看TimesTen端有啥变化
ORACLE端插入一条数据:
SQL> insert into t1 values(3,'ccc');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t1;
X Y
---------- --------------------
1 xxx
2 bbb
3 ccc
TimesTen端查询:
Command> select * from t1;
< 1, xxx >
< 2, bbb >
2 rows found.
--没有变化
使用load:
Command> load cache group cg_t1 commit every 0 rows;
1 cache instance affected.
--显示一行发生了变化;
Command> select * from t1;
< 1, xxx >
< 2, bbb >
< 3, ccc >
3 rows found.
--数据已经刷新过来
ORACLE端再插入一条数据:
SQL> insert into t1 values(4,'ddd');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t1;
X Y
---------- --------------------
1 xxx
2 bbb
3 ccc
4 ddd
TimesTen端查询:
Command> select * from t1;
< 1, xxx >
< 2, bbb >
< 3, ccc >
3 rows found.
--数据还是没过来;
使用refresh:
Command> refresh cache group cg_t1 commit every 0 rows;
4 cache instances affected.
--显示4行记录被刷新
Command>
Command> select * from t1;
< 1, xxx >
< 2, bbb >
< 3, ccc >
< 4, ddd >
4 rows found.
--有数据了
ORACLE端修改:
SQL> update t1 set y='yyy' where x=2;
1 row updated.
SQL> commit;
Commit complete.
SQL> select * from t1;
X Y
---------- --------------------
1 xxx
2 yyy
3 ccc
4 ddd
TimesTen端查询:
Command> select * from t1;
< 1, xxx >
< 2, bbb >
< 3, ccc >
< 4, ddd >
4 rows found.
--依然没有变化
使用load:
Command> load cache group cg_t1 commit every 0 rows;
1 cache instance affected.
--显示1条数据被影响
Command> select * from t1;
< 1, xxx >
< 2, bbb >
< 2, yyy >
< 3, ccc >
< 4, ddd >
4 rows found.
--与tt不同的一行被load过来
使用refresh:
Command> refresh cache group cg_t1 commit every 0 rows;
4 cache instances affected.
--4行记录被刷新
Command> select * from t1;
< 1, xxx >
< 2, yyy >
< 3, ccc >
< 4, ddd >
4 rows found.
--记录重新与oracle一致
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12355989/viewspace-709368/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12355989/viewspace-709368/