3 Tablespaces, Datafiles, and Control Files


001 This chapter describes tablespaces, the primary logical database structures of any Oracle database, and the physical datafiles that correspond to each tablespace.
 
本章讲解Oracle数据库中重要的逻辑数据库结构--表空间(tablespace),以及组成表空间的物理数据文件(physical datafile)。
002 This chapter contains the following topics: 本章包含以下主题:
003

Introduction to Tablespaces, Datafiles, and Control Files

3.1 表空间,数据文件,控制文件简介

004 Oracle stores data logically in tablespaces and physically in datafiles associated with the corresponding tablespace. Figure 3-1 illustrates this relationship.
 
Oracle中的数据逻辑上存储于表空间(tablespace)中,而物理上则存储于属于表空间的数据文件(datafile)中。图3-1 说明了二者的关系。
005 Figure 3-1 Datafiles and Tablespaces
 
图3-1 数据文件和表空间
006


 

007
Figure 3-1 shows one tablespace that contains two datafiles. The datafiles are the physical structures associated with only one tablespace. Inside the datafiles are objects, like tables and indexes. Objects stored in tablespaces can span several datafiles.
图3-1 显示一个由两个数据文件(datafile)组成的表空间(tablespace)。数据文件是一种物理存储结构,由唯一一个表空间拥有。表、索引等方案对象(schema objects)就存储在数据文件中。属于一个表空间的方案对象可以跨多个数据文件。
008 Databases, tablespaces, and datafiles are closely related, but they have important differences:
  • An Oracle database consists of one or more logical storage units called tablespaces, which collectively store all of the database's data.
  • Each tablespace in an Oracle database consists of one or more files called datafiles, which are physical structures that conform to the operating system in which Oracle is running.
  • A database's data is collectively stored in the datafiles that constitute each tablespace of the database. For example, the simplest Oracle database would have one tablespace and one datafile. Another database can have three tablespaces, each consisting of two datafiles (for a total of six datafiles).
数据库(database),表空间(tablespace),及数据文件(datafile)关系密切,但是她们又具有以下重要区别:
  • 一个Oracle数据库是由一个或多个被称为表空间(tablespace)的逻辑存储单位构成的,这些表空间共同用于存储数据库的数据
  • Oracle数据库的每个表空间由一个或多个被称为数据文件(datafile)的物理文件构成,这些文件由Oracle所在的操作系统管理。
  • 数据库的数据实际存储在构成各个表空间的数据文件中。例如,一个最简单的Oracle数据库至少包含一个表空间及一个数据文件。再例如,一个数据库可能含有三个表空间,每个表空间由两个数据文件构成(即总共有六个数据文件)。
009

Oracle-Managed Files

3.1.1 由Oracle管理数据库文件

010 Oracle-managed files eliminate the need for you, the DBA, to directly manage the operating system files comprising an Oracle database. You specify operations in terms of database objects rather than filenames. Oracle internally uses standard file system interfaces to create and delete files as needed for the following database structures:
  • Tablespaces
  • Redo log files
  • Control files
由Oracle管理数据库文件(Oracle-managed files)避免了由DBA直接管理组成Oracle数据库的操作系统文件(operating system file)。管理员不必了解数据库中各个文件的文件名,而是以数据库对象的形式对文件进行管理操作。而Oracle在内部则使用标准的文件系统(file system)接口来创建,删除以下各种数据库结构所需的文件:
  • 表空间(tablespace)
  • 重做日志文件(redo log file)
  • 控制文件(control file)
011 Through initialization parameters, you specify the file system directory to be used for a particular type of file. Oracle then ensures that a unique file, an Oracle-managed file, is created and deleted when no longer needed.
 
管理员可以在初始化参数(initialization parameter)中设定保存各类数据库文件的文件系统目录(file system directory)。而Oracle就可以据此自动地创建由Oracle管理的唯一的文件,并在不需要时将其删除。
012

See Also:

另见:

013

Allocate More Space for a Database

3.1.2 为数据库分配更多空间

014 The size of a tablespace is the size of the datafiles that constitute the tablespace. The size of a database is the collective size of the tablespaces that constitute the database.
 
表空间(tablespace)的容量等于构成此表空间的各个数据文件(datafile)的容量。而数据库(database)的容量则等于构成此数据库的各个表空间的容量之和。
015 You can enlarge a database in three ways:
  • Add a datafile to a tablespace
  • Add a new tablespace
  • Increase the size of a datafile
管理员可以通过以下三种方式为数据库扩容:
  • 为表空间(tablespace)添加数据文件(datafile)
  • 添加新的表空间
  • 增大数据文件的容量
016 When you add another datafile to an existing tablespace, you increase the amount of disk space allocated for the corresponding tablespace. Figure 3-2 illustrates this kind of space increase.
 
当用户向已有表空间(tablespace)添加数据文件(datafile)时,相当于为此表空间分配了更多的磁盘空间(disk space)。图3-12 显示了这种情况。
017 Figure 3-2 Enlarging a Database by Adding a Datafile to a Tablespace
 
图3-2 通过向表空间添加数据文件而为数据库扩容
018


 


 

019
Figure 3-2 shows the SQL statement for adding a datafile to a tablespace.
ALTER TABLESPACE system
ADD DATAFILE 'DATA2.ORA'
Database size and tablespace size increase with the addition of datafiles.
图3-2 显示了使用一个SQL语句向表空间中添加数据文件。
ALTER TABLESPACE system
ADD DATAFILE 'DATA2.ORA'
表空间及数据库容量因添加的数据文件而增加
020 Alternatively, you can create a new tablespace (which contains at least one additional datafile) to increase the size of a database. Figure 3-3 illustrates this.
 
此外,用户还可以通过创建新的表空间(tablespace )(想当于至少向数据库中添加了一个数据文件(datafile))来扩大数据库容量。见 图3-3 所示。
021 Figure 3-3 Enlarging a Database by Adding a New Tablespace
 
