关于TimesTen中对象变更小结
2. 新增的表
▼▼▼
create table TTUSER.BS_SPSE
(
KEY_ID NUMBER(18) not null,
SYNC_SRC_KEY VARCHAR2 (50 BYTE) not null,
ATTROID NUMBER(14) not null,
ATTRID VARCHAR2(32 BYTE) not null,
ATTRVALUE VARCHAR2(128 BYTE),
STARTDATE DATE,
ENDDATE DATE,
SPSERVID VARCHAR2(32 BYTE),
CANCELOID NUMBER(14)
)
3. 新建表加索引
▼▼▼
create unique index TTUSER.IDX_BS_SPSE_UIDon TTUSER.BS_SPSE (KEY_ID,ATTRID,SYNC_SRC_KEY,ATTROID);
▼▼▼
Command> call ttconfiguration;----查看当前参数
< CacheAwtMethod, 1 >
< CacheAwtParallelism, 1 >
< CkptFrequency, >
< CkptLogVolume, 256 >
< CkptRate, >
< CkptReadThreads, 1 >
< CommitBufferSizeMax, 10 >
< ConnectionCharacterSet, US7ASCII >
< ConnectionName, sampledb >
< Connections, 245 >
< DDLReplicationAction, INCLUDE >
< DDLReplicationLevel, 2 >
< DataBaseCharacterSet, AL32UTF8 >
< DataStore, /timesten/ttuser/datads/sampledb >
< DynamicLoadEnable, 1 >
< DurableCommits, >
create table TTUSER .BS_SP_0507 as select * from TTUSER .BS_SP;
2. 核对数据:
▼▼▼
select count(1)from (SELECT *FROM TTUSER .BS_SPminus SELECT *FROM TTUSER .BS_SP_0507);
select count(1)from (SELECT *FROM TTUSER .BS_SP_0507minus SELECT *FROM TTUSER .BS_SP);
3. 添加字段:
添加字段用删除表后修改建表语句将新字段加入重新建表的方式
alter session set ddl_replication_level=2;
DDLReplicationLevel 连接属性可以控制复制对象的行为。
DDLReplicationLevel = 1:不复制表,索引和同义词的create 和 drop,只复制复制表的添加和删除列操作
DDLReplicationLevel = 2: 缺省,复制表,索引和同义词的create 和 drop;DDLReplicationAction 必须设置为INCLUDE(缺省)
DDLReplicationLevel = 3:除了2 的所有行为外,还复制视图,序列,ttCacheUidPwdSet,以及可以为一个表加一个非空的列
alter session set ddl_replication_action='EXCLUDE';
truncate table TTUSER.BS_SP;
drop table TTUSER.BS_SP;
▼▼▼
create table TTUSER.BS_SP (
KEY_ID TT_BIGINT NOT NULL,
SP_ID VARCHAR2(64 BYTE) NOT INLINE,
SP_BIZ_ID VARCHAR2(64 BYTE) NOT INLINE,
BIZ_TYPE VARCHAR2(32 BYTE) INLINE,
PACKAGE_ID VARCHAR2(4 BYTE) INLINE,
STATUS TT_TINYINT,
THRD_NUM VARCHAR2(20 BYTE) INLINE,
AVAILTIME DATE NOT NULL,
EXPIRETIME DATE,
OID TT_BIGINT NOT NULL DEFAULT ,
PRODUCT_OID TT_BIGINT,
SYNC_SRC_KEY VARCHAR2(50 BYTE)
);
create unique index TTUSER.PK_BS_SP on TTUSER.BS_SP (KEY_ID, OID);
-----添加字段新建表之后,主库表结构及索引几分钟的时间内自动同步到备库当中。
create table TTUSER.BS_SPSE
(
KEY_ID NUMBER(18) not null,
SYNC_SRC_KEY VARCHAR2 (50 BYTE) not null,
ATTROID NUMBER(14) not null,
ATTRID VARCHAR2(32 BYTE) not null,
ATTRVALUE VARCHAR2(128 BYTE),
STARTDATE DATE,
ENDDATE DATE,
SPSERVID VARCHAR2(32 BYTE),
CANCELOID NUMBER(14)
);
create unique index TTUSER.IDX_BS_SPSE_UID on TTUSER.BS_SPSE (KEY_ID,ATTRID,SYNC_SRC_KEY,ATTROID);
------新建表之后,表结构会自动同步到备库。
▼▼▼
alter session set ddl_replication_level=2;
alter session set ddl_replication_action='EXCLUDE';
alter active standby pair include table TTUSER.BS_SP; ---调整asp关系同步
alter active standby pair include table TTUSER.BS_SPSE; ---调整asp关系同步
——主库已修改过的两个表放开asp关系中的同步为include之后,会自动同步到备库asp关系中(无需两边都执行)。
▼▼▼
insert into TTUSER.BS_SP (KEY_ID,SP_ID,SP_BIZ_ID,BIZ_TYPE,PACKAGE_ID,STATUS,THRD_NUM,AVAILTIME,EXPIRETIME,OID,PRODUCT_OID)
select KEY_ID,SP_ID,SP_BIZ_ID,BIZ_TYPE,PACKAGE_ID,STATUS,THRD_NUM,AVAILTIME,EXPIRETIME,OID,PRODUCT_OID from TTUSER .BS_SP_0507;
commit;
注:主库insert之后,不会立即同步到备库,因为数据量大提交后会在备库产生大量的锁(如下),经过一段时间后(十分钟左右)锁会自动消失,之后查询备库数据会与主库一致,主备数据自动同步完成。
▼▼▼
41982 0x2cf00f0 2030.1426 Active Database 0x01312d0001312d00 IX 0
Row BMUFVUAAACvjgcABiU Xn 0 TTUSER.BS_SP
Row BMUFVUAAACvjgcAAiU Xn 0 TTUSER.BS_SP
Row BMUFVUAAACvjgcAPiT Xn 0 TTUSER.BS_SP
Row BMUFVUAAACvjgcAOiT Xn 0 TTUSER.BS_SP
Row BMUFVUAAACvjgcANiT Xn 0 TTUSER.BS_SP
Row BMUFVUAAACvjgcAMiT Xn 0 TTUSER.BS_SP
Row BMUFVUAAACvjgcALiT Xn 0 TTUSER.BS_SP
Row BMUFVUAAACvjgcAKiT Xn 0 TTUSER.BS_SP
Row BMUFVUAAACvjgcAJiT Xn 0 TTUSER.BS_SP
▼▼▼
select count(1) from (SELECT * FROM TTUSER .BS_SP minus SELECT * FROM TTUSER .BS_SP_0507);
select count(1) from (SELECT * FROM TTUSER .BS_SP_0507 minus SELECT * FROM TTUSER .BS_SP);
▼▼▼
call ttOptEstimateStats('TTUSER.BS_SP',1,'51 PERCENT');
call ttOptEstimateStats('TTUSER.BS_SPSE',1,'51 PERCENT');
来自:https://mp.weixin.qq.com/s/385s4240rIz-Mf0odipeHg
相关文章