行迁移消除中的疑问!
exp和imp可以将行迁移删除!我不太理解!为什么这样做能实现!请斑竹和高人从理论和实际层面加以讲解!谢谢!检查行链接和行迁移的方法
1.执行utlchain.sql脚本
SQL> CREATE TABLE chained_rows (
2owner_name VARCHAR2(30),
3table_name VARCHAR2(30),
4cluster_name VARCHAR2(30),
5partition_name VARCHAR2(30),
6head_rowid ROWID,
7analyze_timestampDATE );
创建chained_rows表,然后分析
SQL> ANALYZE TABLE oe.orders LIST CHAINED ROWS;
Table analyzed.
SQL> SELECTowner_name, table_name, head_rowid
2 FROMchained_rows
3 WHERE table_name = 'ORDERS';
OWNER_NAMETABLE_NAMEHEAD_ROWID
--------------------------------------
SALES ORDER_HISTAAAAluAAHAAAAA1AAA
SALES ORDER_HISTAAAAluAAHAAAAA1AAB
2.对行迁移的处理
a).exp/drop/imp table
b).alter table emp move ...;
c).查找迁移的行,拷贝迁移的行到一个新表,删除原记录,然后从新表将行拷贝到原表
3.相关的脚本
/* 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
SET ECHO ON
SPOOL fix_mig
/* List the chained & 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
参考一下,不知道是否能用上。 我的意思是,导入和导出是如何实现对行迁移的删除的!后台进行了什么操作或是如何实现的!我想知道原理!谢谢
页:
[1]