图3-3 通过添加新的表空间而为数据库扩容
022


 


 

023
Figure 3-3 shows the SQL statement for adding a new tablespace:
CREATE TABLESPACE users
DATAFILE 'DATA3.ORA'
图3-3 显示了使用SQL语句添加一个新的表空间:
CREATE TABLESPACE users
DATAFILE 'DATA3.ORA'
024 The third option for enlarging a database is to change a datafile's size or let datafiles in existing tablespaces grow dynamically as more space is needed. You accomplish this by altering existing files or by adding files with dynamic extension properties. Figure 3-4 illustrates this.
 
扩大数据库的第三种方法是手工增大数据文件(datafile)的容量或使表空间(tablespace)内的数据文件容量可以随需动态地增长。用户可以为已有或新建的数据文件设置动态扩展属性(dynamic extension properties)。见 图3-4 所示。
025 Figure 3-4 Enlarging a Database by Dynamically Sizing Datafiles
 
图3-4 通过动态增大数据文件而为数据库扩容
026


 


 

027
Figure 3-4 shows the SQL statement for dynamically sizing datafiles:
ALTER DATABASE
DATAFILE 'DATA3.ORA
AUTOEXTEND ON NEXT 20M
MAXSIZE 1000M;
图3-4 显示了使用SQL语句动态地增大数据库文件:
ALTER DATABASE
DATAFILE 'DATA3.ORA
AUTOEXTEND ON NEXT 20M
MAXSIZE 1000M;
028
See Also:

Oracle Database Administrator's Guide for more information about increasing the amount of space in your database
另见:

Oracle 数据库管理员指南 了解关于增大数据库容量的信息
029

Overview of Tablespaces

3.2 表空间概述

030 A database is divided into one or more logical storage units called tablespaces. Tablespaces are divided into logical units of storage called segments, which are further divided into extents. Extents are a collection of contiguous blocks.
 
数据库是由一个或多个被称为表空间(tablespace)的逻辑存储单位构成。表空间内的逻辑存储单位为(segment),段又可以继续划分为数据扩展(extent)。而数据扩展是由一组连续的数据块(data block)构成。
031 This section includes the following topics about tablespaces: 本节包含以下与表空间(tablespace)相关的主题:
032

See Also:

另见:

033

Bigfile Tablespaces

3.2.1 大文件表空间

034 Oracle lets you create bigfile tablespaces. This allows Oracle Database to contain tablespaces made up of single large files rather than numerous smaller ones. This lets Oracle Database utilize the ability of 64-bit systems to create and manage ultralarge files. The consequence of this is that Oracle Database can now scale up to 8 exabytes in size.
 
在Oracle中用户可以创建大文件表空间(bigfile tablespace)。这样Oracle数据库使用的表空间(tablespace)可以由一个单一的大文件构成,而不是若干个小数据文件。这使Oracle可以发挥64位系统的能力,创建、管理超大的文件。在64位系统中,Oracle数据库的存储能力被扩展到了8 EB(1EB = 1024PB,1PB = 1024TB,1TB=1024GB)。
035 With Oracle-managed files, bigfile tablespaces make datafiles completely transparent for users. In other words, you can perform operations on tablespaces, rather than the underlying datafile. Bigfile tablespaces make the tablespace the main unit of the disk space administration, backup and recovery, and so on. Bigfile tablespaces also simplify datafile management with Oracle-managed files and Automatic Storage Management by eliminating the need for adding new datafiles and dealing with multiple files.
 
当数据库文件由Oracle管理(Oracle-managed files),且使用大文件表空间(bigfile tablespace)时,数据文件对用户完全透明。换句话说,用户只须针对表空间(tablespace)执行管理操作,而无须关心处于底层的数据文件(datafile)。使用大文件表空间,使表空间成为磁盘空间管理,备份,和恢复等操作的主要对象。使用大文件表空间,并与由Oracle管理数据库文件(Oracle-managed files)技术以及自动存储管理(Automatic Storage Management)技术相结合,就不再需要管理员手工创建新的数据文件(datafile)并维护众多数据库文件,因此简化了数据库文件管理工作。
 
036 The system default is to create a smallfile tablespace, which is the traditional type of Oracle tablespace. The SYSTEM and SYSAUX tablespace types are always created using the system default type.
 
数据库默认创建的是小文件表空间(smallfile tablespace),即Oracle中传统的表空间(tablespace)类型。数据库中 SYSTEMSYSAUX 表空间在创建时总是使用传统类型。
037 Bigfile tablespaces are supported only for locally managed tablespaces with automatic segment-space management. There are two exceptions: locally managed undo and temporary tablespaces can be bigfile tablespaces, even though their segments are manually managed.
 
只有本地管理的(locally managed),且段空间自动管理(automatic segment-space management)的表空间(tablespace)才能使用大文件表空间(bigfile tablespace)。但是有两个例外:本地管理的撤销表空间(undo tablespace)和临时表空间(temporary tablespace),即使其段(segment)为手工管理(manually managed),也可以使用大文件表空间。
 
038 An Oracle database can contain both bigfile and smallfile tablespaces. Tablespaces of different types are indistinguishable in terms of execution of SQL statements that do not explicitly refer to datafiles.
 
一个Oracle数据库可以同时包含大文件/小文件表空间(bigfile/smallfile tablespace)。SQL语句执行时无需考虑表空间(tablespace)的类型,除非语句中显式地引用了数据文件(datafile)名。
039 You can create a group of temporary tablespaces that let a user consume temporary space from multiple tablespaces. A tablespace group can also be specified as the default temporary tablespace for the database. This is useful with bigfile tablespaces, where you could need a lot of temporary tablespace for sorts.
 
