Row Migration,是Oracle里面的一个重要的基本概念。 一般传统意义上,我们需要消除行迁移。 因为这样,会造成额外的IO消耗。传统的办法一般是导入倒出整个表。 但是这样的风险比较大,而且Downtime会比较长。
当有外键约束之类的时候,也非常的麻烦。 也有人选择用删除migration的行,然后重新Insert ,但是和EXP/Imp一样,当遭碰到FK/PK限制的时候,也会很头疼。 我们可以用下面的办法来最方便的进行重组,消除row migration: SQL> alter table t add t1 date default sysdate; Table altered. SQL> c/t1/t2 1* alter table t add t2 date default sysdate SQL> / Table altered. SQL> c/t2/t3 1* alter table t add t3 date default sysdate SQL> / Table altered. SQL> analyze table t compute statistics; Table analyzed. SQL> select table_name,num_rows,CHAIN_CNT from user_tables where table_name='T'; TABLE_NAME NUM_ROWS CHAIN_CNT ------------------------------ ---------- ---------- T 41616 3908 SQL> alter table t move ; Table altered. SQL> analyze table t compute statistics; Table analyzed. SQL> select table_name,num_rows,CHAIN_CNT from user_tables where table_name='T'; TABLE_NAME NUM_ROWS CHAIN_CNT ------------------------------ ---------- ---------- T 41616 0
|