oracle体系结构(五)

When Extents Are Deallocated
The Oracle Database provides a Segment Advisor that helps you determine whether an object has space available for reclamation based on the level of space fragmentation within the object.
Oracle 数据库提供了 Segment Advisor 工具,她依据对象存储空间中的碎片程度来判断此对象中是否包含可回收的空间。

In general, the extents of a segment do not return to the tablespace until you drop the schema object whose data is stored in the segment (using a DROP TABLE or DROP CLUSTER statement). Exceptions to this include the following:
■ The owner of a table or cluster, or a user with the DELETE ANY privilege, can truncate the table or cluster with a  TRUNCATE ... DROP  STORAGE statement.
■ A database administrator (DBA) can deallocate unused extents using the following SQL syntax:

ALTER TABLE table_name DEALLOCATE UNUSED;
 
■ Periodically, Oracle deallocates one or more extents of a rollback segment if it has the  OPTIMAL size specified.

一般来说,如果段中存储了数据,那么直到用户drop掉这个方案对象(使用drop table语句或者drop cluster 语句)之前,此段中区的空间是不会返回给表空间的。但是也有特殊情况,如下面所示:
■表,簇表的所有者(owner)或拥有 DELETE ANY 权限的用户, 可以使用 TRUNCATE...DROP STORAGE 语句将表,簇表的数据清除
■数据库管理员(DBA)可以通过以下语句解除已分配的未被使用的区空间:
ALTER TABLE table_name DEALLOCATE UNUSED;
■如果用户为回滚段(rollback segment)设定了 OPTIMAL 参数,Oracle将周期性地从其中回收区空间。

When extents are freed, Oracle modifies the bitmap in the datafile (for locally managed tablespaces) or updates the data dictionary (for dictionary managed tablespaces) to reflect the regained extents as available space. Any data in the blocks of freed extents becomes inaccessible.
当区被释放后,oracle会通过修改数据文件中的位图(针对本地管理表空间)或者更新数据字典(针对字典管理表空间)来将回收的区作为可以利用的空间。被释放的区中的数据无法继续访问。

Extents in Nonclustered Tables 非簇表中的区
As long as a nonclustered table exists or until you truncate the table, any data block allocated to its data segment remains allocated for the table. Oracle inserts new rows into a block if there is enough room. Even if you delete all rows of a table, Oracle does not reclaim the data blocks for use by other objects in the tablespace.
只要用户没有移除或清除(truncate)一个非簇表中的数据,那么表中已分配的数据段中的任何已被分配的数据块都不会被回收。Oracle在空间足够的情况下会在插入数据的时候使用这些数据块。即使用户删掉了table中的所有行,Oracle也不会回收此表的数据块供表空间内的其他方案对象(schema object)使用。

After you drop a nonclustered table, this space can be reclaimed when other extents require free space. Oracle reclaims all the extents of the table’s data and index segments for the tablespaces that they were in and makes the extents available for other schema objects in the same tablespace.
用户drop掉一个非簇表后,当其他区需要更多空间的时候这个空间就会被回收。Oracle将此表对应的数据段、索引段中包含的区全部收回,并供存储于此表空间的其他方案对象使用。
In dictionary managed tablespaces, when a segment requires an extent larger than the available extents, Oracle identifies and combines contiguous reclaimed extents to form a larger one. This is called coalescing extents. Coalescing extents is not necessary in locally managed tablespaces, because all contiguous free space is available for allocation to a new extent regardless of whether it was reclaimed from one or more extents.
对于数据字典管理的表空间(dictionary managed tablespace),当一个段(segment)需要的区(extent)比现有可用扩展的都大时,Oracle通过寻找、合并连续的被回收的区来形成更大的区。这个过程被称为区合并(coalescing)。本地管理的表空间(locally managed tablespace)没有必要进行区合并,因为所有连续空间都可以被用于分配新区,而无需关心所用空间是如何被回收的。

Extents in Clustered Tables 簇表中的区
Clustered tables store information in the data segment created for the cluster. Therefore, if you drop one table in a cluster, the data segment remains for the other tables in the cluster, and no extents are deallocated. You can also truncate clusters (except for hash clusters) to free extents.
簇表的数据存储在为整个簇分配的数据段中。因此,如果用户删除(drop)簇中的一个表,数据段会被保留下来用于簇中其他的表,并且不会释放区空间。用户当然也可以通过truncate一个簇(哈希簇除外)来释放(回收)区。

Extents in Materialized Views and Their Logs 物化视图及其日志的区
Oracle deallocates the extents of materialized views and materialized view logs in the same manner as for tables and clusters.
Oracle回收属于物化视图(materialized view)及其日志(materialized view log)的区的方式与表和簇相同。

Extents in Indexes 索引的区
All extents allocated to an index segment remain allocated as long as the index exists. When you drop the index or associated table or cluster, Oracle reclaims the extents for other uses within the tablespace.
只要索引存在,那么对应索引段的所有区都不会被回收。当用户移除(drop)索引或相关的表、簇表时,Oracle才将索引使用的区回收。

Extents in Temporary Segments 临时段的区
When Oracle completes the execution of a statement requiring a temporary segment, Oracle automatically drops the temporary segment and returns the extents allocated for that segment to the associated tablespace. A single sort allocates its own temporary segment in a temporary tablespace of the user issuing the statement and then returns the extents to the tablespaces.
当Oracle执行完一个 SQL 语句,且在执行过程中需要使用的临时段时,Oracle自动地移除(drop)临时段,并将属于此临时段的区空间还给临时段所在的表空间。当用户执行单一排序语句时,Oracle将在此用户的临时表空间中创建为这个排序服务的临时段,并在执行后将此临时段使用的区回收。

Multiple sorts, however, can use sort segments in temporary tablespaces designated exclusively for sorts. These sort segments are allocated only once for the instance, and they are not returned after the sort, but remain available for other multiple sorts.
但是对于多重排序,可能会使用临时表空间中专为排序而创建的排序段。在每个实例中只会分配一个排序段,在排序操作使用后也不会被回收,而是继续供以后的多重排序使用

A temporary segment in a temporary table contains data for multiple statements of a single transaction or session. Oracle drops the temporary segment at the end of the transaction or session, returning the extents allocated for that segment to the associated tablespace.
同一会话或同一事务的多个 SQL 语句,有可能共同使用一个临时表的临时段存储临时数据。在这种情况下,Oracle在会话或事务结束时才移除(drop)临时段,并为临时段所在表空间回收使用的区。

Extents in Rollback Segments 回滚段的区
Oracle periodically checks the rollback segments of the database to see if they have grown larger than their optimal size. If a rollback segment is larger than is optimal (that is, it has too many extents), then Oracle automatically deallocates one or more extents from the rollback segment.
Oracle周期性地检查数据库回滚段的容量是否超过了最优值(optimal size)。如果回滚段超过了这个最优值(即回滚段中的区过多),Oracle将自动地从回滚段回收一些区。 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值