管理员可以创建一组临时表空间(temporary tablespace),用户在需要时可以利用组内各个表空间(tablespace)提供的临时空间。管理员还可以指定表空间组(tablespace group)为数据库默认的临时表空间。当用户需要大量临时空间进行排序操作时,就可以利用大文件表空间及表空间组。
040

Benefits of Bigfile Tablespaces

3.2.1.1 使用大文件表空间的优势

041
  • Bigfile tablespaces can significantly increase the storage capacity of an Oracle database. Smallfile tablespaces can contain up to 1024 files, but bigfile tablespaces contain only one file that can be 1024 times larger than a smallfile tablespace. The total tablespace capacity is the same for smallfile tablespaces and bigfile tablespaces. However, because there is limit of 64K datafiles for each database, a database can contain 1024 times more bigfile tablespaces than smallfile tablespaces, so bigfile tablespaces increase the total database capacity by 3 orders of magnitude. In other words, 8 exabytes is the maximum size of the Oracle database when bigfile tablespaces are used with the maximum block size (32 k).
  • Bigfile tablespaces simplify management of datafiles in ultra large databases by reducing the number of datafiles needed. You can also adjust parameters to reduce the SGA space required for datafile information and the size of the control file.
  • They simplify database management by providing datafile transparency.
  • 使用大文件表空间(bigfile tablespace)可以显著地增强Oracle数据库的存储能力。一个小文件表空间(smallfile tablespace)最多可以包含1024个数据文件(datafile),而一个大文件表空间中只包含一个文件,这个数据文件的最大容量是小数据文件的1024倍。这样看来,大文件表空间和小文件表空间的最大容量是相同的。但是由于每个数据库最多使用64K个数据文件,因此使用大文件表空间时数据库中表空间的极限个数是使用小文件表空间时的1024倍,使用大文件表空间时的总数据库容量比使用小文件表空间时高出三个数量级。换言之,当一个Oracle数据库使用大文件表空间,且使用最大的数据块容量时(32K),其总容量可以达到8EB。
  • 在超大型数据库中使用大文件表空间减少了数据文件的数量,因此也简化了对数据文件的管理工作。由于数据文件的减少,SGA中关于数据文件的信息,以及控制文件(control file)的容量也得以减小。
  • 由于数据文件对用户透明,由此简化了数据库管理工作。
042

Considerations with Bigfile Tablespaces

3.2.1.2 使用大文件表空间时需要考虑的因素

043
  • Bigfile tablespaces are intended to be used with Automatic Storage Management or other logical volume managers that support dynamically extensible logical volumes and striping or RAID.
  • Avoid creating bigfile tablespaces on a system that does not support striping because of negative implications for parallel execution and RMAN backup parallelization.
  • Avoid using bigfile tablespaces if there could possibly be no free space available on a disk group, and the only way to extend a tablespace is to add a new datafile on a different disk group.
  • Using bigfile tablespaces on platforms that do not support large file sizes is not recommended and can limit tablespace capacity. Refer to your operating system specific documentation for information about maximum supported file sizes.
  • Performance of database opens, checkpoints, and DBWR processes should improve if data is stored in bigfile tablespaces instead of traditional tablespaces. However, increasing the datafile size might increase time to restore a corrupted file or create a new datafile.
  • 大文件表空间(bigfile tablespace)应该和自动存储管理(Automatic Storage Management)或其他逻辑卷管理工具(logical volume manager)配合使用,这些工具应该能够支持动态扩展逻辑卷,也能支持striping(数据跨磁盘分布)或RAID。
  • 应该避免在不支持striping的系统上使用大文件表空间,因为这将不利于并行执行(parallel execution)及 RMAN 的并行备份(backup parallelization)。
  • 当表空间正在使用的磁盘组(disk group)可能没有足够的空间,且扩展表空间的唯一办法是向另一个磁盘组加入数据文件时,应避免使用大文件表空间。
  • 不建议在不支持大文件的平台上使用大文件表空间,这会限制表空间(tablespace)的容量。参考相关的操作系统文档了解其支持的最大文件容量。
  • 如果使用大文件表空间替代传统的表空间,数据库开启(open),checkpoints,以及 DBWR 进程的性能会得到提高。但是增大数据文件(datafile)容量可能会增加备份与恢复的时间。
044
See Also:

Oracle Database Administrator's Guide for details on creating, altering, and administering bigfile tablespaces
另见:

Oracle 数据库管理员指南 了解关于创建、修改、管理大文件表空间的详细信息。
045

The SYSTEM Tablespace

3.2.2 SYSTEM 表空间

046 Every Oracle database contains a tablespace named SYSTEM, which Oracle creates automatically when the database is created. The SYSTEM tablespace is always online when the database is open.
 
每个Oracle数据库都包含一个名为 SYSTEM 的表空间(tablespace),她在数据库创建时由Oracle自动创建。只要数据库处于开启(open)状态,SYSTEM 表空间就一定是联机(online)的。
047 To take advantage of the benefits of locally managed tablespaces, you can create a locally managed SYSTEM tablespace, or you can migrate an existing dictionary managed SYSTEM tablespace to a locally managed format.
 
管理员可以创建本地管理的(locally managed)SYSTEM 表空间(tablespace),或将已有的数据字典管理的(dictionary managed)SYSTEM 表空间转换为本地管理,以便发挥本地管理的表空间的优势。
048 In a database with a locally managed SYSTEM tablespace, dictionary managed tablespaces cannot be created. It is possible to plug in a dictionary managed tablespace using the transportable feature, but it cannot be made writable.
 
如果数据库中的 SYSTEM 表空间(tablespace)为本地管理的(locally managed),那么此数据库中就不能创建数据字典管理的(dictionary managed)表空间。虽然用户可以通过可移动表空间(transportable tablespace)功能向其中添加数据字典管理的表空间,但这个表空间只能是只读的。
 
049
Note:

If a tablespace is locally managed, then it cannot be reverted back to being dictionary managed.
提示:

