TimesTen_重建业务日志表

---备份业务日志变更表

ttisql -connStr "dsn=ttstd" -e "

creaet table TIMESTEN.XIAOXU_01bak
select * from TIMESTEN.XIAOXU_01 where AVAILTIME>=to_date('20150810','yyyymmdd');
exit;"

---重建业务日志表
ttisql -connStr "dsn=ttstd" -e "
alter session set ddl_replication_level=2;
alter session set ddl_replication_action='EXCLUDE';
truncate table  TIMESTEN.XIAOXU_01;
drop table  TIMESTEN.XIAOXU_01;
create table TIMESTEN.XIAOXU_01 (
        KEY_ID      TT_BIGINT NOT NULL,
        OID         TT_BIGINT NOT NULL,
        PRODUCT_OID TT_BIGINT NOT NULL,
        ATTR_ID     TT_INTEGER NOT NULL,
        "VALUE"     VARCHAR2(128 BYTE) INLINE NOT NULL,
        AVAILTIME   DATE NOT NULL,
        EXPIRETIME  DATE,
        SHARE_FLAG  CHAR(1 BYTE) DEFAULT 'N',

        DERIVE_FLAG CHAR(1 BYTE) DEFAULT 'N');

---为了加快数据导入速度,未建索引之前将数据导回

Command> insert into TIMESTEN.XIAOXU_01 select * from TIMESTEN.XIAOXU_01bak;
1 row inserted.
Command> commit;

----创建索引

Command>   create unique index TIMESTEN.PK_XIAO1 on TIMESTEN.XIAOXU_01
       >         (KEY_ID, OID, PRODUCT_OID);
17063: CREATE INDEX can only refer to empty tables when DDLReplicationLevel > 1
The command failed.        

 备注:创建失败,当主备开启ddl结构同步时,创建索引时,表必须为空。

---删除表数据

Command> delete TIMESTEN.XIAOXU_01;
1 row deleted.
Command> commit;
Command>  create unique index TIMESTEN.PK_XIAO1 on TIMESTEN.XIAOXU_01
       >         (KEY_ID, OID, PRODUCT_OID);   ---ok


alter active standby pair include table  TIMESTEN.XIAOXU_01;
alter session set ddl_replication_level=1;
exit;"


---将数据插回去操作
insert into TIMESTEN.XIAOXU_01
select * from TIMESTEN.XIAOXU_01bak;
commit;


---重启主备Timesten account实例释放HIGH_WATER
 ---主
 Command>call ttrepstop;
 $ttadmin -ramunload account
 ---备
 command>call ttrepstop;
 $ttadmin -ramunload account
 --主
  Command>call ttrepstart;
  Command>call ttrepstateset('active');
  Command>call ttrepstateget;
 --备
  Command>call ttrepstart;

  Command>call ttrepstateget;


Command> dssize m
  PERM_ALLOCATED_SIZE:      51200
  PERM_IN_USE_SIZE:         33764.8427734375
  PERM_IN_USE_HIGH_WATER:   34017.0322265625
  TEMP_ALLOCATED_SIZE:      6440
  TEMP_IN_USE_SIZE:         85.705078125
  TEMP_IN_USE_HIGH_WATER:   2267.828125


---比对(主备库执行查询)
ttisql -connStr "dsn=ttstd" -e "
select count(1) from  TIMESTEN.XIAOXU_01;
exit;"


---表分析
ttisql -connStr "dsn=ttstd" -e "
call ttOptEstimateStats('TIMESTEN.XIAOXU_01',1,'51  PERCENT'); commit;
exit;"

你可能感兴趣的:(数据库)