【redefined】在线重定义概览与详细使用(三)

2014-11-24 15:01:41 · 作者: · 浏览: 2
n.copy_table_dependents()过程,自动在中间表上建立原表上有的依赖对象,并且对这些对象进行自动register。Register可以使得中间表上的依赖对象在在线重定义过程中与原始表上的依赖对象进行转换。当在线重定义完成后,中间表上将具有和原表上相同名字的依赖对象。
Method 2: Manually Creating Dependent Objects
You can manually create dependent objects on the interim table and then register them.
---你也可以手动在中间表上建立这些依赖对象,然后在调用dbms_redefinition.register_dependence_object()包进行resiter。
Note:In Oracle Database Release 9i, you were required to manually create the triggers, indexes, grants, and constraints on the interim table, and there may still be situations where you want to or must do so. In such cases, any referential constraints involving the interim table (that is, the interim table is either a parent or a child table of the referential constraint) must be created disabled. When online redefinition completes, the referential constraint is automatically enabled. In addition, until the redefinition process is either completed or aborted, any trigger defined on the interim table does not execute.
---注释:在一些情况下,你需要使用手动创建依赖对象。在在线重定义完成之前,与中间表有关的任何约束都应置为disable状态,完成之后,将自动变为enabled状态。除此之外,在在线重定义完成之前,中间表上的触发器是无效状态。
7. (Optional) Performing Intermediate Synchronization
After the redefinition process has been started by calling START_REDEF_TABLE and before FINISH_REDEF_TABLE has been called, it is possible that a large number of DML statements have been executed on the original table. If you know that this is the case, it is recommended that you periodically synchronize the interim table with the original table. This is done by calling the SYNC_INTERIM_TABLE procedure. Calling this procedure reduces the time taken byFINISH_REDEF_TABLE to complete the redefinition process. There is no limit to the number of times that you can call SYNC_INTERIM_TABLE.
---(可选)执行中间数据的同步
如果在调用start_redef_table和finishi_redef_table期间,在原始表上进行了大量DML操作,建议执行此步骤,来使得下一步骤8的执行过程更加快一些。此步骤使用dbms_redefinition.sync_interim_table()过程来进行原始表与中间表间的数据同步。在start_redef_table和finishi_redef_table期间,此过程可以多次被执行
The small amount of time that the original table is locked during FINISH_REDEF_TABLE is independent of whether SYNC_INTERIM_TABLE has been called.
---当然,不论此步骤是否被执行,在下一步骤中原始表都将被独占模式锁定一小段时间
Execute the FINISH_REDEF_TABLE procedure to complete the redefinition of the table. During this procedure, the original table is locked in exclusive mode for a very short time, independent of the amount of data in the original table. However, FINISH_REDEF_TABLE will wait for all pending DML to commit before completing the redefinition.
---调用dbms_redefinition.finish_redef_table()过程来完成在线重定义。在这个期间,原始表将会被将加X锁,这个过程很短,其依赖于原始表中的数据量。但是,在 系统真正执行这个过程之前需要等待已有的dml操作完成commit
If you used rowids for the redefinition and your COMPATIBLE initialization parameter is set to 10.1 or lower, set to UNUSED the hidden column M_ROW$$ that is now in the redefined table.
If COMPATIBLE is 10.2 or higher, this hidden column is automatically set to UNUSED for you when redefinition completes.
---如果在前面的操作中,你使用了基于rowid的方法,并且数据库的版本为10.1或更低。你需要使用下面的语句对隐藏列m_row$$标记为不可用或者将该列删除。如果你的数据库版本为10.2以上,隐藏列会自动标记为不可用,便不需要进行此步操作
ALTER TABLEtable_nameSET UNUSED (M_ROW$$);
Alter table table_name drop unused columns;
下面给出一个在线重定义的范例:
Hr.admin_emp表中有empno,ename,job,deptno四列,对此表按如下要求进行在线重定义操作:
l 表中添加新的列mgr,hiredate,sal,bonus
l 新列bonus的初始值为0,
l Deptno列在原有的基础上加10
l 重定义后