如果一个表空间(tablespace)为本地管理的(locally managed),则不能将她转换为数据字典管理的(dictionary managed)。
050

The Data Dictionary

3.2.2.1 数据字典

051 The SYSTEM tablespace always contains the data dictionary tables for the entire database. The data dictionary tables are stored in datafile 1.
 
SYSTEM 表空间(tablespace)总是用于存储整个数据库的数据字典表(data dictionary table)。数据字典表存储在编号为 1 的数据文件(datafile)中。
052

PL/SQL Program Units Description

3.2.2.2 PL/SQL 程序结构描述

053 All data stored on behalf of stored PL/SQL program units (that is, procedures, functions, packages, and triggers) resides in the SYSTEM tablespace. If the database contains many of these program units, then the database administrator must provide the space the units need in the SYSTEM tablespace.
 
所有和 PL/SQL 程序结构(包括过程(procedure),函数(function),包(package),及触发器(trigger))有关的数据都被保存在 SYSTEM 表空间(tablespace)中。如果数据库中用户定义的程序结构很多,那么管理员必须为之在 SYSTEM 表空间中提供足够的空间。
054

See Also:

另见:

055

The SYSAUX Tablespace

3.2.3 SYSAUX 表空间

056 The SYSAUX tablespace is an auxiliary tablespace to the SYSTEM tablespace. Many database components use the SYSAUX tablespace as their default location to store data. Therefore, the SYSAUX tablespace is always created during database creation or database upgrade.
 
SYSAUX 表空间(tablespace)是 SYSTEM 表空间的一个辅助性表空间。Oracle中很多组件使用 SYSAUX 表空间作为默认的数据存储位置。因此在 10g 数据库创建,或从低版本升级到 10g 时,一定会创建 SYSAUX 表空间。
057 The SYSAUX tablespace provides a centralized location for database metadata that does not reside in the SYSTEM tablespace. It reduces the number of tablespaces created by default, both in the seed database and in user-defined databases.
 
此外,SYSAUX 表空间(tablespace)还被用来集中存储所有不应放在 SYSTEM 表空间的数据库元数据。不论是依据模版建立的数据库(seed database),还是用户定义的数据库(user-defined database),使用 SYSAUX 表空间可以减少默认创建的表空间数量。
058 During normal database operation, the Oracle database server does not allow the SYSAUX tablespace to be dropped or renamed. Transportable tablespaces for SYSAUX is not supported.
 
在正常的数据库操作中,不允许移除(drop)或重命名(rename)SYSAUX 表空间(tablespace)。SYSAUX 表空间也不支持可移动表空间(transportable tablespace)功能。
059
Note:

If the SYSAUX tablespace is unavailable, such as due to a media failure, then some database features might fail.
提示:

如果 SYSAUX 表空间实效,例如发生介质故障(media failure),那么有些数据库功能可能会随之失效。
060

Undo Tablespaces

3.2.4 撤销表空间

061 Undo tablespaces are special tablespaces used solely for storing undo information. You cannot create any other segment types (for example, tables or indexes) in undo tablespaces. Each database contains zero or more undo tablespaces. In automatic undo management mode, each Oracle instance is assigned one (and only one) undo tablespace. Undo data is managed within an undo tablespace using undo segments that are automatically created and maintained by Oracle.
 
撤销表空间(undo tablespace)是一个特殊的表空间(tablespace),只用于存储撤销信息(undo information)。用户不能在其中创建段(segment)(例如表或索引)。一个数据库中可以没有撤销表空间,也可以包含多个。在自动撤销管理模式(automatic undo management mode)下,每个Oracle实例(instance)有(且仅有)一个撤销表空间。Oracle在撤销表空间内自动地创建和维护撤销段(undo segment),对撤销数据(undo data)进行管理。
062 When the first DML operation is run within a transaction, the transaction is bound (assigned) to an undo segment (and therefore to a transaction table) in the current undo tablespace. In rare circumstances, if the instance does not have a designated undo tablespace, the transaction binds to the system undo segment.
 
当事务(transaction)内第一条 DML 语句运行时,系统就为期其在当前撤销表空间(undo tablespace)中分配一个撤销段(undo segment),同时也分配一个事务表(transaction table)。在极少数情况下,如果实例(instance)中没有指定撤销表空间,那么事务将使用系统的撤销段。
063
Caution:

Do not run any user transactions before creating the first undo tablespace and taking it online.
警告:

在创建撤销表空间(undo tablespace),并使之联机(online)之前,不要运行任何用户事务 (transaction)。
064 Each undo tablespace is composed of a set of undo files and is locally managed. Like other types of tablespaces, undo blocks are grouped in extents and the status of each extent is represented in the bitmap. At any point in time, an extent is either allocated to (and used by) a transaction table, or it is free.
 
撤销表空间(undo tablespace)由一组撤销文件(undo file)构成,且为本地管理的(locally managed)。与其他表空间(tablespace)的结构类似,撤销表空间中也存在由撤销数据块(undo block)构成的数据扩展(extent),这些数据扩展的状态由位图(bitmap)表示。在任何时间点上,一个数据扩展或者被分配给一个事务表(transaction table)(被使用状态),或者处于可用状态。
 
065 You can create a bigfile undo tablespace.
 
用户可以创建大文件撤销表空间(bigfile undo tablespace)。
066
See Also:

"Bigfile Tablespaces"
另见:

大文件表空间
067

Creation of Undo Tablespaces

3.2.4.1 创建撤销表空间

068 A database administrator creates undo tablespaces individually, using the CREATE UNDO TABLESPACE statement. It can also be created when the database is created, using the CREATE DATABASE statement. A set of files is assigned to each newly created undo tablespace. Like regular tablespaces, attributes of undo tablespaces can be modified with the ALTER TABLESPACE statement and dropped with the DROP TABLESPACE statement.
 
