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

2014-11-24 15:01:41 · 作者: · 浏览: 3
n be dropped or marked as unused after the redefinition is complete. You cannot use this method on index-organized tables.
---基于rowid:这种方法就不需要使用主键列。使用这种方法后,新定义的表中将会有一个隐藏列m_row$$。Oracle建议你将这列删除或标记为不可用。这种方法的一个限制是不能在索引组织表中使用。
Verify that the table can be redefined online by invoking the CAN_REDEF_TABLE procedure. If the table is not a candidate for online redefinition, then this procedure raises an error indicating why the table cannot be redefined online.
---在在线重定义开始前,使用can_redef_table包进行验证,确认是否能对表进行在线重定义操作,如果不能,将会返回报错表明原因。
Create an empty interim table (in the same schema as the table to be redefined) with all of the desired logical and physical attributes. If columns are to be dropped, do not include them in the definition of the interim table. If a column is to be added, then add the column definition to the interim table. If a column is to be modified, create it in the interim table with the properties that you want.
---然后在同一个用户下创建一个中间表,你可以按照你所希望的表的结构进行创建,并不需要和原表相同,你可以添加新列,删除旧列,改变原有列的属性。
It is not necessary to create the interim table with all the indexes, constraints, grants, and triggers of the table being redefined, because these will be defined in step 6 when you copy dependent objects.
---这一步中,我们可以先不在中间表上创建那些应有的索引、约束和触发器。我们可以第6步中使用另一个包来完成这些操作
(Optional)If you are redefining a large table and want to improve the performance of the next step by running it in parallel, issue the following statements:
---(可选)如果你对一个很大的表进行了在线重定义操作,你可以使用下面语句来设置并行操作来加快在线重定义的的过程
alter session force parallel dml paralleldegree-of-parallelism;
alter session force parallel query paralleldegree-of-parallelism;
Start the redefinition process by calling START_REDEF_TABLE。
Because this process involves copying data, it may take a while. The table being redefined remains available for queries and DML during the entire process.
---调用dbms_redefinition.start_redef_table()过程,这个过程提供如下参数:被重定义的表的名称,中间表的名称,列的映射规则,重定义方法。如果没有给出列的映射规则,则认为所有包括在中间表中的列用于表的重定义。如果给出了映射规则,则按照映射规则。
因为在此过程中需要进行原始表和中间表间的数据拷贝,所以可能需要较长的时间。但此阶段不会对查询和dml操作产生影响
Note:If START_REDEF_TABLE fails for any reason, you must call ABORT_REDEF_TABLE, otherwise subsequent attempts to redefine the table will fail.
---注释:如果调用dbms_redefinition.start_redefinition_table ()过程失败,不论任何原因,必须调用一次dbms_redefinition.abort_redef_table(),否则后续的操作可能会继续失败
Copy dependent objects (such as triggers, indexes, grants, and constraints) and statistics from the table being redefined to the interim table, using one of the following two methods. Method 1 is the preferred method because it is more automatic, but there may be times that you would choose to use method 2. Method 1 also enables you to copy table statistics to the interim table.
---拷贝原始表上的依赖对象(触发器、索引、约束、授权)到中间表上。你可以通过如下两种方法,其中方法1更自动化一些,因为更好一些。方法2是手工方法,但也有些时候更适合使用方法2.
Method 1: Automatically Creating Dependent Objects
Use the COPY_TABLE_DEPENDENTS procedure to automatically create dependent objects on the interim table. This procedure also registers the dependent objects. Registering the dependent objects enables the identities of these objects and their copied counterparts to be automatically swapped later as part of the redefinition completion process. The result is that when the redefinition is completed, the names of the dependent objects will be the same as the names of the original dependent objects.
---调用dbms_redefinitio