处理方案
o 在大多数情况下,行链接是无法克服的,特别是在一个表包含象LONGS, LOBs 等这样的列时。当在不同的表中有大量的链接行,并且哪些表的行的长度不是很长时,你可以通过用更大的block size重建数据库的方法来解决它。
例如:当前你的数据库的数据块的大小为4K,但是你的行的平均长度为6k,那么你可以通过用8k大小的数据块来重建数据库的办法解决行链接现象。
o 行迁移主要是由于设置的PCTFREE参数过小,导致没有给update操作留下足够的空闲空间引起。为了避免行迁移,所有被修改的表应该设置合适的 PCTFREE 值,以便在每个数据块内为数据修改保留足够的空间。可以通过增加PCTFREE值的办法来避免行迁移,但这种解决办法是以牺牲更多的空间为代价的,这也就是我们通常所说的以空间换效率。 而且通过增加PCTFREE值的办法只能缓解行迁移现象,而不能完全解决行迁移,所以较好的办法是在设置了合适的PCTFREE值的后,在发现行迁移现象比较严重时,对表的数据进行重组。下面是对行迁移数据进行重组的步骤(这种方法也被成为CTAS):
- -- Get the name of the table with migrated rows:
- ACCEPT table_name PROMPT 'Enter the name of the table with migrated rows: '
- -- Clean up from last execution
- set echo off
- DROP TABLE migrated_rows;
- DROP TABLE chained_rows;
- -- Create the CHAINED_ROWS table
- @.../rdbms/admin/utlchain.sql
- set echo on
- spool fix_mig
- -- List the chained and migrated rows
- ANALYZE TABLE &table_name LIST CHAINED ROWS;
- -- Copy the chained/migrated rows to another table
- create table migrated_rows as
- SELECT orig.*
- FROM &table_name orig, chained_rows cr
- WHERE orig.rowid = cr.head_rowid
- AND cr.table_name = upper('&table_name');
- -- Delete the chained/migrated rows from the original table
- DELETE FROM &table_name WHERE rowid IN (SELECT head_rowid FROM chained_rows);
- -- Copy the chained/migrated rows back into the original table
- INSERT INTO &table_name SELECT * FROM migrated_rows;
- spool off