数据库管理员可以使用 CREATE UNDO TABLESPACE 语句单独创建撤销表空间(undo tablespace),也可以在使用 CREATE DATABASE 语句创建数据库的同时创建撤销表空间。撤销表空间也使用一组数据文件存储数据。与常规的表空间一样,撤销表空间既可以用 DROP TABLESPACE 语句移除,其属性也可以通过 ALTER TABLESPACE 语句修改。
 
069
Note:

An undo tablespace cannot be dropped if it is being used by any instance or contains any undo information needed to recover transactions.
提示:

当撤销表空间(undo tablespace)正在被实例(instance)使用,或者包含了事务恢复所需的撤销信息(undo information)时,不能将其移除(drop)。
070

Assignment of Undo Tablespaces

3.2.4.2 分配撤销表空间

071 You assign an undo tablespace to an instance in one of two ways:
  • At instance startup. You can specify the undo tablespace in the initialization file or let the system choose an available undo tablespace.
  • While the instance is running. Use ALTER SYSTEM SET UNDO_TABLESPACE to replace the active undo tablespace with another undo tablespace. This method is rarely used.
用户可以使用以下两种方法将撤销表空间(undo tablespace)分配给一个实例(instance):
  • 在实例启动时。用户可以在实例的初始化文件(initialization file)中指定一个撤销表空间,或指定由系统自动选择一个可用的撤销表空间。
  • 当实例运行时。使用 ALTER SYSTEM SET UNDO_TABLESPACE 将当前活动的撤销表空间替换为另一个。这种方式很少使用。
072 You can add more space to an undo tablespace by adding more datafiles to the undo tablespace with the ALTER TABLESPACE statement.
 
用户可以使用 ALTER TABLESPACE 语句向撤销表空间(undo tablespace)添加数据文件(datafile),以扩展撤销表空间的容量。
073 You can have more than one undo tablespace and switch between them. Use the Database Resource Manager to establish user quotas for undo tablespaces. You can specify the retention period for undo information.
 
用户可以创建多个撤销表空间(undo tablespace),以便切换使用。用户还可以设定撤销信息(undo information)的保存周期(retention period)。用户也可以使用数据库资源管理器(Database Resource Manager)为用户规定撤销表空间的使用配额(quota)。
 
074
See Also:

Oracle Database Administrator's Guide for detailed information about creating and managing undo tablespaces
另见:

Oracle 数据库管理员指南 了解创建和管理撤销表空间的详细信息
075

Default Temporary Tablespace

3.2.5 默认的临时表空间

076 When the SYSTEM tablespace is locally managed, you must define at least one default temporary tablespace when creating a database. A locally managed SYSTEM tablespace cannot be used for default temporary storage.
 
如果 SYSTEM 表空间(tablespace)是本地管理的(locally managed),用户必须在创建数据库时定义一个默认的临时表空间(temporary tablespace)。本地管理的 SYSTEM 表空间不能作为默认的临时存储空间。
077 If SYSTEM is dictionary managed and if you do not define a default temporary tablespace when creating the database, then SYSTEM is still used for default temporary storage. However, you will receive a warning in ALERT.LOG saying that a default temporary tablespace is recommended and will be necessary in future releases.
 
如果 SYSTEM 表空间(tablespace)是数据字典管理的(dictionary managed),且创建数据库时没有定义默认的临时表空间(temporary tablespace),那么Oracle将 SYSTEM 表空间作为默认的临时存储空间使用。此时用户在 ALERT.LOG 文件中会发现一条警告:建议创建默认的临时表空间,以后的Oracle版本将会需要。
078

How to Specify a Default Temporary Tablespace

3.2.5.1 如何指定默认的临时表空间

079 Specify default temporary tablespaces when you create a database, using the DEFAULT TEMPORARY TABLESPACE extension to the CREATE DATABASE statement.
 
用户在使用 CREATE DATABASE 语句创建数据库时,可以通过 DEFAULT TEMPORARY TABLESPACE 子句指定默认的临时表空间(temporary tablespace)。
080 If you drop all default temporary tablespaces, then the SYSTEM tablespace is used as the default temporary tablespace.
 
如果用户移除(drop)了所有默认的临时表空间(temporary tablespace),Oracle将使用 SYSTEM 表空间(tablespace)作为默认的临时表空间。
081 You can create bigfile temporary tablespaces. A bigfile temporary tablespaces uses tempfiles instead of datafiles.
 
用户可以创建大文件临时表空间(bigfile temporary tablespace)。大文件临时表空间使用临时文件(tempfile),而不是数据文件(datafile)。
 
082
Note:

You cannot make a default temporary tablespace permanent or take it offline.
提示:

用户不能将默认的临时表空间(default temporary tablespace)转为永久表空间(permanent),或将其置为脱机状态(offline)。
083

See Also:

另见:

084

Using Multiple Tablespaces

3.2.6 在数据库中使用多个表空间

085 A very small database may need only the SYSTEM tablespace; however, Oracle recommends that you create at least one additional tablespace to store user data separate from data dictionary information. This gives you more flexibility in various database administration operations and reduces contention among dictionary objects and schema objects for the same datafiles.
 
一个小型数据库可能只需要使用 SYSTEM 表空间(tablespace);但是Oracle建议用户至少创建一个额外的表空间来存储用户数据,使之与系统的数据字典信息(data dictionary information)分离。这使用户在进行数据库管理操作时更灵活,并减少了由于数据字典对象(dictionary object)与用户方案对象(schema object)处于同一数据文件(datafile)而导致的竞争。
086 You can use multiple tablespaces to perform the following tasks:
  • Control disk space allocation for database data
  • Assign specific space quotas for database users
  • Control availability of data by taking individual tablespaces online or offline
  • Perform partial database backup or recovery operations
  • Allocate data storage across devices to improve performance
