Oracle 表空間管理(tablespace managment)
<span style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;"><b style="background-color:inherit;"><span style="background-color:inherit;font-size:medium;">一. 官網說明</span></b></span><br style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;" />
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<p style="background-color:inherit;">
<span style="background-color:inherit;"><b style="background-color:inherit;"><span style="background-color:inherit;"><span style="background-color:inherit;">Logical Storage Structures</span></span><span style="background-color:inherit;"> </span></b></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;"><span style="background-color:inherit;">其中有關ASSM 的內容如下:</span></span>
</p>
</div>
<div style="white-space:normal;widows:auto;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;line-height:1.8;background-color:#F5F5F5;">
<p style="background-color:inherit;">
<span style="background-color:inherit;font-family:宋體;font-size:12pt;line-height:1.8;"><span style="line-height:1.8;background-color:inherit;"></span></span>
</p>
<h4 style="font-size:16px;background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:medium;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">Logical Space Management</span></span></span>
</h4>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">Oracle Database must use<span style="background-color:inherit;"> </span><strong style="background-color:inherit;">logical space management</strong><span style="background-color:inherit;"> </span>to track and allocate the extents in a tablespace. When a database object requires an extent, the database must have a method of finding and providing it. Similarly, when an object no longer requires an extent, the database must have a method of making the free extent available.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">Oracle Databa</span><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">se manages space within a tablespace based on the type that you create. You can create either of the following types of tablespaces:</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="background-color:inherit;color:red;font-family:Symbol;font-size:10pt;line-height:1.8;">·<span style="font-family:'Times New Roman';font-size:7pt;background-color:inherit;"> <span style="background-color:inherit;"> </span></span></span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;font-size:small;line-height:1.8;">Locally managed tablespaces (default)</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;">The database uses bitmaps in the tablespaces themselves to manage extents. Thus, locally managed tablespaces have a part of the tablespace set aside for a bitmap. Within a tablespace, the database can manage segments with<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><strong style="background-color:inherit;">automatic segment space management (ASSM)</strong></span><span style="background-color:inherit;"> </span><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;">or<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><strong style="background-color:inherit;">manual segment space management (MSSM)</strong></span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;">.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="font-family:Symbol;font-size:10pt;line-height:1.8;background-color:inherit;">·<span style="font-family:'Times New Roman';font-size:7pt;background-color:inherit;"> <span style="background-color:inherit;"> </span></span></span><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;">Dictionary-managed tablespaces</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">The database uses the<span style="background-color:inherit;"> </span></span><a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/glossary.htm#CHDJJJGD" style="background-color:inherit;cursor:pointer;color:navy;"><span style="background-color:inherit;color:#003399;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">data dictionary</span></span></a><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;"><span style="background-color:inherit;"> </span>to manage extents (see<span style="background-color:inherit;"> </span></span><a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/datadict.htm#i1012" style="background-color:inherit;cursor:pointer;color:navy;"><span style="background-color:inherit;color:#0000FF;font-family:宋體;font-size:small;line-height:1.8;">"Overview of the Data Dictionary"</span></a><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">).</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/logical.htm#BABDJBGD" style="background-color:inherit;cursor:pointer;color:navy;"><span style="background-color:inherit;color:#0000FF;font-family:宋體;font-size:small;line-height:1.8;">Figure 12-3</span></a><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="background-color:inherit;"> </span>shows the alternatives for logical space management in a tablespace.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><strong style="background-color:inherit;"><em style="background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">Figure 12-3 Logical Space Management<br />
<img src="/attachment/201510/13/30208428_1444744363SAZY.gif" width="451" height="181" alt="" /></span></span></em></strong></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><img src="file://D:/%E6%9C%89%E9%81%93%E4%BA%91%E7%AC%94%E8%AE%B0/%E6%95%B0%E6%8D%AE%E7%9B%AE%E5%BD%95/zr2095@163.com/057aa1fe78c244fe87181267ee85c38f/04934118i922.gif" data-media-type="image" data-attr-org-src-id="33B54179DE834BEEA5EEE4A0C3ED479C" data-attr-org-img-file="file:///D:/%E6%9C%89%E9%81%93%E4%BA%91%E7%AC%94%E8%AE%B0/%E6%95%B0%E6%8D%AE%E7%9B%AE%E5%BD%95/zr2095@163.com/057aa1fe78c244fe87181267ee85c38f/04934118i922.gif" style="background-color:inherit;cursor:default;display:inline-block;margin-top:8px;max-width:800px;" /><br style="background-color:inherit;" />
<a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/img_text/cncpt268.htm" style="background-color:inherit;cursor:pointer;color:navy;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;color:#0000FF;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">Description of "Figure 12-3 Logical Space Management"</span></span></span></a></span>
</p>
<h5 style="background-color:inherit;font-size:14px;">
<span style="background-color:inherit;font-family:Tahoma, sans-serif;font-size:14pt;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">Locally Managed Tablespaces</span></span>
</h5>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;">A locally managed tablespace<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;">maintains a bitmap in the data file header to track free and used space in the data file body</span><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;">. Each bit corresponds to a group of blocks. When space is allocated or freed, Oracle Database changes the bitmap values to reflect the new status of the blocks.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">The following graphic is a conceptual representation of bitmap-managed storage. A<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">1</span></code><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;"><span style="background-color:inherit;"> </span>in the header refers to used space, whereas a<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">0</span></code><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="background-color:inherit;"> </span>refers to free space.<br />
<img src="/attachment/201510/13/30208428_1444744504B8TM.gif" width="633" height="332" alt="" /></span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><img src="file://D:/%E6%9C%89%E9%81%93%E4%BA%91%E7%AC%94%E8%AE%B0/%E6%95%B0%E6%8D%AE%E7%9B%AE%E5%BD%95/zr2095@163.com/8ee0499171524680ad495f8edfa56674/049341258bpp.gif" data-media-type="image" data-attr-org-src-id="D0BFE5097E49426DB272DC1F2FE07435" data-attr-org-img-file="file:///D:/%E6%9C%89%E9%81%93%E4%BA%91%E7%AC%94%E8%AE%B0/%E6%95%B0%E6%8D%AE%E7%9B%AE%E5%BD%95/zr2095@163.com/8ee0499171524680ad495f8edfa56674/049341258bpp.gif" style="background-color:inherit;cursor:default;display:inline-block;margin-top:8px;max-width:800px;" /></span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">A locally managed tablespace has the following advantages:</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="font-family:Symbol;font-size:10pt;line-height:1.8;background-color:inherit;">·<span style="font-family:'Times New Roman';font-size:7pt;background-color:inherit;"> <span style="background-color:inherit;"> </span></span></span><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;">Avoids using the data dictionary to manage extents</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">Recursive operations can occur in dictionary-managed tablespaces if consuming or releasing space in an extent results in another operation that consumes or releases space in a data dictionary table or undo segment.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="font-family:Symbol;font-size:10pt;line-height:1.8;background-color:inherit;">·<span style="font-family:'Times New Roman';font-size:7pt;background-color:inherit;"> <span style="background-color:inherit;"> </span></span></span><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;">Tracks adjacent free space automatically</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">In this way, the database eliminates the need to coalesce free extents.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="font-family:Symbol;font-size:10pt;line-height:1.8;background-color:inherit;">·<span style="font-family:'Times New Roman';font-size:7pt;background-color:inherit;"> <span style="background-color:inherit;"> </span></span></span><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;">Determines the size of locally managed extents automatically</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">Alternatively, all extents can have the same size in a locally managed tablespace and override object storage options.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><strong style="background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">Note:</span></span></strong></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">Oracle strongly recommends the use of locally managed tablespaces with Automatic Segment Space Management.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><strong style="background-color:inherit;">Segment space management</strong></span><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;"> </span>is an attribute inherited from the tablespace that contains the segment. Within a locally managed tablespace, the database can manage segments automatically or manually. For example, segments in tablespace<span style="background-color:inherit;"> </span></span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">users</span></code><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;"><span style="background-color:inherit;"> </span>can be managed automatically while segments in tablespace<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">tools</span></code><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="background-color:inherit;"> </span>are managed manually.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="color:#000000;font-size:15pt;line-height:1.8;"><span style="font-family:宋體;line-height:1.8;color:#000000;"><strong>Automatic Segment Space Management</strong></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">The ASSM method uses bitmaps to manage space. Bitmaps provide the following advantages:</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="background-color:inherit;color:red;font-family:Symbol;font-size:10pt;line-height:1.8;">·<span style="font-family:'Times New Roman';font-size:7pt;background-color:inherit;"> <span style="background-color:inherit;"> </span></span></span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;font-size:small;line-height:1.8;">Simplified administration</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;">ASSM avoids the need to manually determine correct settings for many storage parameters.<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;">Only one crucial SQL parameter controls space allocation:<span style="background-color:inherit;"> </span></span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="background-color:inherit;color:red;font-size:13pt;line-height:1.8;">PCTFREE</span></code><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;">.<span style="background-color:inherit;"> </span></span><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;">This parameter specifies the percentage of space to be reserved in a block for future updates (see<span style="background-color:inherit;"> </span><a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/logical.htm#BABBAJHC" style="background-color:inherit;cursor:pointer;color:navy;"><span style="background-color:inherit;color:#0000FF;line-height:1.8;">"Percentage of Free Space in Data Blocks"</span></a>).</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;">ASSM<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;color:red;line-height:1.8;">管理,只需要一個參數:</span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;">PCTFREE</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="background-color:inherit;color:red;font-family:Symbol;font-size:10pt;line-height:1.8;">·<span style="font-family:'Times New Roman';font-size:7pt;background-color:inherit;"> <span style="background-color:inherit;"> </span></span></span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;font-size:small;line-height:1.8;">Increased concurrency</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">Multiple<span style="background-color:inherit;"> </span></span><a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/glossary.htm#CHDJEBHA" style="background-color:inherit;cursor:pointer;color:navy;"><span style="background-color:inherit;color:#003399;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">transactions</span></span></a><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="background-color:inherit;"> </span>can search separate lists of free data blocks, thereby reducing contention and waits. For many standard workloads, application performance with ASSM is better than the performance of a well-tuned application that uses MSSM.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="font-family:Symbol;font-size:10pt;line-height:1.8;background-color:inherit;">·<span style="font-family:'Times New Roman';font-size:7pt;background-color:inherit;"> <span style="background-color:inherit;"> </span></span></span><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;">Dynamic affinity of space to instances in an Oracle Real Application Clusters (Oracle RAC) environment</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">ASSM is more efficient and is the default for permanent, locally managed tablespaces.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><strong style="background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">Note:</span></span></strong></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">This chapter assumes the use of ASSM in all of its discussions of logical storage space.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"> </span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-size:15pt;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><b style="background-color:inherit;">Manual Segment Space Management</b></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;">The legacy MSSM method<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;">uses a linked list called a<span style="background-color:inherit;"> </span><strong style="background-color:inherit;">free list</strong><span style="background-color:inherit;"> </span>to manage free space in the segment</span><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;">. For a database object that has free space, a free list keeps track of blocks under the<span style="background-color:inherit;"> </span><a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/glossary.htm#CHDIJHII" style="background-color:inherit;cursor:pointer;color:navy;"><span style="background-color:inherit;color:#003399;line-height:1.8;">high water mark</span></a><span style="background-color:inherit;"> </span>(HWM), which is the dividing line between segment space that is used and not yet used. As blocks are used, the database puts blocks on or removes blocks from the free list as needed.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">In addition to<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="background-color:inherit;color:red;font-size:13pt;line-height:1.8;">PCTFREE</span></code><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">, MSSM requires you to control space allocation with SQL parameters such as<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="background-color:inherit;color:red;font-size:13pt;line-height:1.8;">PCTUSED</span></code><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">,<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="background-color:inherit;color:red;font-size:13pt;line-height:1.8;">FREELISTS</span></code><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">, and<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="background-color:inherit;color:red;font-size:13pt;line-height:1.8;">FREELIST GROUPS</span></code><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">.</span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">PCTUSED</span></code><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;"><span style="background-color:inherit;"> </span>sets the percentage of free space that must exist in a currently used block for the database to put it on the free list. For example, if you set</span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">PCTUSED</span></code><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;"><span style="background-color:inherit;"> </span>to<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">40</span></code><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;"><span style="background-color:inherit;"> </span>in a<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">CREATE TABLE</span></code><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="background-color:inherit;"> </span>statement, then you cannot insert rows into a block in the segment until less than 40% of the block space is used.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">As an illustration, suppose you insert a row into a table. The database checks a free list of the table for the first available block. If the row cannot fit in the block, and if the used space in the block is greater than or equal to<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">PCTUSED</span></code><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">, then the database takes the block off the list and searches for another block. If you delete rows from the block, then the database checks whether used space in the block is now less than<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">PCTUSED</span></code><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">. If so, then the database places the block at the beginning of the free list.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">An object may have multiple free lists. In this way, multiple sessions performing DML on a table can use different lists, which can reduce contention. Each database session uses only one free list for the duration of its session.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">As shown in<span style="background-color:inherit;"> </span></span><a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/logical.htm#BABJABGH" style="background-color:inherit;cursor:pointer;color:navy;"><span style="background-color:inherit;color:#0000FF;font-family:宋體;font-size:small;line-height:1.8;">Figure 12-4</span></a><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">, you can also create an object with one or more<span style="background-color:inherit;"> </span><strong style="background-color:inherit;">free list groups</strong>, which are collections of free lists. Each group has a<span style="background-color:inherit;"> </span><strong style="background-color:inherit;">master free list</strong><span style="background-color:inherit;"> </span>that manages the individual<span style="background-color:inherit;"> </span><strong style="background-color:inherit;">process free lists</strong><span style="background-color:inherit;"> </span>in the group. Space overhead for free lists, especially for free list groups, can be significant.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><strong style="background-color:inherit;"><em style="background-color:inherit;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">Figure 12-4 Free List Groups<br />
<img src="/attachment/201510/13/30208428_1444744426N32P.gif" width="323" height="275" alt="" /><br />
</span></span></em></strong></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><img src="file://D:/%E6%9C%89%E9%81%93%E4%BA%91%E7%AC%94%E8%AE%B0/%E6%95%B0%E6%8D%AE%E7%9B%AE%E5%BD%95/zr2095@163.com/5534672ca11440319f1ff7c414e940dd/04934130k9ex.gif" data-media-type="image" data-attr-org-src-id="C05DADD0BEBD4277841C477F77662550" data-attr-org-img-file="file:///D:/%E6%9C%89%E9%81%93%E4%BA%91%E7%AC%94%E8%AE%B0/%E6%95%B0%E6%8D%AE%E7%9B%AE%E5%BD%95/zr2095@163.com/5534672ca11440319f1ff7c414e940dd/04934130k9ex.gif" style="background-color:inherit;cursor:default;display:inline-block;margin-top:8px;max-width:800px;" /><br style="background-color:inherit;" />
<a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/img_text/cncpt320.htm" style="background-color:inherit;cursor:pointer;color:navy;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;color:#0000FF;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">Description of "Figure 12-4 Free List Groups"</span></span></span></a></span>
</p>
<p style="background-color:inherit;">
<span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">Managing segment space manually can be complex. You must adjust<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">PCTFREE</span></code><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;"><span style="background-color:inherit;"> </span>and<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">PCTUSED</span></code><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;"><span style="background-color:inherit;"> </span>to reduce row migration (see<span style="background-color:inherit;"> </span></span><a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/logical.htm#BABEEAAE" style="background-color:inherit;cursor:pointer;color:navy;"><span style="background-color:inherit;color:#0000FF;font-family:宋體;font-size:small;line-height:1.8;">"Chained and Migrated Rows"</span></a><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;">) and avoid wasting space. For example, if every used block in a segment is half full, and if<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="font-size:13pt;line-height:1.8;background-color:inherit;">PCTUSED</span></code><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;"> </span>is 40, then the database does not permit inserts into any of these blocks. Because of the difficulty of fine-tuning space allocation parameters, Oracle strongly recommends ASSM.<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;">In ASSM,<span style="background-color:inherit;"> </span></span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="background-color:inherit;color:red;font-size:13pt;line-height:1.8;">PCTFREE</span></code><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;font-size:small;line-height:1.8;"><span style="background-color:inherit;"> </span>determines whether a new row can be inserted into a block, but it does not use free lists and ignores<span style="background-color:inherit;"> </span></span></span><code style="font-family:Monaco, Consolas, Courier, 'Lucida Console', monospace;background-color:inherit;"><span style="background-color:inherit;color:red;font-size:13pt;line-height:1.8;">PCTUSED</span></code><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;">.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;">-- ASSM<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;color:red;line-height:1.8;">會忽略</span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;">PCTUSED<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;color:red;line-height:1.8;">參數</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-size:16pt;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><b style="background-color:inherit;">Dictionary-Managed Tablespaces</b></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;">A dictionary-managed tablespace uses the data dictionary to manage its extents.<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;">Oracle Database updates tables in the data dictionary whenever an extent is allocated or freed for reuse.</span><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;"> </span>For example, when a table needs an extent, the database queries the data dictionary tables, and searches for free extents. If the database finds space, then it modifies one data dictionary table and inserts a row into another. In this way, the database manages space by modifying and moving data.</span></span></span>
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-size:small;line-height:1.8;"><span style="background-color:inherit;font-family:宋體;line-height:1.8;"><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;">The SQL that the database executes in the background to obtain space for database objects is<span style="background-color:inherit;"> </span><strong style="background-color:inherit;">recursive SQL</strong>.</span><span style="background-color:inherit;color:red;font-family:Tahoma, sans-serif;line-height:1.8;"><span style="background-color:inherit;"> </span>Frequent use of recursive SQL can have a negative impact on performance because updates to the data dictionary must be serialized.</span><span style="font-family:Tahoma, sans-serif;line-height:1.8;background-color:inherit;"><span style="background-color:inherit;"> </span>Locally managed tablespaces, which are the default, avoid this performance problem.</span></span></span>
</p>
<p style="background-color:inherit;">
<br />
</p>
<p style="background-color:inherit;">
<span style="background-color:inherit;font-family:宋體;line-height:1.8;"><b style="background-color:inherit;"><span style="font-size:14pt;line-height:1.8;background-color:inherit;"></span></b></span>
</p>
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<p style="background-color:inherit;">
<span style="background-color:inherit;"><span style="background-color:inherit;"><span style="background-color:inherit;font-size:medium;"><b style="background-color:inherit;"><span style="background-color:inherit;">二</span><span style="background-color:inherit;">. ASSM<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;">說明</span></b></span></span></span>
</p>
</div>
<p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<span style="background-color:inherit;"><span style="background-color:inherit;"> 在</span><span style="background-color:inherit;">Orale 9i</span><span style="background-color:inherit;">以前,表的剩余空間的管理與分配都是由鏈接列表</span><span style="background-color:inherit;">freelist</span><span style="background-color:inherit;">來完成的,因為</span><span style="background-color:inherit;">freelist</span><span style="background-color:inherit;">存在串行的問題因此容易引起往往容易引起段頭的爭用與空間的浪費(其實這一點并不明顯),最主要的還是因為需要</span><span style="background-color:inherit;">DBA<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;">花費大量的精力去管理這些爭用并監控表的空間利用。</span></span><span style="background-color:inherit;"><span style="background-color:inherit;"> <br style="background-color:inherit;" />
</span></span><span style="background-color:inherit;line-height:1.5;"> 自動段空間管理(</span><span style="background-color:inherit;line-height:1.5;">ASSM</span><span style="background-color:inherit;line-height:1.5;">),它首次出現在</span><span style="background-color:inherit;line-height:1.5;">Oracle 920</span><span style="background-color:inherit;line-height:1.5;">里。有了</span><span style="background-color:inherit;line-height:1.5;">ASSM</span><span style="background-color:inherit;line-height:1.5;">,鏈接列表</span><span style="background-color:inherit;line-height:1.5;">freelist</span><span style="background-color:inherit;line-height:1.5;">被</span><span style="background-color:inherit;line-height:1.5;">位圖</span><span style="background-color:inherit;line-height:1.5;">所取代,</span><span style="background-color:inherit;line-height:1.5;">它是一個二進制的數組</span><span style="background-color:inherit;line-height:1.5;">,能夠迅速有效地管理存儲擴展和剩余區塊(</span><span style="background-color:inherit;line-height:1.5;">free block</span><span style="background-color:inherit;line-height:1.5;">),因此能夠改善分段存儲本質,</span><span style="background-color:inherit;line-height:1.5;">ASSM</span><span style="background-color:inherit;line-height:1.5;">表空間上創建的段還有另外一個稱呼叫</span><span style="background-color:inherit;line-height:1.5;">Bitmap Managed Segments</span><span style="background-color:inherit;line-height:1.5;">(</span><span style="background-color:inherit;line-height:1.5;">BMB </span><span style="background-color:inherit;line-height:1.5;">段)。</span><span style="background-color:inherit;line-height:1.5;"> </span>
</p>
<p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<span style="background-color:inherit;"><br style="background-color:inherit;" />
</span><span style="background-color:inherit;"><span style="background-color:inherit;">讓我們看看位圖</span><span style="background-color:inherit;">freelist</span><span style="background-color:inherit;">是如何實現的。從使用區段空間管理自動參數創建</span><span style="background-color:inherit;">tablespace</span><span style="background-color:inherit;">開始:</span></span><span style="background-color:inherit;"><span style="background-color:inherit;"> <br style="background-color:inherit;" />
create tablespace demo <br style="background-color:inherit;" />
datafile '/ora01/oem/demo01.dbf ' <br style="background-color:inherit;" />
size 5m <br style="background-color:inherit;" />
EXTENT MANAGEMENT LOCAL -- Turn on LMT <br style="background-color:inherit;" />
SEGMENT SPACE MANAGEMENT AUTO -- Turn on ASSM; <br style="background-color:inherit;" />
<br style="background-color:inherit;" />
</span></span>
</p>
<p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<span style="background-color:inherit;"><span style="background-color:inherit;"> 一旦你定義好了</span><span style="background-color:inherit;">tablespace</span><span style="background-color:inherit;">,那么表和索引就能夠使用各種方法很容易地被移動到新的</span><span style="background-color:inherit;">tablespace</span><span style="background-color:inherit;">里,</span><span style="background-color:inherit;">帶有</span><span style="background-color:inherit;">ASSM</span><span style="background-color:inherit;">的本地管理</span><span style="background-color:inherit;">tablespace</span><span style="background-color:inherit;">會略掉任何為</span><span style="background-color:inherit;">PCTUSED</span><span style="background-color:inherit;">、</span><span style="background-color:inherit;">NEXT</span><span style="background-color:inherit;">和</span><span style="background-color:inherit;">FREELISTS</span><span style="background-color:inherit;">所指定的值</span><span style="background-color:inherit;">。</span><span style="background-color:inherit;"> </span></span>
</p>
<p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<span style="background-color:inherit;"><span style="background-color:inherit;"> 當表格或者索引被分配到這個</span><span style="background-color:inherit;">tablespace</span><span style="background-color:inherit;">以后,用于獨立對象的</span><span style="background-color:inherit;">PCTUSED</span><span style="background-color:inherit;">的值會被忽略,而</span><span style="background-color:inherit;">Oracle9i</span><span style="background-color:inherit;">會使用位圖數組來自動地管理</span><span style="background-color:inherit;">tablespace</span><span style="background-color:inherit;">里表格和索引的</span><span style="background-color:inherit;">freelist</span><span style="background-color:inherit;">。對于在</span><span style="background-color:inherit;">LMT</span><span style="background-color:inherit;">的</span><span style="background-color:inherit;">tablespace</span><span style="background-color:inherit;">內部創建的表格和索引而言,這個</span><span style="background-color:inherit;">NEXT</span><span style="background-color:inherit;">擴展子句是過時的</span><span style="background-color:inherit;">,因為由本地管理的</span><span style="background-color:inherit;">tablespace</span><span style="background-color:inherit;">會管理它們。但是,</span><span style="background-color:inherit;">INITIAL</span><span style="background-color:inherit;">參數仍然是需要的</span><span style="background-color:inherit;">,因為</span><span style="background-color:inherit;">Oracle</span><span style="background-color:inherit;">不可能提前知道初始表格加載的大小</span><span style="background-color:inherit;">。對于</span><span style="background-color:inherit;">ASSM</span><span style="background-color:inherit;">而言,</span><span style="background-color:inherit;">INITIAL</span><span style="background-color:inherit;">最小的值是三個塊</span><span style="background-color:inherit;">。</span><span style="background-color:inherit;"> </span></span>
</p>
<p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<span style="background-color:inherit;"><br style="background-color:inherit;" />
</span><span style="background-color:inherit;"><span style="background-color:inherit;"> 新的管理機制用位圖來跟蹤或管理每個分配到對象的塊,每個塊有多少剩余空間根據位圖的狀態來確定,如</span><span style="background-color:inherit;">>75%,50%-75%,25%-50%</span><span style="background-color:inherit;">和</span><span style="background-color:inherit;"><25%</span><span style="background-color:inherit;">,也就是說</span><span style="background-color:inherit;">位圖其實采用了四個狀態位來代替以前的</span><span style="background-color:inherit;">pctused</span><span style="background-color:inherit;">,什么時候該利用該數據塊則由設定的</span><span style="background-color:inherit;">pctfree</span><span style="background-color:inherit;">來確定。</span><span style="background-color:inherit;"> </span></span>
</p>
<p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<span style="background-color:inherit;"><br style="background-color:inherit;" />
</span><span style="background-color:inherit;"><span style="background-color:inherit;"> 使用</span><span style="background-color:inherit;">ASSM</span><span style="background-color:inherit;">的一個</span><span style="background-color:inherit;"><span style="background-color:inherit;">巨大優勢</span></span><span style="background-color:inherit;">是,</span><span style="background-color:inherit;">位圖</span><span style="background-color:inherit;">freelist</span><span style="background-color:inherit;">肯定能夠減輕緩沖區忙等待</span><span style="background-color:inherit;">(</span><span style="background-color:inherit;">buffer busy wait</span><span style="background-color:inherit;">)的負擔,這個問題在</span><span style="background-color:inherit;">Oracle9i</span><span style="background-color:inherit;">以前的版本里曾是一個嚴重的問題</span> <span style="background-color:inherit;">。</span> </span>
</p>
<p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<span style="background-color:inherit;"><br style="background-color:inherit;" />
</span><span style="background-color:inherit;"><span style="background-color:inherit;"> 在沒有多個</span><span style="background-color:inherit;">freelist</span><span style="background-color:inherit;">的時候</span><span style="background-color:inherit;">,每個</span><span style="background-color:inherit;">Oracle</span><span style="background-color:inherit;">表格和索引在表格的頭部都曾有一個數據塊,用來管理對象所使用的剩余區塊,并為任何</span><span style="background-color:inherit;">SQL</span><span style="background-color:inherit;">插入聲明所創建的新數據行提供數據塊。當數據緩沖內的數據塊由于被另一個</span><span style="background-color:inherit;">DML</span><span style="background-color:inherit;">事務處理鎖定而無法使用的時候,緩沖區忙等待就會發生。當你需要將多個任務插入到同一個表格里的時候,這些任務就被強制等待,而同時</span><span style="background-color:inherit;">Oracle</span><span style="background-color:inherit;">會在同時分派剩余的區塊,一次一個。</span><span style="background-color:inherit;"> </span></span>
</p>
<p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<span style="background-color:inherit;"><br style="background-color:inherit;" />
</span><span style="background-color:inherit;"><span style="background-color:inherit;"> 有了</span><span style="background-color:inherit;">ASSM</span><span style="background-color:inherit;">之后,</span><span style="background-color:inherit;">Oracle</span><span style="background-color:inherit;">宣稱<span style="background-color:inherit;">顯著</span>地提高了</span><span style="background-color:inherit;">DML</span><span style="background-color:inherit;">并發操作的性能</span><span style="background-color:inherit;">,</span><span style="background-color:inherit;">因為</span><span style="background-color:inherit;">(同一個)位圖的不同部分可以被同時使用,這樣就消除了尋找剩余空間的串行化。根據</span><span style="background-color:inherit;">Oracle</span><span style="background-color:inherit;">的測試結果,使用位圖</span><span style="background-color:inherit;">freelist</span><span style="background-color:inherit;">會消除所有分段頭部(對資源)的爭奪,還能獲得超快的并發插入操作</span> </span>
</p>
<p style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<span style="background-color:inherit;"><br style="background-color:inherit;" />
</span><span style="background-color:inherit;"><span style="background-color:inherit;"> 盡管</span><span style="background-color:inherit;">ASSM</span><span style="background-color:inherit;">顯示出了令人激動的特性并能夠簡化</span><span style="background-color:inherit;">Oracle DBA</span><span style="background-color:inherit;">的工作,但是</span><span style="background-color:inherit;">Oracle9i</span><span style="background-color:inherit;">的位圖分段管理還是有一些局限性</span><span style="background-color:inherit;">的:</span></span><span style="background-color:inherit;"><span style="background-color:inherit;"> <br style="background-color:inherit;" />
1.<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;">一旦</span><span style="background-color:inherit;">DBA</span><span style="background-color:inherit;">被分配之后,它就無法控制</span><span style="background-color:inherit;">tablespace</span><span style="background-color:inherit;">內部的獨立表格和索引的存儲行為。</span></span><span style="background-color:inherit;"><span style="background-color:inherit;"> <br style="background-color:inherit;" />
2.<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;">大型對象不能夠使用</span><span style="background-color:inherit;">ASSM</span><span style="background-color:inherit;">,而且必須為包含有</span><span style="background-color:inherit;">LOB</span><span style="background-color:inherit;">數據類型的表格創建分離的</span><span style="background-color:inherit;">tablespace</span><span style="background-color:inherit;">。</span></span><span style="background-color:inherit;"><span style="background-color:inherit;"> <br style="background-color:inherit;" />
3.<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;">你不能夠使用</span><span style="background-color:inherit;">ASSM</span><span style="background-color:inherit;">創建臨時的</span><span style="background-color:inherit;">tablespace</span><span style="background-color:inherit;">。這是由排序時臨時分段的短暫特性所決定的。</span></span><span style="background-color:inherit;"><span style="background-color:inherit;"> <br style="background-color:inherit;" />
4.<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;">只有本地管理的</span><span style="background-color:inherit;">tablespace</span><span style="background-color:inherit;">才能夠使用位圖分段管理。</span></span><span style="background-color:inherit;"><span style="background-color:inherit;"> <br style="background-color:inherit;" />
5·<span style="background-color:inherit;"> </span></span><span style="background-color:inherit;">使用超高容量的</span><span style="background-color:inherit;">DML</span><span style="background-color:inherit;">(例如</span><span style="background-color:inherit;">INSERT</span><span style="background-color:inherit;">、</span><span style="background-color:inherit;">UPDATE</span><span style="background-color:inherit;">和</span><span style="background-color:inherit;">DELETE</span><span style="background-color:inherit;">等)的時候可能會出現性能上的問題。</span></span>
</p>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<br style="background-color:inherit;" />
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<b style="background-color:inherit;"><span style="background-color:inherit;font-size:medium;">三、表空間的更改</span></b>
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<br style="background-color:inherit;" />
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
有時候我們創建了我們想要的表空間,但是計劃是趕不上變化的,比如你的數據數據越來越多,原來的表空間容納不下了,怎么辦?或者你想把你的表空間變為只讀,或者你想讓你的有空間自己擴展大小,變手工為自動,等等,這些我們都可以利用ORACLE 的ALTER TABLESPACE 來完成。
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
最先看本地管理表空間(locally managed tablespace)
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<br style="background-color:inherit;" />
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
關于表空間,不能更改的內容:
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
1. 不能把永久表空間變為臨時表空間;
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
2. 不能改變表空間的segment管理方式。
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
可以更改的內容:
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
1. 增加數據文件,DATAFILE
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
2. 改變表空間的可用性,online與offline
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
a) ALTER TABLESPACE lmtemp TEMPFILE OFFLINE;
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
b) ALTER TABLESPACE lmtemp TEMPFILE ONLINE;
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
3. 改變表空間的屬性,read/write only
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
4. 更改數據文件的名字,啟動或禁止數據文件的自動擴展功能。
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
大表空間(bigfile tablespace)
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
1. resize:<span style="background-color:inherit;line-height:1.5;">ALTER TABLESPACE XXX RESIZE 80G</span>
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
2. autoextend:<span style="background-color:inherit;line-height:1.5;"> ALTER TABLESPACE XXX QUTOEXEND ON NEXT 20G</span>
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
<br style="background-color:inherit;" />
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
本地臨時表空間
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
1.增加臨時文件
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
ALTER TABLESPACE lmtemp
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
ADD TEMPFILE '/u02/oracle/data/lmtemp02.dbf' SIZE 18M REUSE;
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
2.改變可用性,不可以讓一個臨時表空間離線,但可以讓臨時文件離線
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf' OFFLINE;
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf' ONLINE;
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
3.改變臨時文件的大小
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf' RESIZE 18M;
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
4.干掉臨時數據文件
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
ALTER DATABASE TEMPFILE '/u02/oracle/data/lmtemp02.dbf' DROP <span style="background-color:inherit;line-height:1.5;"> INCLUDING DATAFILES;</span>
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
5.壓縮臨時表空間
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
先說說操作
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
ALTER TABLESPACE lmtemp1 SHRINK SPACE KEEP 20M;
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
ALTER TABLESPACE lmtemp2 SHRINK TEMPFILE <span style="background-color:inherit;line-height:1.5;"> '/u02/oracle/data/lmtemp02.dbf';</span>
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
KEEP 保持指定大小,如果沒有KEEP語句,則盡可能的減小。還是指定一個好。
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
為什么要執行這個操作?因為數據庫在執行大的排序操作時,會占用很大的臨時表空間,它會讓臨時表空間增大的,然而它也不很完全負責任,當它執行完命令后,他不會把增加的那部分空間歸還給操作系統,它只把它標記為FREE可以重用。這樣就會造成磁盤空間亂費,很可能以后那部分FREE空間一直FREE。
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
上面有針對性的說了一些各種類型表空間的更改方法,下面說一些共性的東西吧:
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
1.改名字用RENAME TO
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
ALTER TABLESPACE user RENAME TO newuser;
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
2.刪除表空間
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
DROP TABLESPACE users INCLUDING CONTENTS;
</div>
<div style="font-family:微軟雅黑;font-size:14px;line-height:21px;white-space:normal;widows:auto;background-color:#FFFFFF;">
DROP TABLESPACE users INCLUDING CONTENTS AND DATAFILES;
</div>