ITPub博客

首页 > 数据库 > Oracle > 行连接、行迁移

行连接、行迁移

原创 Oracle 作者:wyq_0712 时间:2014-05-26 16:33:43 0 删除 编辑
1.检测行迁移和行连接
数据库级链接行的影响:
select value from v$sysstat where name='table fetch continued row';


上面反回的是由语句访问的链接行的数量。


2.获得表的链接行的数目;
分析表:
analyze table owner.table_name compute;
接下来查询DBA_TABLES得到链接行的数目:
select chain_cnt from  dba_tables where table_name ='' and owner=owner_name;
3.识别表中的链接行:
3.1 创建CHAINED_ROWS表,oracle提供了一个称为utlchain.sql 的脚本。该脚本放在ORACLE_HOME/rdbms/admin下:
3.2 分析要检查行连接和行迁移的表:
analyze table table_name list chained rows into chained_rows;


3.3 查询CHAINED_ROWS表:
select owner_name,table_name,head_rowid from chained_rows;






4.消除行连接


行连接很难消除,为了完全消除行连接,可能需要用较大的数据块尺寸重新创建数据库。
涉及以下步骤:
4.1。执行一致的全库导出。
4.2.删除旧数据库。
4.3.用较大的数据块尺寸创建新数据库。
4.4 从导出的转储文件中将数据导入新创建的数据库中。




5.消除行迁移


5.1 方法1(当大型表中有相对较少的行迁移时可用)
A,首先通过分析表并将链接行和迁移行列入chained_row表来标识这些行。
 analyze table scott.emp list chained rows into chained_rows;
B,使用create table ... as select 语句创建一个临时表并备份迁移行。
create table chain_temp as 
select * from  scott.emp
where rowid in(select head_rowid
from chained_rows);
注意:查询临时表以确保迁移行已经备份
select count(*) from chain_temp;
C,从原来的表中删除这些迁移行(先前被标识的)
delete from scott.emp
where rowid in(select head_rowid
from chained_rows);
D:从临时表中将这些行重新插入到原来的表中
insert into scott.emp select * from chain_tmp;
检查以确保这些行已经重新插入到表中,然后可以删除chain_tmp表。
drop table chain_tmp;


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29677883/viewspace-1170241/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 10046/10053事件
请登录后发表评论 登录
全部评论

注册时间:2014-05-26

  • 博文量
    27
  • 访问量
    35687