用户可以利用多个表空间(multiple tablespace)完成以下任务:
  • 控制数据库内的磁盘空间分配
  • 为数据库用户设定空间使用配额(quota)
  • 通过将某个表空间置于联机/脱机(online/offline)状态来控制数据的可访问性(availability)
  • 执行对数据库的某部分的备份与恢复
  • 使数据存储可以跨多个设备,提升系统性能
087 A database administrator can use tablespaces to do the following actions:
  • Create new tablespaces
  • Add datafiles to tablespaces
  • Set and alter default segment storage settings for segments created in a tablespace
  • Make a tablespace read only or read/write
  • Make a tablespace temporary or permanent
  • Rename tablespaces
  • Drop tablespaces
数据库管理员可以对表空间(tablespace)进行以下操作:
  • 创建一个新的表空间
  • 为一个表空间添加数据文件(datafile)
  • 设置或修改表空间内某段(segment)的默认段存储参数(default segment storage setting)
  • 使一个表空间为只读(read only)或可读写(read/write)
  • 将表空间设置为临时(temporary)或永久(permanent)
  • 重命名表空间
  • 移除(drop)表空间
088

Managing Space in Tablespaces

3.2.7 表空间内的空间管理

089 Tablespaces allocate space in extents. Tablespaces can use two different methods to keep track of their free and used space:
  • Locally managed tablespaces: Extent management by the tablespace
  • Dictionary managed tablespaces: Extent management by the data dictionary
表空间(tablespace)内(为各个方案对象)分配空间的单位是数据扩展(extent)。Oracle采用两种方式监控表空间内的空间的已用/可用情况:
  • 本地管理的表空间(Locally managed tablespaces): 通过位图(bitmap)管理数据扩展
  • 数据字典管理的表空间(Dictionary managed tablespaces):通过数据字典管理数据扩展
090 When you create a tablespace, you choose one of these methods of space management. Later, you can change the management method with the DBMS_SPACE_ADMIN PL/SQL package.
 
当用户创建表空间(tablespace)时,需要选择空间管理方式。在此之后,用户还可以通过 DBMS_SPACE_ADMIN PL/SQL 包(package)改变管理方式。
091
Note:

If you do not specify extent management when you create a tablespace, then the default is locally managed.
提示:

当用户在创建表空间(tablespace)时没有指定数据扩展(extent)的管理方式,默认使用本地管理(locally managed)。
092
See Also:

"Overview of Extents"
另见:

数据扩展概述
093

Locally Managed Tablespaces

3.2.7.1 本地管理的表空间

094 A tablespace that manages its own extents maintains a bitmap in each datafile to keep track of the free or used status of blocks in that datafile. Each bit in the bitmap corresponds to a block or a group of blocks. When an extent is allocated or freed for reuse, Oracle changes the bitmap values to show the new status of the blocks. These changes do not generate rollback information because they do not update tables in the data dictionary (except for special cases such as tablespace quota information).
 
本地管理的表空间(locally managed tablespace)在每个数据文件(datafile)中维护一个位图(bitmap),记录此数据文件内数据块(block)的状态(可用/占用),并据此管理表空间内的数据扩展(extent)。位图中的每一位代表一个或一组数据块(block)。当一个数据扩展被分配或者被释放,Oracle负责改变位图中相应的数据块的状态。这些修改不会产生回滚信息(rollback information),因为她们不会更新数据字典(data dictionary)中的表(一些特殊的情况除外,例如改变表空间的配额(quota)信息)。
095 Locally managed tablespaces have the following advantages over dictionary managed tablespaces:
  • Local management of extents automatically tracks adjacent free space, eliminating the need to coalesce free extents.
  • Local management of extents avoids recursive space management operations. Such 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 rollback segment.
本地管理的表空间(locally managed tablespace)与数据字典管理的表空间(dictionary managed tablespace)相比有如下优势:
  • 在本地管理数据扩展(extent)的分配,易于查找连续的可用空间[此处指数据块],避免了数据扩展合并(coalesce free extents)。
  • 在本地管理数据扩展的分配,能够避免产生递归(recursive)的空间管理操作。在使用数据字典管理的表空间时,分配或回收方案对象(schema object)的数据扩展可能会导致数据字典表(data dictionary table)或回滚段(rollback segment)中也产生分配或回收空间的操作,即称为递归的空间管理操作。
096 The sizes of extents that are managed locally can be determined automatically by the system. Alternatively, all extents can have the same size in a locally managed tablespace and override object storage options.
 
在本地管理(locally managed)状态下,每次分配的数据扩展(extent)的容量可以由系统自动地决定。此外,用户也可以覆盖方案对象默认的存储参数,每次分配相同容量的数据扩展。
097 The LOCAL clause of the CREATE TABLESPACE or CREATE TEMPORARY TABLESPACE statement is specified to create locally managed permanent or temporary tablespaces, respectively.
 
CREATE TABLESPACE CREATE TEMPORARY TABLESPACE 语句中使用 LOCAL 子句可以创建本地管理的(locally managed)永久表空间(permanent tablespace)或临时表空间(temporary tablespace)。
 
098

Segment Space Management in Locally Managed Tablespaces

3.2.7.2 本地管理的表空间中的段空间管理

099 When you create a locally managed tablespace using the CREATE TABLESPACE statement, the SEGMENT SPACE MANAGEMENT clause lets you specify how free and used space within a segment is to be managed. Your choices are:
  • AUTO

    This keyword tells Oracle that you want to use bitmaps to manage the free space within segments. A bitmap, in this case, is a map that describes the status of each data block within a segment with respect to the amount of space in the block available for inserting rows. As more or less space becomes available in a data block, its new state is reflected in the bitmap. Bitmaps enable Oracle to manage free space more automatically; thus, this form of space management is called automatic segment-space management.

    Locally managed tablespaces using automatic segment-space management can be created as smallfile (traditional) or bigfile tablespaces. AUTO is the default.
     
  • MANUAL

    This keyword tells Oracle that you want to use free lists for managing free space within segments. Free lists are lists of data blocks that have space available for inserting rows.
