相当方便快速消除行迁移的表的方法

王朝other·作者佚名  2008-05-19
宽屏版  字体: |||超大  

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有