| Oracle® Database Administrator's Guide 10g Release 1 (10.1) Part Number B10739-01 |
|
![]() Previous |
![]() Next |
This chapter discusses the use of the Oracle-managed files and contains the following topics:
Tablespaces
Redo log files
Control files
Archived logs
Block change tracking files
Flashback logs
RMAN backups
Through initialization parameters, you speci fy the file system directory to be used for a particular type of file. The database then ensures that a unique file, an Oracle-manage d file, is created and deleted when no longer needed.
This feature does not affect the creation or naming of administrative fi les such as trace files, audit files, alert files, and core files.
|
See Also: Chapter 12, " Using Automatic Storage Manag ement" for information about the Oracle Database integrated storage management system that extends the power of Oracle-managed fi les. With Oracle-managed files, files are created and managed automatically for you, but with Automatic Storage Management you get th e additional benefits of features such as file redundancy and striping, without the need to purchase a third-party logical volume man ager. |
Oracle-man aged files are most useful for the following types of databases:
Databases that are supported by the fol lowing:
A logical volume manager that supports striping/RAID and dynamically extensible logical volume s
A file system that provides large, extensible files
Low end o r test databases
The Oracle-managed files feature is not intended to ease administration of systems that use raw dis ks. This feature provides better integration with operating system functionality for disk space allocation. Since there is no operati ng system support for allocation of raw disks (it is done manually), this feature cannot help. On the other hand, because Oracle-mana ged files require that you use the operating system file system (unlike raw disks), you lose control over how files are laid out on t he disks and thus, you lose some I/O tuning ability.
A logical volume manager (LVM) is a software package available with most operating systems. Sometimes it is called a logical dis k manager (LDM). It allows pieces of multiple physical disks to be combined into a single contiguous address space that appears as on e disk to higher layers of software. An LVM can make the logical volume have better capacity, performance, reliability, and availabil ity characteristics than any of the underlying physical disks. It uses techniques such as mirroring, striping, concatenation, and RAI D 5 to implement these characteristics.
Some LVMs allow the characteristics of a logical volume to be changed after it is crea ted, even while it is in use. The volume may be resized or mirrored, or it may be relocated to different physical disks.
A file system is a data structure built in side a contiguous disk address space. A file manager (FM) is a software package that manipulates file systems, but it is sometimes ca lled the file system. All operating systems have file managers. The primary task of a file manager is to allocate and deallocate disk space into files within a file system.
A file system allows the disk space to be allocated to a large number of files. Each f ile is made to appear as a contiguous address space to applications such as Oracle Database. The files may not actually be contiguous within the disk space of the file system. Files can be created, read, written, resized, and deleted. Each file has a name associated with it that is used to refer to the file.
A file system is commonly built on top of a logical volume constructed by an LVM. Thus all the files in a particular file system have the same performance, reliability, and availability characteristics inherited fro m the underlying logical volume. A file system is a single pool of storage that is shared by all the files in the file system. If a f ile system is out of space, then none of the files in that file system can grow. Space available in one file system does not affect s pace in another file system. However some LVM/FM combinations allow space to be added or removed from a file system.
An operat ing system can support multiple file systems. Multiple file systems are constructed to give different storage characteristics to diff erent files as well as to divide the available disk space into pools that do not affect each other.
Consider the following benefits of using Oracle-managed files:
They make the administration of the database easier.
< p>There is no need to invent filenames and define specific storage requirements. A consistent set of rules is used to name all releva nt files. The file system defines the characteristics of the storage and the pool where it is allocated.They reduce corruption caused by administrators specifying the wrong file.
Each Oracle-managed file and filename is unique. U sing the same file in two different databases is a common mistake that can cause very large down times and loss of committed transact ions. Using two different names that refer to the same file is another mistake that causes major corruptions.
They reduce wasted disk space consumed by obsolete files.
Oracle Database automatically removes old Oracle-managed files when they are no longer needed. Much disk space is wasted in large systems simply because no one is sure if a particular file is sti ll required. This also simplifies the administrative task of removing files that are no longer required on disk and prevents the mist ake of deleting the wrong file.
They simplify creation of test and development databases.
You can minimize the time spent making decisions regarding file structure and naming, and you have fewer file management tasks. You can focu s better on meeting the actual requirements of your test or development database.
Oracle-managed files m ake development of portable third-party tools easier.
Oracle-managed files eliminate the need to put operating system specific file names in SQL scripts.
Using Or acle-managed files does not eliminate any existing functionality. Existing databases are able to operate as they always have. New fil es can be created as managed files while old ones are administered in the old way. Thus, a database can have a mixture of Oracle-mana ged and unmanaged files.
The following initialization parameter s allow the database server to use the Oracle-managed files feature:
| Initialization Parameter | Description |
|---|---|
DB_CREATE_FILE_DEST |
Defines the location of the default file system directory where the database creates datafiles or tempfile
s when no file specification is given in the creation operation. Also used as the default file system directory for redo log and cont
rol files if DB_CREATE_ONLINE_LOG_DEST_n is not specified. |
DB_CREATE_ONLINE_LOG_DEST_n |
Defines the loca tion of the default file system directory for redo log files and control file creation when no file specification is given in the cre ation operation. You can use this initialization parameter multiple times, where n specifies a multiplexed copy of the redo log or control file. You can specify up to five multiplexed copies. |
DB_RECOVERY_FILE_DEST |
Defines the location of th e default file system directory where the database creates RMAN backups when no format option is used, archived logs when no other lo cal destination is configured, and flashback logs. Also used as the default file system directory for redo log and control files if < code>DB_CREATE_ONLINE_LOG_DEST_n is not specified. |
Th e file system directory specified by either of these parameters must already exist: the database does not create it. The directory mu st also have permissions to allow the database to create the files in it.
The default location is used whenever a location is not explicitly specified for the operation creating the file. The database creates the filename, and a file thus created is an Oracle -managed file.
Both of these initialization parameters are dynamic, and can be set using the ALTER SYSTEM or
Include the DB_CREATE_FILE_DEST initia
lization parameter in your initialization parameter file to identify the default location for the database server to create:
Datafiles
Tempfiles
Redo log files
Control files
Block change tracking files
You specify the name of a file syst
em directory that becomes the default location for the creation of the operating system files for these entities. The following examp
le sets /u01/oradata as the default directory to use when creating Oracle-managed files:
D B_CREATE_FILE_DEST = '/u01/oradata'
Include the DB_RECOVERY_FILE_DEST and DB_RECOVERY_FILE_DEST_SIZE parameters in
your initialization parameter file to identify the default location in which Oracle Database should create:
Redo log files
Control files
RMAN backups (datafile copies, control fi le copies, backup pieces, control file autobackups)
Archived logs
Flashback logs
You specify the name of file system directory that becomes the default location for creation of the operating system files for these entities. For example:
DB_RECOVERY_FILE_DEST = '/u01/oradata' DB_RECOVERY_F ILE_DEST_SIZE = 20G
Inclu
de the DB_CREATE_ONLINE_LOG_DEST_n initialization parameter in your initialization parameter file
to identify the default location for the database server to create:
Redo log files
Control files
You specify the name of a file system directory that becomes the default location for the crea tion of the operating system files for these entities. You can specify up to five multiplexed locations.
For the creation
of redo log files and control files only, this parameter overrides any default location specified in the DB_CREATE_FILE_DE
ST and DB_RECOVERY_FILE_DEST initialization parameters. If you do not specify a DB_CREATE_FILE_DEST
parameter, but you do specify the DB_CREATE_ONLINE_LOG_DEST_n parameter, then only redo log files
and control files can be created as Oracle-managed files.
It is recommended that you specify at least two parameters. For exam ple:
DB_CREATE_ONLINE_LOG_DEST_1 = '/u02/oradata' DB_CREATE_ONLINE_LOG_DEST_2 = '/u03/oradata'
This allows multiplexing, which provides greater fault-tolerance for the redo log and control file if one of the destinations fai ls.
I f you have met any of the following conditions, then Oracle Database creates Oracle-managed files for you, as appropriate, when no fi le specification is given in the creation operation:
You have included any of the DB_CREATE_FILE_D
EST, DB_REDOVERY_FILE_DEST, or DB_CREATE_ONLINE_LOG_DEST_n initialization para
meters in your initialization parameter file.
You have issued the ALTER SYSTEM statement to
dynamically set any of DB_RECOVERY_FILE_DEST, DB_CREATE_FILE_DEST, or DB_CREATE_ONLINE_LOG_DEST_n initialization parameters
You have issued the ALTER SESSION stat
ement to dynamically set any of the DB_CREATE_FILE_DEST, DB_RECOVERY_FILE_DEST, or DB_CREATE_ONLINE_L
OG_DEST_n initialization parameters.
If a statement that creates an Oracle-managed file finds an error or does not complete due to some failure, then any Oracle-managed files created by the statement are automatically de leted as part of the recovery of the error or failure. However, because of the large number of potential errors that can occur with f ile systems and storage subsystems, there can be situations where you must manually remove the files using operating system commands. When an Oracle-managed file is created, its filename is written to the alert file. This information can be used to find the file if it is necessary to manually remove the file.
The following topics are discussed in this section:
Creating Datafiles for Tablespaces Using Oracle-Manage d Files
Creating Tempfiles for Temporary Tablespaces Using Oracle-Managed Files< /a>
The filenames of Oracle-managed files comp ly with the Optimal Flexible Architecture (OFA) standard for file naming. The assigned names are intended to meet the following requi rements:
Database files are easily distinguishable from all other files.
Fi les of one database type are easily distinguishable from other database types.
Files are clearly associa ted with important attributes specific to the file type. For example, a datafile name may include the tablespace name to allow for ea sy association of datafile to tablespace, or an archived log name may include the thread, sequence, and creation date.
No two Oracle-managed files are given the same name. The name that is used for creation of an Oracle-managed file is constructed f rom three sources:
The default creation location
A file name template that is chosen based on the type of the file. The template also depends on the operating system platform and whether or not automatic stor age management is used.
A unique string created by the Oracle Database server or the operating system. T his ensures that file creation does not damage an existing file and that the file cannot be mistaken for some other file.
As a specific example, filenames for Oracle-managed files have the following format on a Solaris file system:
<destination_prefix>/o1_mf_%t_%u_.dbf
where:
<destination_pr
efix> is <destination_location>/<db_unique_name>/<datafile>
where:
<destination_location> is the loca
tion specified in DB_CREATE_FILE_DEST
<db_unique_name> is the
globally unique name (DB_UNIQUE_NAME initialization parameter) of the target database. If there is no DB_UNIQUE_N
AME parameter, then the DB_NAME initialization parameter value is used.
%t is the tablespace name.
%u is an eight-character string that guarantees uniqueness
For example, assume the following parameter settings:
DB_CREATE_FILE_DEST = /u01/oradata DB_UNIQUE_NAME = PAYROLL
Then an example datafile name would be:
/u01/oradata/PAYROLL/datafile/o1_mf_tbs1_ 2ixh90q_.dbf
Names for other file types are similar. Names on other platforms are also similar, subject to the constraint s of the naming rules of the platform.
The examples on the following pages use Oracle-managed file names as they might appear with a Solaris file system as an OMF destination.
|
|
The behavior of the
CREATE DATABASE statement for crea
ting database structures when using Oracle-managed files is discussed in this section.
At database creation, the control file is created in the files specified by the
CONTROL_FILES initialization parameter. If the CONTROL_FILES parameter is not set and at least one of the initial
ization parameters required for the creation of Oracle-managed files is set, then an Oracle-managed control file is created in the de
fault control file destinations. In order of precedence, the default destination is defined as follows:
One or more control files as specified in the DB_CREATE_ONLINE_LOG_DEST_n initialization parameter
. The file in the first directory is the primary control file. When DB_CREATE_ONLINE_LOG_DEST_n is
specified, the database does not create a control file in DB_CREATE_FILE_DEST or in DB_RECOVERY_FILE_DEST
(the flash recovery area).
If no value is specified for DB_CREATE_ONLINE_LOG_DEST_n, but values are set for both the DB_CREATE_FILE_DEST and DB_RECOVERY_FILE_DEST, then the dat
abase creates one control file in each location. The location specified in DB_CREATE_FILE_DEST is the primary control fi
le.
If a value is specified only for DB_CREATE_FILE_DEST, then the database creates one con
trol file in that location.
If a value is specified only for DB_RECOVERY_FILE_DEST, then th
e database creates one control file in that location.
If the CONTROL_FILES parameter is not set and non
e of these initialization parameters are set, then the Oracle Database default behavior is operating system dependent. At least one c
opy of a control file is created in an operating system dependent default location. Any copies of control files created in this fashi
on are not Oracle-managed files, and you must add a CONTROL_FILES initialization parameter to any initialization paramet
er file.
If the database creates an Oracle-managed control file, and if there is a server parameter file, then the database cr
eates a CONTROL_FILES initialization parameter entry in the server parameter file. If there is no server parameter file,
then you must manually include a CONTROL_FILES initialization parameter entry in the text initialization parameter file
.
The
LOGFILE clause is not required in the CREATE DATABASE statement, and omitting it provides a simple means o
f creating Oracle-managed redo log files. If the LOGFILE clause is omitted, then redo log files are created in the defau
lt redo log file destinations. In order of precedence, the default destination is defined as follows:
If
either the DB_CREATE_ONLINE_LOG_DEST_n is set, then the database creates a log file member in eac
h directory specified, up to the value of the MAXLOGMEMBERS initialization parameter.
If th
e DB_CREATE_ONLINE_LOG_DEST_n parameter is not set, but both the DB_CREATE_FILE_DEST
and DB_RECOVERY_FILE_DEST initialization parameters are set, then the database creates one Oracle-managed log file membe
r in each of those locations. The log file in the DB_CREATE_FILE_DEST destination is the first member.
If only the DB_CREATE_FILE_DEST initialization parameter is specified, then the database creates a log file
member in that location.
If only the DB_RECOVERY_FILE_DEST initialization parameter is spec
ified, then the database creates a log file member in that location.
The default size of an Oracle-managed redo log file is 100 MB.
Optionally, you can create Oracle-managed redo log files, and override default attributes, by including the LOGFILE clause of CREATE DATABASE, and none of the initialization parameters required fo
r creating Oracle-managed files are provided, then the CREATE DATABASE statement fails.
The SYSAUX DATAFILE clause is not required in the CREATE DATABASE statement,
and omitting it provides a simple means of creating Oracle-managed datafiles for the SYSTEM and SYSAUX tab
lespaces. If the DATAFILE clause is omitted, then one of the following actions occurs:
If <
code>DB_CREATE_FILE_DEST is set, then one Oracle-managed datafile for the SYSTEM tablespace and another for the <
code>SYSAUX tablespace are created in the DB_CREATE_FILE_DEST directory.
If DB
_CREATE_FILE_DEST is not set, then the database creates one SYSTEM, and one SYSAUX, tablespace dataf
ile whose name and size are operating system dependent. Any SYSTEM or SYSAUX tablespace datafile created in
this manner is not an Oracle-managed file.
The default size for an Oracle-managed datafile is 100 MB and the file i
s autoextensible. When autoextension is required, the database extends the datafile by its existing size or 100 MB, whichever is smal
ler. You can also explicitly specify the autoextensible unit using the NEXT parameter of the STORAGE clause
when you specify the datafile (in a CREATE or ALTER TABLESPACE operation).
Optionally, you can crea
te an Oracle-managed datafile for the SYSTEM or SYSAUX tablespace and override default attributes. This is
done by including the DATAFILE clause, omitting a filename, but specifying overriding attributes. When a filename is not
supplied and the DB_CREATE_FILE_DEST parameter is set, an Oracle-managed datafile for the SYSTEM or
SYSAUX tablespace is created in the DB_CREATE_FILE_DEST directory with the specified attributes being overridden.
However, if a filename is not supplied and the DB_CREATE_FILE_DEST parameter is not set, then the CREATE DATABASE
statement fails.
When overriding the default attributes of an Oracle-managed file, if a SIZE value is spe
cified but no AUTOEXTEND clause is specified, then the datafile is not autoextensible.
The DATAFILE
subclause of the UNDO TABLESPACE clause is optional and a filename is not required in the file specification. If
a filename is not supplied and the DB_CREATE_FILE_DEST parameter is set, then an Oracle-managed datafile is created in
the DB_CREATE_FILE_DEST directory. If DB_CREATE_FILE_DEST is not set, then the statement fails with a synta
x error.
The UNDO TABLESPACE clause itself is optional in the CREATE DATABASE statement. If it is no
t supplied, and automatic undo management mode is enabled, then a default undo tablespace named SYS_UNDOTBS is created a
nd a 10 MB datafile that is autoextensible is allocated as follows:
If DB_CREATE_FILE_DEST
is set, then an Oracle-managed datafile is created in the indicated directory.
If DB_CREATE_FILE_D
EST is not set, then the datafile location is operating system specific.
The TEMPFIL
E subclause is optional for the DEFAULT TEMPORARY TABLESPACE clause and a filename is not required in the file sp
ecification. If a filename is not supplied and the DB_CREATE_FILE_DEST parameter set, then an Oracle-managed tempfile is
created in the DB_CREATE_FILE_DEST directory. If DB_CREATE_FILE_DEST is not set, then the CREATE DAT
ABASE statement fails with a syntax error.
The DEFAULT TEMPORARY TABLESPACE clause itself is optional. If
it is not specified, then no default temporary tablespace is created.
The default size for an Oracle-managed tempfile is 100 M B and the file is autoextensible with an unlimited maximum size.
This section contains examples of the CREATE DATABAS
E statement when using the Oracle-managed files feature.
This example creates a database with the following Oracle-managed files:
A SYSTEM tablespace datafile in directory /u01/oradata that is 100 MB and autoextensible up to
an unlimited size.
A SYSAUX tablespace datafile in directory /u01/oradata tha
t is 100 MB and autoextensible up to an unlimited size. The tablespace is locally managed with automatic segment-space management.
Two online log groups with two members of 100 MB each, one each in /u02/oradata and
/u03/oradata.
If automatic undo management mode is enabled, then an undo tablespace datafi
le in directory /u01/oradata that is 10 MB and autoextensible up to an unlimited size. An undo tablespace named SY
S_UNDOTBS is created.
If no CONTROL_FILES initialization parameter is specified, the
n two control files, one each in /u02/oradata and /u03/oradata. The control file in /u02/oradata is the primary control file.
The following parameter settings relating to Oracle-managed files, are included in t he initialization parameter file:
DB_CREATE_FILE_DEST = '/u01/oradata' DB_CREATE_ONLINE_LOG_DEST_1 = '/ u02/oradata' DB_CREATE_ONLINE_LOG_DEST_2 = '/u03/oradata'
The following statement is issued at the SQL prompt:
SQL> CREATE DATABASE sample;
This example creates a database with the following Oracle-managed files:
A 100 MB SYSTEM tablespace datafile in directory /u01/oradata that is autoextensible up to an unlimite
d size.
A SYSAUX tablespace datafile in directory /u01/oradata that is 100 MB
and autoextensible up to an unlimited size. The tablespace is locally managed with automatic segment-space management.
Two redo log files of 100 MB each in directory /u01/oradata. They are not multiplexed.
An undo tablespace datafile in directory /u01/oradata that is 10 MB and autoextensible up to an unl
imited size. An undo tablespace named SYS_UNDOTBS is created.
A control file in /u01/
oradata.
In this example, it is assumed that:
No DB_CREATE_ONLINE_LOG_DEST
_n initialization parameters are specified in the initialization parameter file.
No CONTROL_FILES initialization parameter was specified in the initialization parameter file.
Automatic undo management mode is enabled.
The following statements are issued at the SQL prompt:
SQL> ALTER SYSTEM SET DB_CREATE_FILE_DEST = '/u01/oradata'; SQL> CREATE DATABASE sample2;
This database configuration is not recommended for a production database. The example illustrates how a very low-end database or simple t est database can easily be created. To better protect this database from failures, at least one more control file should be created a nd the redo log should be multiplexed.
In this example, the file size for the Oracle-managed files for the default temporary tablespace and undo tablespa ce are specified. A database with the following Oracle-managed files is created:
A 400 MB SYSTEM
code> tablespace datafile in directory /u01/oradata. Because SIZE is specified, the file in not autoextensi
ble.
A 200 MB SYSAUX tablespace datafile in directory /u01/oradata. Because
Two redo log groups with two members of 100 MB each, one each in directories /u02/oradata and /u03/oradata.
For the default temporary tablespace dflt_ts, a 10 MB tem
pfile in directory /u01/oradata. Because SIZE is specified, the file in not autoextensible.
For the undo tablespace undo_ts, a 10 MB datafile in directory /u01/oradata. Because SI
ZE is specified, the file in not autoextensible.
If no CONTROL_FILES initialization
parameter was specified, then two control files, one each in directories /u02/oradata and /u03/oradata. The
control file in /u02/oradata is the primary control file.
The following parameter settings are include d in the initialization parameter file:
DB_CREATE_FILE_DEST = '/u01/oradata' DB_CREATE_ONLINE_LOG_DEST_ 1 = '/u02/oradata' DB_CREATE_ONLINE_LOG_DEST_2 = '/u03/oradata'
The following statement is issued at the SQL prompt:
SQL> CREATE DATABASE sample3 DATAFILE SIZE 400M 2> SYSAUX DATAFILE SIZE 200M 3> DEFAULT TEMPOR ARY TABLESPACE dflt_ts TEMPFILE SIZE 10M 4> UNDO TABLESPACE undo_ts DATAFILE SIZE 10M;
The following statements that can create datafiles are relevant to the discussion in this section:
CREATE TABLESPACE
CREATE UNDO TABLESPACE
ALTER TABLESPACE ... ADD DATAFI
LE
When creating a tablespace, either a regular tablespace or an undo tablespace, the DATAFILE c
lause is optional. When you include the DATAFILE clause the filename is optional. If the DATAFILE clause or
filename is not provided, then the following rules apply:
If the DB_CREATE_FILE_DEST initi
alization parameter is specified, then an Oracle-managed datafile is created in the location specified by the parameter.
If the DB_CREATE_FILE_DEST initialization parameter is not specified, then the statement creating the d
atafile fails.
When you add a datafile to a tablespace with the ALTER TABLESPACE ... ADD DATAFILE state
ment the filename is optional. If the filename is not specified, then the same rules apply as discussed in the previous paragraph.
By default, an Oracle-managed datafile for a regular tablespace is 100 MB and is autoextensible with an unlimited maximum size.
However, if in your DATAFILE clause you override these defaults by specifying a SIZE value (and no AU
TOEXTEND clause), then the datafile is not autoextensible.
The following are some examples of creating tablespaces with Oracle-managed files.
The following example sets
the default location for datafile creations to /u01/oradata and then creates a tablespace tbs_1 with a data
file in that location. The datafile is 100 MB and is autoextensible with an unlimited maximum size.
SQL > ALTER SYSTEM SET DB_CREATE_FILE_DEST = '/u01/oradata'; SQL> CREATE TABLESPACE tbs_1;
This example creates a tablespace named tbs_2 with a datafile in the directory /u01/oradata. The datafile initial size is 400 MB, and because the SIZE clause is
specified, the datafile is not autoextensible.
The following parameter setting is included in the initialization parameter fil e:
DB_CREATE_FILE_DEST = '/u01/oradata'
The following statement is issued at the SQL prompt :
SQL> CREATE TABLESPACE tbs_2 DATAFILE SIZE 400M;
This example creates a tablespace named tbs_3 with
an autoextensible datafile in the directory /u01/oradata with a maximum size of 800 MB and an initial size of 100 MB:
p>
The following parameter setting is included in the initialization parameter file:
DB_CREATE_FILE_ DEST = '/u01/oradata'
The following statement is issued at the SQL prompt:
SQL> CREATE T ABLESPACE tbs_3 DATAFILE AUTOEXTEND ON MAXSIZE 800M;
The following example sets the default location for datafile creations to /u01/oradata
code> and then creates a tablespace named tbs_4 in that directory with two datafiles. Both datafiles have an initial siz
e of 200 MB, and because a SIZE value is specified, they are not autoextensible
SQL> AL TER SYSTEM SET DB_CREATE_FILE_DEST = '/u01/oradata'; SQL> CREATE TABLESPACE tbs_4 DATAFILE SIZE 200M SIZE 200M;
The following example creates an un
do tablespace named undotbs_1 with a datafile in the directory /u01/oradata. The datafile for the undo tabl
espace is 100 MB and is autoextensible with an unlimited maximum size.
The following parameter setting is included in the init ialization parameter file:
DB_CREATE_FILE_DEST = '/u01/oradata'
The following statement is issued at the SQL prompt:
SQL> CREATE UNDO TABLESPACE undotbs_1;
This example adds an Oracle-managed autoextensible da
tafile to the tbs_1 tablespace. The datafile has an initial size of 100 MB and a maximum size of 800 MB.
The foll owing parameter setting is included in the initialization parameter file:
DB_CREATE_FILE_DEST = '/u01/o radata'
The following statement is entered at the SQL prompt:
SQL> ALTER TABLESPACE tbs_ 1 ADD DATAFILE AUTOEXTEND ON MAXSIZE 800M;
|
See Also: Oracle Database SQL Reference for a description of theALTER TABLESPACE statement |
The following statements that create tempfiles are relevant to the discussion in this section:
CREATE TEMPORARY TABLESPACE
ALTER TABLESPACE ... ADD TEMPFILE
When creating a temporary tablespace the TEMPFILE clause is optional. If you include the TEMPFILE cl
ause, then the filename is optional. If the TEMPFILE clause or filename is not provided, then the following rules apply:
If the DB_CREATE_FILE_DEST initialization parameter is specified, then an Oracle-managed t
empfile is created in the location specified by the parameter.
If the DB_CREATE_FILE_DEST i
nitialization parameter is not specified, then the statement creating the tempfile fails.
When you add a tempfile to
a tablespace with the ALTER TABLESPACE ... ADD TEMPFILE statement the filename is optional. If the filename is not spec
ified, then the same rules apply as discussed in the previous paragraph.
When overriding the default attributes of an Oracle-m
anaged file, if a SIZE value is specified but no AUTOEXTEND clause is specified, then the datafile is n
ot autoextensible.
|
See Also: "Specifying the Default Temporary Tablespace Tempfile at Database Creation" |
The following example
creates a log group with a member in /u01/oradata and another member in /u02/oradata. The size of each log
file is 100 MB.
The following parameter settings are included in the initialization parameter file:
DB_CREATE_ONLINE_LOG_DEST_1 = '/u01/oradata' DB_CREATE_ONLINE_LOG_DEST_2 = '/u02/oradata'
The following statement is issued at the SQL prompt:
SQL> ALTER DATABASE ADD LOGFILE;
If you previously created a control file
specifying RESETLOGS and either did not specify filenames or specified nonexistent filenames, then the database creates
redo log files for you when you issue the ALTER DATABASE OPEN RESETLOGS statement. The rules for determining the directo
ries in which to store redo log files, when none are specified in the control file, are the same as those discussed in "Specifying Redo Log Files at Database Creation".
Archived logs are created in the DB_RECOVERY_FILE_DEST
location when:
The ARC or LGWR background process archives an online r
edo log or
An ALTER SYSTEM ARHIVE LOG CURRENT statement is issued.
For exa mple, assume that the following parameter settings are included in the initialization parameter file:
D B_RECOVERY_FILE_DEST_SIZE = 20G DB_RECOVERY_FILE_DEST = '/u01/oradata' LOG_ARCHIVE_DEST_1 = 'LOCATION=USE_DB_RECOVERY_FI LE_DEST'
The filenames of Oracle-managed files are accepted in SQL statements w
herever a filename is used to identify an existing file. These filenames, like other filenames, are stored in the control file and, i
f using Recovery Manager (RMAN) for backup and recovery, in the RMAN catalog. They are visible in all of the usual fixed and dynamic
performance views that are available for monitoring datafiles and tempfiles (for example, V$DATAFILE or DBA_DATA_F
ILES).
The following are some examples of statements using database-generated filenames:
SQL> ALTER DATABASE 2> RENAME FILE '/u01/oradata/mydb/datafile/o1_mf_tbs01_ziw3bopb_.dbf' 3> TO '/u01/oradata/mydb/tbs0 101.dbf'; SQL> ALTER DATABASE 2> DROP LOGFILE '/u01/oradata/mydb/onlinelog/o1_mf_1_wo94n2xi_.log'; SQL> ALTER TABLE emp 2> ALLOCATE EXTENT 3> (DATAFILE '/u01/oradata/mydb/datafile/o1_mf_tbs1_2ixfh90q_.dbf');
You can backup and re store Oracle-managed datafiles, tempfiles, and control files as you would corresponding non Oracle-managed files. Using database-gene rated filenames does not impact the use of logical backup files such as export files. This is particularly important for tablespace p oint-in-time recovery (TSPITR) and transportable tablespace export files.
There are some cases where Oracle-managed files beha ve differently. These are discussed in the sections that follow.
Unlike files that are not managed by the database, when an Oracle-managed datafile or tempfile is dropped, the filename is removed from the control file and the file is automatic ally deleted from the file system. The statements that delete Oracle-managed files when they are dropped are:
DROP TABLESPACE
ALTER DATABASE TEMPFILE<
/code> ... DROP
When an Oracle-managed redo log file is dropped its Oracle-managed files are deleted. You specify the group or members to b e dropped. The following statements drop and delete redo log files:
ALTER DATABASE DROP LOGFILE
ALTER DATABASE DROP <
code>LOGFILE MEMBER
The following statements are used to rename files:
ALTER DATABASE RENAME FILE
ALTER
TABLESPACE ... RENAME DATAFILE
These statements do not actually rename the files on the operating system, but rather, the names in the control file are changed. If the old file is an Oracle-managed file and it exists , then it is deleted. You must specify each filename using the conventions for filenames on your operating system when you issue this statement.
The datafiles, control files, and redo log files in a s tandby database can be managed by the database. This is independent of whether Oracle-managed files are used on the primary database.
When recovery of a standby database encounters redo for the creation of a datafile, if the datafile is an Oracle-managed file , then the recovery process creates an empty file in the local default file system location. This allows the redo for the new file to be applied immediately without any human intervention.
When recovery of a standby database encounters redo for the deletion o
f a tablespace, it deletes any Oracle-managed datafiles in the local file system. Note that this is independent of the INCLUDIN
G DATAFILES option issued at the primary database.
This section further demonstrates the use of Oracle-managed files by presenting scenarios of their use.
In this scenario, a DBA creates a database where the datafile s and redo log files are created in separate directories. The redo log files and control files are multiplexed. The database uses an undo tablespace, and has a default temporary tablespace. The following are tasks involved with creating and maintaining this database .
Setting the initialization parameters
The DBA includes three generic file creation defau lts in the initialization parameter file before creating the database. Automatic undo management mode is also specified.
DB_CREATE_FILE_DEST = '/u01/oradata' DB_CREATE_ONLINE_LOG_DEST_1 = '/u02/oradata' DB_CREATE_ONLINE_LOG_DEST_2 = '/u 03/oradata' UNDO_MANAGEMENT = AUTO
The DB_CREATE_FILE_DEST parameter sets the default file system directory
for the datafiles and tempfiles.
The DB_CREATE_ONLINE_LOG_DEST_1 and DB_CREATE_ONLINE_LOG_DEST_2 par
ameters set the default file system directories for redo log file and control file creation. Each redo log file and control file is m
ultiplexed across the two directories.
Creating a database
Once the initialization parameters are set, the da tabase can be created by using this statement:
SQL> CREATE DATABASE sample 2> DEFAULT TEMPORARY TABLESPACE dflttmp;
Because a DATAFILE clause is not present and the DB_CREATE_FILE_DEST initi
alization parameter is set, the SYSTEM tablespace datafile is created in the default file system (/u01/oradata in this scenario). The filename is uniquely generated by the database. The file is autoextensible with an initial size of 100 MB
and an unlimited maximum size. The file is an Oracle-managed file. A similar datafile is created for the SYSAUX tablespa
ce.
Because a LOGFILE clause is not present, two redo log groups are created. Each log group has two members, wit
h one member in the DB_CREATE_ONLINE_LOG_DEST_1 location and the other member in the DB_CREATE_ONLINE_LOG_DEST_2
code> location. The filenames are uniquely generated by the database. The log files are created with a size of 100 MB. The log file m
embers are Oracle-managed files.
Similarly, because the CONTROL_FILES initialization parameter is not present, an
d two DB_CREATE_ONLINE_LOG_DEST_n initialization parameters are specified, two control files are c
reated. The control file located in the DB_CREATE_ONLINE_LOG_DEST_1 location is the primary control file; the control fi
le located in the DB_CREATE_ONLINE_LOG_DEST_2 location is a multiplexed copy. The filenames are uniquely generated by th
e database. They are Oracle-managed files. Assuming there is a server parameter file, a CONTROL_FILES initialization par
ameter is generated.
Automatic undo management mode is specified, but because an undo tablespace is not specified and the SYS_UNDOTBS is created in
the directory specified by DB_CREATE_FILE_DEST. The datafile is a 10 MB datafile that is autoextensible. It is an Oracle
-managed file.
Lastly, a default temporary tablespace named dflttmp is specified. Because DB_CREATE_FILE_DE
ST is included in the parameter file, the tempfile for dflttmp is created in the directory specified by that para
meter. The tempfile is 100 MB and is autoextensible with an unlimited maximum size. It is an Oracle-managed file.
The resultan t file tree, with generated filenames, is as follows:
/u01
/oradata
/SAMPLE
/datafile
/o1_mf_system_cmr7t30p_.dbf
/o1_mf_sysaux_cmr7t88p_.dbf
/o1_
mf_sys_undotbs_2ixfh90q_.dbf
/o1_mf_dflttmp_157se6ff_.tmp
/u02
/oradata
/SAMPLE
/on
linelog
/o1_mf_1_0orrm31z_.log
/o1_mf_2_2xyz16am_.log
/controlfile
/o1_mf_cmr7t30p_.ctl
/u03
/oradata
/SAMPLE
/onlinelog
/o1_mf_1_ixfvm8w9_.l
og
/o1_mf_2_q89tmp28_.log
/controlfile
/o1_mf_x1sr8t36_.ctl
The in ternally generated filenames can be seen when selecting from the usual views. For example:
SQL> SELE CT NAME FROM V$DATAFILE; NAME ---------------------------------------------------- /u01/oradata/SAMPLE/datafile/o1_mf_system_cmr7t30 p_.dbf /u01/oradata/SAMPLE/datafile/o1_mf_sysaux_cmr7t88p_.dbf /u01/oradata/SAMPLE/datafile/o1_mf_sys_undotbs_2ixfh90q_.dbf 3 rows s elected
The name is also printed to the alert file when the file is created.
Managing control files
The control file was created when generating the database, and a CONTROL_FILES initialization parameter was added to
the parameter file. If needed, then the DBA can re-create the control file or build a new one for the database using the CREATE CONTROLFILE statement.
The correct O
racle-managed filenames must be used in the DATAFILE and LOGFILE clauses. The ALTER DATABASE BACKUP C
ONTROLFILE TO TRACE statement generates a script with the correct filenames. Alternatively, the filenames can be found by sele
cting from the V$DATAFILE, V$TEMPFILE, and V$LOGFILE views. The following example re-creates t
he control file for the sample database:
CREATE CONTROLFILE REUSE
DATABASE sample
LOGFILE
GROU
P 1('/u02/oradata/SAMPLE/onlinelog/o1_mf_1_0orrm31z_.log',
'/u03/oradata/SAMPLE/onlinelog/o1_mf_1_ixfvm8w9_.log'),
GROUP 2('/u02/oradata/SAMPLE/onlinelog/o1_mf_2_2xyz16am_.log',
'/u03/oradata/SAMPLE/onlinelog/o1_mf_2_q89tmp28_.log')
N
ORESETLOGS
DATAFILE '/u01/oradata/SAMPLE/datafile/o1_mf_system_cmr7t30p_.dbf',
'/u01/oradata/SAMPLE/datafile/o1_mf_sysau
x_cmr7t88p_.dbf',
'/u01/oradata/SAMPLE/datafile/o1_mf_sys_undotbs_2ixfh90q_.dbf',
'/u01/oradata/SAMPLE/datafile
/o1_mf_dflttmp_157se6ff_.tmp'
MAXLOGFILES 5
MAXLOGHISTORY 100
MAXDATAFILES 10
MAXINSTANCES 2
ARCHIVELOG;
The co
ntrol file created by this statement is located as specified by the CONTROL_FILES initialization parameter that was gene
rated when the database was created. The REUSE clause causes any existing files to be overwritten.
Mana ging the redo log
To create a new group of redo log files, the DBA can use the
ALTER DATABASE ADD LOGFILE statement. The following statement adds a log file with a member in the DB_CREATE_ONLINE_LOG_
DEST_1 location and a member in the DB_CREATE_ONLINE_LOG_DEST_2 location. These files are Oracle-managed files.
p>
SQL> ALTER DATABASE ADD LOGFILE;
Log file members continue to be added and dropped by spe cifying complete filenames.
The GROUP clause can be used to drop a log group. In the following example the operat
ing system file associated with each Oracle-managed log file member is automatically deleted.
SQL> A LTER DATABASE DROP LOGFILE GROUP 3;
The de
fault storage for all datafiles for future tablespace creations in the sample database is the location specified by the
DB_CREATE_FILE_DEST initialization parameter (/u01/oradata in this scenario). Any datafiles for which no fi
lename is specified, are created in the file system specified by the initialization parameter DB_CREATE_FILE_DEST. For e
xample:
SQL> CREATE TABLESPACE tbs_1;
The preceding statement creates a tablespace whose
storage is in /u01/oradata. A datafile is created with an initial of 100 MB and it is autoextensible with an unlimited
maximum size. The datafile is an Oracle-managed file.
When the tablespace is dropped, the Oracle-managed files for the tablesp ace are automatically removed. The following statement drops the tablespace and all the Oracle-managed files used for its storage:
SQL> DROP TABLESPACE tbs_1;
Once the first datafile is full, the database does not automat
ically create a new datafile. More space can be added to the tablespace by adding another Oracle-managed datafile. The following stat
ement adds another datafile in the location specified by DB_CREATE_FILE_DEST:
SQL> ALTE R TABLESPACE tbs_1 ADD DATAFILE;
The default file system can be changed by changing the initialization parameter. This do es not change any existing datafiles. It only affects future creations. This can be done dynamically using the following statement: p>
SQL> ALTER SYSTEM SET DB_CREATE_FILE_DEST='/u04/oradata';
Archiving redo inform ation
Archiving of redo log files is no different for Oracle-managed files, than it is for unmanaged files. A file system loca
tion for the archived log files can be specified using the LOG_ARCHIVE_DEST_n initialization param
eters. The filenames are formed based on the LOG_ARCHIVE_FORMAT parameter or its default. The archived logs are not Orac
le-managed files
Backup, restore, and recover
Since an Oracle-managed file is compatible with standard operat ing system files, you can use operating system utilities to backup or restore Oracle-managed files. All existing methods for backing up, restoring, and recovering the database work for Oracle-managed files.
In this scenario, a DBA creates a database where the control files and redo log files are multiplexed. Archived logs and RMAN backups are created in th e flash recovery area. The following tasks are involved in creating and maintaining this database:
The DBA includes the following generic file creation defaults:
DB_CREATE_FILE_DEST = '/u01/oradata' DB_RECOVERY_FILE_DEST_SIZE = 10G DB_RECOVERY_FILE_DEST = '/u02/oradata' LOG_ARCHIVE_DEST_ 1 = 'LOCATION = USE_DB_RECOVERY_FILE_DEST'
The DB_CREATE_FILE_DEST parameter sets the default file system di
rectory for datafiles, tempfiles, control files, and redo logs.
The DB_RECOVERY_FILE_DEST parameter sets the defa
ult file system directory for control files, redo logs, and RMAN backups.
The LOG_ARCHIVE_DEST_1 configuration '<
code>LOCATION=USE_DB_RECOVERY_FILE_DEST' redirects archived logs to the DB_RECOVERY_FILE_DEST location.
Th
e DB_CREATE_FILE_DEST and DB_RECOVERY_FILE_DEST parameters set the default directory for log file and contr
ol file creation. Each redo log and control file is multiplexed across the two directories.
Creating a database
< /li>Managing control files
Managing the redo log
Tasks 2, 3, 4, and 5 are the same as in Scenario 1, except that the control files and redo logs are multi
plexed across the DB_CREATE_FILE_DEST and DB_RECOVERY_FILE_DEST locations.
Archiving redo log information
Archiving online logs is no different for Oracle-managed files than it is for unmanaged files. The archived lo
gs are created in DB_RECOVERY_FILE_DEST and are Oracle-managed files.
Backup, restore, and recover
An Oracle-managed file is compatible with standard operating system files, so you can use operating system utilities to backup or
restore Oracle-managed files. All existing methods for backing up, restoring, and recovering the database work for Oracle-managed fil
es. When no format option is specified, all disk backups by RMAN are created in the DB_RECOVERY_FILE_DEST location. The
backups are Oracle-managed files.
Assume in this case that an existing database does not have any Oracle-managed
files, but the DBA would like to create new tablespaces with Oracle-managed files and locate them in directory /u03/oradata.
Setting the initialization parameters
To allow automatic datafile creation, set the
DB_CREATE_FILE_DEST initialization parameter to the file system directory in which to create the datafiles. This can be
done dynamically as follows:
SQL> ALTER SYSTEM SET DB_CREATE_FILE_DEST = '/u03/oradata';
Creating tablespaces
Once DB_CREATE_FILE_DEST is set, the DATAFILE clause can be omitted
from a CREATE TABLESPACE statement. The datafile is created in the location specified by DB_CREATE_FILE_DEST by default. For example:
SQL> CREATE TABLESPACE tbs_2;
When the tbs_2 tab
lespace is dropped, its datafiles are automatically deleted.