用户使用 CREATE TABLESPACE 语句创建一个本地管理的表空间(locally managed tablespace)时,可以使用 SEGMENT SPACE MANAGEMENT 子句来设定段(segment)内的可用/已用空间如何管理。可选的方式有:
  • AUTO

    在这种设置下,Oracle使用位图(bitmap)管理段内的可用空间。[注意此处的位图与本地管理的表空间使用的位图不一样]此处的位图用于描述段内每个数据块(data block)是否有足够的可用空间来插入(insert)新数据。随着一个数据块中可用空间的变化,她的状态也被及时地反映到位图中。Oracle使用位图可以更自动化地管理段内的可用空间。这种空间管理形式被称为自动段空间管理(automatic segment-space management)。

    一个本地管理的(locally managed),且使用自动段空间管理的表空间,既可以被创建为小文件表空间(传统的)(smallfile tablespace),也可以被创建为大文件表空间(bigfile tablespaces)。在创建本地管理的表空间时,自动段空间管理是默认值。
     
  • MANUAL

    在这种设置下,Oracle使用可用块列表(free list)来管理段内的可用空间。可用块列表记录了所有可以被用于插入新数据的数据块。
100

See Also:

另见:

101

Dictionary Managed Tablespaces

3.2.7.3 数据字典管理的表空间

102 If you created your database with an earlier version of Oracle, then you could be using dictionary managed tablespaces. For a tablespace that uses the data dictionary to manage its extents, Oracle updates the appropriate tables in the data dictionary whenever an extent is allocated or freed for reuse. Oracle also stores rollback information about each update of the dictionary tables. Because dictionary tables and rollback segments are part of the database, the space that they occupy is subject to the same space management operations as all other data.
 
如果用户的数据库是使用Oracle的早期版本创建的,有可能还在使用数据字典管理的表空间(dictionary managed tablespace)。如果表空间(tablespace)使用数据字典(data dictionary)管理其数据扩展(extent),当发生数据扩展的分配与回收时,Oracle会更新数据字典内相应的表。Oracle也会在更新数据字典表时存储相应的回滚信息(rollback information)。因为数据字典表与回滚段(rollback segment)都是数据库的一部分,她们使用的空间如同其他数据库对象一样也必须进行空间管理操作。
103

Multiple Block Sizes

3.2.8 多种数据块容量

104 Oracle supports multiple block sizes in a database. The standard block size is used for the SYSTEM tablespace. This is set when the database is created and can be any valid size. You specify the standard block size by setting the initialization parameter DB_BLOCK_SIZE. Legitimate values are from 2K to 32K.
 
Oracle支持在数据库中使用多种数据块容量(multiple block size)。SYSTEM 表空间(tablespace)使用标准数据块容量(standard block size)。这个容量在数据库创建时被设定,可以为任何有效值。用户可以使用 DB_BLOCK_SIZE 初始化参数(initialization parameter)设定标准数据块容量。数据块容量的合法值(legitimate value)范围是2K到32K。
105 In the initialization parameter file or server parameter, you can configure subcaches within the buffer cache for each of these block sizes. Subcaches can also be configured while an instance is running. You can create tablespaces having any of these block sizes. The standard block size is used for the system tablespace and most other tablespaces.
 
在初始化参数文件(initialization parameter file)或服务器参数文件(server parameter file)中,用户可以为数据缓存(buffer cache)内的不同子缓存区(subcache)设定不同的数据块容量(block size)。子缓存区也可以在实例(instance)运行时配置。此外用户还可以创建使用不同数据块容量的表空间(tablespace)。但是 SYSTEM 表空间及绝大多数表空间还是使用标准数据块容量(standard block size)。
 
106
Note:

All partitions of a partitioned object must reside in tablespaces of a single block size.
提示:

一个分区对象(partitioned object)的所有分区(partition)所在的表空间(tablespace)必须使用相同的数据块容量(block size)。
107 Multiple block sizes are useful primarily when transporting a tablespace from an OLTP database to an enterprise data warehouse. This facilitates transport between databases of different block sizes.
 
多种数据块容量(multiple block size)功能主要用于从 OLTP 数据库向企业级数据仓库(enterprise data warehouse)迁移(transporting)表空间时使用。这有助于在拥有不同数据块容量(block size)的数据库间迁移数据。
108

See Also:

另见:

109

Online and Offline Tablespaces

3.2.9 联机/脱机表空间

110 A database administrator can bring any tablespace other than the SYSTEM tablespace online (accessible) or offline (not accessible) whenever the database is open. The SYSTEM tablespace is always online when the database is open because the data dictionary must always be available to Oracle.
 
数据库管理员可以在数据库处于开启(open)状态时令除 SYSTEM 表空间(tablespace)之外的任何表空间联机(online)(可访问)或脱机(offline)(不可访问)。SYSTEM 表空间在数据库处于开启(open)状态时总是处于联机状态,因为Oracle需要使用其中的数据字典(data dictionary)。
111 A tablespace is usually online so that the data contained within it is available to database users. However, the database administrator can take a tablespace offline for maintenance or backup and recovery purposes.
 
表空间(tablespace)通常处于联机(online)状态,以便数据库用户访问其中的数据。但是数据库管理员可以在对表空间进行维护,备份或恢复操作时,令表空间脱机(offline)。
112

Bringing Tablespaces Offline

3.2.9.1 令表空间脱机

113 When a tablespace goes offline, Oracle does not permit any subsequent SQL statements to reference objects contained in that tablespace. Active transactions with completed statements that refer to data in that tablespace are not affected at the transaction level. Oracle saves rollback data corresponding to those completed statements in a deferred rollback segment in the SYSTEM tablespace. When the tablespace is brought back online, Oracle applies the rollback data to the tablespace, if needed.
 
