Tablespace creation is a snap with Oracle Managed Files
Oracle Tips by Burleson ConsultingSeptember 5, 2002
Oracle9i introduces a new feature that simplifies tablespace creation. This new feature, Oracle Managed Files (OMF), makes life easier for Oracle DBAs by removing the tedium from creating and managing Oracle data files.Before OMF, Oracle DBAs had to take several manual steps before adding a data file. A simple example of these steps follows, but note that you must know the location of the directory that contains the Oracle data files:create tablespace users_02add ‘c:oracleoradatadiogenesusers02.dbf’size 20m ;In this example, you must know the following information to create a new tablespace:
The proper file location
The proper filename
The proper file size
Prior to OMF, you needed to execute queries to get the filenames and file locations, interrogating the dba_data_files view to find the appropriate location for a new data file, as shown in Listing A..
SQL> select file_name from dba_data_files; FILE_NAME
Using the output of the previous query, the C:OracleOradataDiogenes directory is the proper location to add a new Oracle data file.Viewing tablespace information was also cumbersome. You had to write a query to join dba_tablespaces with dba_data_files to get the file sizes, as shown in Listing B.
column file_name format a40column tablespace format a15column bytes format 999,999,999
Oracle Corporation recognized that this was a lot of work just to add a data file, so it developed OMF to reduce the complexity involved in specifying all the detailed file information. Some of the benefits of OMF are:
Easier Oracle file management—All files are placed into the proper OS directory.
Easier third-party application integration—Third-party apps don’t have to be aware of OS-specific environments.
Reduction of Oracle file management errors—No risk of human error.
Enforcement of Optimal Flexible Architecture (OFA) standards—OMF will comply with the OFA standards for filename and file locations.
Default file sizes—OMF allows files to have standard, uniform sizes.
File size and naming standardsBefore OMF appeared, Oracle DBAs could create data files with any name they chose. While the file suffix was normally .dbf, the Oracle DBA was free to create any type of filename desired. For example, the following is a silly but legitimate Oracle command:create tablespace new_tsdatafile c:windowsProgram Filesautoexec.bat’ size 300m;As we can see from this example, allowing the developer to choose filenames and locations can have disastrous effects. When using OMF, files typically have a default size of 100 MB and are named using a format mask for the filename.Listing D presents the format mask that OMF uses when creating new data files.
u% is a unique 8 digit code, g% is the logfile group number, %t is the tablespace name:Controlfiles ora_%u.ctlRedo Log Files ora_%g_%u.logDatafiles ora_%t_%u.dbfTemporary Datafiles ora_%t_%u.tmp
u% is a unique 8 digit code, g% is the logfile group number, %t is the tablespace name: Controlfiles ora_%u.ctl Redo Log Files ora_%g_%u.log Datafiles ora_%t_%u.dbf Temporary Datafiles ora_%t_%u.tmp
sidebarend–>With OMF, tablespace creation syntax is simplified, and it becomes easy to allocate a new tablespace:SQL> create tablespace new_ts;Tablespace created.Now that the benefits of OMF are apparent, I’ll examine the process for installing and using it. To use OMF, you must set the db_create_file_dest parameter. Once this is set, OMF is installed and tablespace creation becomes super easy:SQL> alter system set db_create_file_dest=’c:oracleoradatadiogenes;System altered.SQL> create tablespace test;Tablespace created.Now I’ll look at the filename, directory name, and size for the file that was created as a result of this command in Listing E.
C:ORACLEORADATADIOGENESORA_TEST_YNJ2K200.DBF TEST 104,857,600
Listing E shows that OMF created the file as follows:
File size—100 MB
Note that the OMF default file size is 100 MB, and the file size can’t be overridden at the command line. You can specify the file size only if you bypass OMF and specify the filename and location in the data file clause.
Oracle enhanced the Oracle9i alert log to display messages about tablespace creation and data file creation. To see the alert log, you must go to the Background_dump_destination directory. You get the location of this directory by issuing the command in Listing F.