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

2014-11-24 15:01:41 · 作者: · 浏览: 4
【redefined】在线重定义概览与详细使用
在线重定义
In any database system, it is occasionally necessary to modify the logical or physical structure of a table to:
Improve the performance of queries or DML
Accommodate application changes
Manage storage
---在以下情况,常需要使用到在线重定义:
l 希望提高查询或dml语句的执行效率
l 适应应用的改变
l 对表的存储属性进行管理
Oracle Database provides a mechanism to make table structure modifications without significantly affecting the availability of the table. The mechanism is called online table redefinition. Redefining tables online provides a substantial increase in availability compared to traditional methods of redefining tables.
---oracle 数据库提供了在线重定义的方法,使得在不影响表的使用的前提下对表的结构进行修改。与传统的修改方法相比,这种方法增加了可用性
When a table is redefined online, it is accessible to both queries and DML during much of the redefinition process. The table is locked in the exclusive mode only during a very small window that is independent of the size of the table and complexity of the redefinition, and that is completely transparent to users.
---对一个表做在线重定义的大部分时间里,你可以继续对表进行查询和DML操作。期间,只有在非常小的一段时间内,需要进行锁表,这一小段时间的长短取决于表的大小和复杂度,但这小段时间对用户来讲是完全透明的
Online table redefinition requires an amount of free space that is approximately equivalent to the space used by the table being redefined. More space may be required if new columns are added.
---在线重定义的一个特点是,需要和原表大小差不多的额外空间来完成这个操作。当然,如果你在新定义的表中添加了一些新列,那么就需要更多的空间
Online table redefinition enables you to:
Modify the storage parameters of a table or cluster
Move a table or cluster to a different tablespace in the same schema
Add, modify, or drop one or more columns in a table or cluster
Add or drop partitioning support (non-clustered tables only)
Change partition structure
Change physical properties of a single table partition, including moving it to a different tablespace in the same schema
Change physical properties of a materialized view log or an Oracle Streams Advanced Queueing queue table
Add support for parallel queries
Re-create a table or cluster to reduce fragmentation
Change the organization of a normal table (heap organized) to an index-organized table, or do the reverse.
Convert a relational table into a table with object columns, or do the reverse.
Convert an object table into a relational table or a table with object columns, or do the reverse.
---利用在线重定义,你可以做以下事情:
l 修改表的存储属性
l 将表移动到另一个表空间,但其schema不变
l 添加、修改、删除表中的某个字段
l 对表添加或删除一个分区(聚簇表不支持)
l 改变分区的结构
l 对分区表中单独的一个区进行物理属性的修改,其中就包括将单独的一个区移到其它表空间下
l 增加并行查询选项
l 重建表来减少碎片
l 将普通表转换成索引组织表,或者将索引组织表转换成普通表(堆表)
l 关系表和对象表间的转换
Performing Online Redefinition with DBMS_REDEFINITION
---下面将使用dbms_redefinition包进行在线重定义的过程操作:
Choose the redefinition method: by key or by rowed
---在线重定义有两种方法:基于主键或基于rowid
By key—Select a primary key or pseudo-primary key to use for the redefinition. Pseudo-primary keys are unique keys with all component columns having NOT NULL constraints. For this method, the versions of the tables before and after redefinition should have the same primary key columns. This is the preferred and default method of redefinition.
---基于主键:使用主键或伪主键,所谓伪主键就是指有unique、not null约束列的组合。使用这种方法,需要重定义前后的表中有相同的主键列。这是默认的重定义方法
By rowid—Use this method if no key is available. In this method, a hidden column named M_ROW$$ is added to the post-redefined version of the table. It is recommended that this colum