当一个表空间(tablespace)脱机(offline)后,Oracle不允许任何SQL语句继续引用此表空间内的对象(schema object)。如果一个活动事务(active transaction)中的 SQL 语句正好在使用被置为脱机状态的表空间内的对象,其事务性也不会被破坏。Oracle使用 SYSTEM 表空间内的延迟回滚段(deferred rollback segment)为此事务中已完成的 SQL 语句保存回滚信息(rollback data)。当脱机表空间被重新置位联机(online)状态后,Oracle会在需要时应用这些回滚信息。
114 When a tablespace goes offline or comes back online, this is recorded in the data dictionary in the SYSTEM tablespace. If a tablespace is offline when you shut down a database, the tablespace remains offline when the database is subsequently mounted and reopened.
 
表空间(tablespace)联机(online)或脱机(offline)时,SYSTEM 表空间内的数据字典(data dictionary)会进行记录。如果用户关闭(shut down)一个数据库时某个表空间处于脱机状态,那么这个表空间在数据库下次被装载(mount)、打开(open)后依旧保持脱机状态。
115 You can bring a tablespace online only in the database in which it was created because the necessary data dictionary information is maintained in the SYSTEM tablespace of that database. An offline tablespace cannot be read or edited by any utility other than Oracle. Thus, offline tablespaces cannot be transposed to other databases.
 
用户只能将一个表空间(tablespace)联机(online)到创建她的数据库中,因为只有这个数据库的 SYSTEM 表空间中才保存着与此表空间相关的必要的数据字典(data dictionary)信息。一个脱机(offline)的表空间不能被Oracle之外的工具打开或编辑。因此脱机表空间不能被移动到其他数据库中。
116 Oracle automatically switches a tablespace from online to offline when certain errors are encountered. For example, Oracle switches a tablespace from online to offline when the database writer process, DBWn, fails in several attempts to write to a datafile of the tablespace. Users trying to access tables in the offline tablespace receive an error. If the problem that causes this disk I/O to fail is media failure, you must recover the tablespace after you correct the problem.
 
当某些错误发生时,Oracle会自动地将相关的联机表空间(online tablespace)切换到脱机(offline)状态。例如,当数据库写入进程(database writer process,DBWn)多次尝试向表空间的数据文件(datafile)写入失败后,Oracle就会将此表空间切换到脱机状态。此时尝试访问脱机表空间内数据表的用户将会得到错误信息。如果是介质故障(media failure)导致此次磁盘 I/O 失败,用户必须在处理故障后恢复(recover)受影响的表空间。
117

See Also:

另见:

118

Use of Tablespaces for Special Procedures

3.2.9.2 特殊情况下的表空间使用

119 If you create multiple tablespaces to separate different types of data, you take specific tablespaces offline for various procedures. Other tablespaces remain online, and the information in them is still available for use. However, special circumstances can occur when tablespaces are taken offline. For example, if two tablespaces are used to separate table data from index data, the following is true:
  • If the tablespace containing the indexes is offline, then queries can still access table data because queries do not require an index to access the table data.
  • If the tablespace containing the tables is offline, then the table data in the database is not accessible because the tables are required to access the data.
用户可以将不同类型的数据分开存储在不同的表空间(tablespace)中。当用户因为某些任务而令某个表空间脱机(offline)后,其余表空间仍保持联机(online)状态,其中的数据对用户依然可用。但是表空间脱机后也会导致特殊情况发生。例如,有两个表空间分别用于存储表及此表对应的索引,将出现以下问题:
  • 如果包含索引的表空间脱机,那么查询依旧可以访问表数据,因为对表数据的访问并不一定需要索引数据。
  • 如果包含表的表空间脱机,那么查询将无法访问表数据,因为脱机表空间内的对象无法被引用。
120 If Oracle has enough information in the online tablespaces to run a statement, it does so. If it needs data in an offline tablespace, then it causes the statement to fail.
 
如果Oracle能够从联机(online)表空间(tablespace)中获得执行一个SQL语句的足够的信息,那么语句就将被执行。如果相关信息必须从脱机(offline)的表空间中获得,那么语句将失败。
121

Read-Only Tablespaces

3.2.10 只读表空间

122 The primary purpose of read-only tablespaces is to eliminate the need to perform backup and recovery of large, static portions of a database. Oracle never updates the files of a read-only tablespace, and therefore the files can reside on read-only media such as CD-ROMs or WORM drives.
 
使用只读表空间(read-only tablespace)的主要目的是为了避免对静态、且容量大的数据库内容进行备份和恢复操作。Oracle不会更新只读表空间内的数据,因此这类表空间的数据文件(datafile)可以放置在 CD-ROM 或 WORM 之类的只读介质(read-only media)上。
123
Note:

Because you can only bring a tablespace online in the database in which it was created, read-only tablespaces are not meant to satisfy archiving requirements.
提示:

用户只能将一个表空间(tablespace)联机(online)到创建她的数据库,因此只读表空间(read-only tablespace)技术不适用于存档工作(archiving)。
124 Read-only tablespaces cannot be modified. To update a read-only tablespace, first make the tablespace read/write. After updating the tablespace, you can then reset it to be read only.
 
只读表空间(read-only tablespace)不能被修改。如需更新一个只读表空间,首先要使表空间可读写。在更新后,还可以将表空间恢复到只读状态。
125 Because read-only tablespaces cannot be modified, and as long as they have not been made read/write at any point, they do not need repeated backup. Also, if you need to recover your database, you do not need to recover any read-only tablespaces, because they could not have been modified.
 
因为只读表空间(read-only tablespace)不能被修改,只要没有将只读表空间置于可读写状态,就无需对其进行重复的备份操作。当用户需要恢复数据库时,也没必要恢复只读表空间,原因同前所述。
126

See Also:

另见: