联机重定义功能是通过物化视图来实现的。在调用START_REDEF_TABLE存储过程时,会自动创建与临时表名称相同的物化视图,并将源表的记录拷贝到临时表,此时源表可以DML和查询,不可DDL。
在联机重定义阶段源表产生的DML修改记录,将会被记录到物化视图日志中。在SYNC_INTERIM_TABLE和最后的FINISH_REDEF_TABLE过程,都会根据物化视图日志中的记录更新临时表。
调用ABORT_REDEF_TABLE存储过程后,建立的物化视图被清除。如果临时表上已经有拷贝的数据,那么在ABORT后,临时表上的数据并未被清除,应手工清除临时表上的数据。
Table redefinition is started by the DBA creating an interim table based on the original table. The interim table can have a different structure than the original table, and will eventually take the original table's place in the database. While the table is redefined, DML operations on the original table are captured in a Materialized View Log table (MLOG$_%). These changes are eventually transformed and merged into the interim table. When done, the names of the original and the interim tables are swapped in the data dictionary. At this point all users will be working on the new table and the old table can be dropped.