Creating a Database with the CREATE DATABASE Statement
Using the CREATE DATBASE SQL statement is a more manual approach to creating a database. If you use the CREATE DATABASE statement, you must complete additional actions before you have an operational database. These actions include building views on the data dictionary tables and installing standard PL/SQL packages. You perform these actions by running prepared scripts.
If you have existing scripts for creating your database, consider editing those scripts to take advantage of new Oracle Database features.
The instructions in this section apply to single-instance installations only. Refer to the Oracle Real Application Clusters (Oracle RAC) installation guide for your platform for instructions for creating an Oracle RAC database.
Note:
Single-instance does not mean that only one Oracle instance can reside on a single host computer. In fact, multiple Oracle instances (and their associated databases) can run on a single host computer. A single-instance database is a database that is accessed by only one Oracle instance, as opposed to an Oracle RAC database, which is accessed concurrently by multiple Oracle instances on multiple nodes. See Oracle Real Application Clusters Administration and Deployment Guide for more information on Oracle RAC.
Complete the following steps to create a database with the CREATE DATABASE statement. The examples create a database named mynewdb.
Step 1: Specify an Instance Identifier (SID)
Step 2: Ensure That the Required Environment Variables Are Set
Step 3: Choose a Database Administrator Authentication Method
Step 4: Create the Initialization Parameter File
Step 5: (Windows Only) Create an Instance
Step 6: Connect to the Instance
Step 7: Create a Server Parameter File
Step 9: Issue the CREATE DATABASE Statement
Step 10: Create Additional Tablespaces
Step 11: Run Scripts to Build Data Dictionary Views
Step 12: Run Scripts to Install Additional Options (Optional)
Step 13: Back Up the Database.
Step 14: (Optional) Enable Automatic Instance Startup
Tip:
If you are using Oracle Automatic Storage Management (ASM) to manage your disk storage, you must start the ASM instance and configure your disk groups before performing these steps. For information about Automatic Storage Management, see Oracle Database Storage Administrator's Guide.
Step 1: Specify an Instance Identifier (SID)
Decide on a unique Oracle system identifier (SID) for your instance, open a command window, and set the ORACLE_SID environment variable. Use this command windows for the subsequent steps.
ORACLE_SID is used to distinguish this instance from other Oracle Database instances that you may create later and run concurrently on the same host computer. The maximum number of characters for ORACLE_SID is 12, and only letters and numeric digits are permitted. On some platforms, the SID is case-sensitive.
Note:
It is common practice to set the SID to be equal to the database name. The maximum number of characters for the database name is eight. For more information, see the discussion of the DB_NAME initialization parameter in Oracle Database Reference.
The following example for UNIX and Linux operating systems sets the SID for the instance that you will connect to in Step 6: Connect to the Instance:
- Bourne, Bash, or Korn shell:
- ORACLE_SID=mynewdb
- export ORACLE_SID
- C shell:
- setenv ORACLE_SID mynewdb
The following example sets the SID for the Windows operating system:
set ORACLE_SID=mynewdb
See Also:
Oracle Database Concepts for background information about the Oracle instance
Step 2: Ensure That the Required Environment Variables Are Set
Depending on your platform, before you can start SQL*Plus (as required in Step 6: Connect to the Instance), you may have to set environment variables, or at least verify that they are set properly.
For example, on most platforms, ORACLE_SID and ORACLE_HOME must be set. In addition, it is advisable to set the PATH variable to include the ORACLE_HOME/bin directory. On the UNIX and Linux platforms, you must set these environment variables manually. On the Windows platform, OUI automatically assigns values to ORACLE_HOME and ORACLE_SID in the Windows registry. If you did not create a database upon installation, OUI does not set ORACLE_SID in the registry, and you will have to set the ORACLE_SID environment variable when you create your database later.
Step 3: Choose a Database Administrator Authentication Method
You must be authenticated and granted appropriate system privileges in order to create a database. You can authenticate as an administrator with the required privileges in the following ways:
- With a password file
- With operating system authentication
In this step, you decide on an authentication method.
If you decide to authenticate with a password file, create the password file as described in "Creating and Maintaining a Password File". If you decide to authenticate with operating system authentication, ensure that you log in to the host computer with a user account that is a member of the appropriate operating system user group. On the UNIX and Linux platforms, for example, this is typically the dba user group. On the Windows platform, the user installing the Oracle software is automatically placed in the required user group.
See Also:
- "About Database Administrator Security and Privileges"
- "Database Administrator Authentication" for information about password files and operating system authentication
Step 4: Create the Initialization Parameter File
When an Oracle instance starts, it reads an initialization parameter file. This file can be a text file, which can be created and modified with a text editor, or a binary file, which is created and dynamically modified by the database. The binary file, which is preferred, is called a server parameter file. In this step, you create a text initialization parameter file. In a later step, you create a server parameter file from the text file.
One way to create the text initialization parameter file is to edit the sample presented in "Sample Initialization Parameter File".
For convenience, store your initialization parameter file in the Oracle Database default location, using the default file name. Then when you start your database, it will not be necessary to specify the PFILE clause of the STARTUP command, because Oracle Database automatically looks in the default location for the initialization parameter file.
For more information about initialization parameters and the initialization parameter file, including the default name and location of the initialization parameter file for your platform, see "About Initialization Parameters and Initialization Parameter Files".
See Also:
Oracle Database Reference for details on all initialization parameters
Step 5: (Windows Only) Create an Instance
On the Windows platform, before you can connect to an instance, you must manually create it if it does not already exist. The ORADIM command creates an Oracle instance by creating a new Windows service.
To create an instance:
- Enter the following command at a Windows command prompt:
- oradim -NEW -SID sid -STARTMODE MANUAL -PFILE pfile
where sid is the desired SID (for example mynewdb) and pfile is the full path to the text initialization parameter file. This command creates the instance but does not start it.
Warning:
Do not set the -STARTMODE argument to AUTO at this point, because this causes the new instance to start and attempt to mount the database, which does not exist yet. You can change this parameter to AUTO, if desired, in Step 14.
See the section "Using ORADIM to Administer an Oracle Database Instance" in Oracle Database Platform Guide for Microsoft Windows for more information on the ORADIM command.
Step 6: Connect to the Instance
Start SQL*Plus and connect to your Oracle Database instance with the SYSDBA system privilege.
- To authenticate with a password file, enter the following commands, and then enter the SYS password when prompted:
- $ sqlplus /nolog
- SQL> CONNECT SYS AS SYSDBA
- To authenticate with operating system authentication, enter the following commands:
- $ sqlplus /nolog
- SQL> CONNECT / AS SYSDBA
SQL*Plus outputs the following message:
Connected to an idle instance.
Note:
SQL*Plus may output a message similar to the following:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP and Data Mining options
If so, this means that the instance is already started. You may have connected to the wrong instance. Exit SQL*Plus with the EXIT command, check that ORACLE_SID is set properly, and repeat this step.
Step 7: Create a Server Parameter File
The server parameter file enables you to change initialization parameters with the ALTER SYSTEM command and persist the changes across a database shutdown and startup. You create the server parameter file from your edited text initialization file.
The following SQL*Plus command reads the text initialization parameter file (PFILE) with the default name from the default location, creates a server parameter file (SPFILE) from the text initialization parameter file, and writes the SPFILE to the default location with the default SPFILE name.
CREATE SPFILE FROM PFILE;
You can also supply the file name and path for both the PFILE and SPFILE if you are not using default names and locations.
Tip:
The database must be restarted before the server parameter file takes effect.
Note:
Although creating a server parameter file is optional at this point, it is recommended. If you do not create a server parameter file, the instance continues to read the text initialization parameter file whenever it starts.
Important—If you are using Oracle-managed files and your initialization parameter file does not contain the CONTROL_FILES parameter, you must create a server parameter file now so the database can save the names and location of the control files that it creates during the CREATE DATABASE statement. See "Specifying Oracle-Managed Files at Database Creation" for more information.
See Also:
- "Managing Initialization Parameters Using a Server Parameter File"
- Oracle Database SQL Language Reference for more information on the CREATE SPFILE command
Step 8: Start the Instance
Start an instance without mounting a database. Typically, you do this only during database creation or while performing maintenance on the database. Use the STARTUP command with the NOMOUNTclause. In this example, because the initialization parameter file or server parameter file is stored in the default location, you are not required to specify the PFILE clause:
STARTUP NOMOUNT
At this point, the instance memory is allocated and its processes are started. The database itself does not yet exist.
See Also:
- Oracle Database Concepts for an overview of the Oracle instance.
- "Managing Initialization Parameters Using a Server Parameter File"
- Chapter 3, "Starting Up and Shutting Down", to learn how to use the STARTUP command
Step 9: Issue the CREATE DATABASE Statement
To create the new database, use the CREATE DATABASE statement.
Example 1
The following statement creates database mynewdb. This database name must agree with the DB_NAME parameter in the initialization parameter file. This example assumes the following:
- The initialization parameter file specifies the number and location of control files with the CONTROL_FILES parameter.
- The directory /u01/app/oracle/oradata/mynewdb exists.
CREATE DATABASE mynewdb
USER SYS IDENTIFIED BY sys_password
USER SYSTEM IDENTIFIED BY system_password
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/mynewdb/redo01.log') SIZE 100M,
GROUP 2 ('/u01/app/oracle/oradata/mynewdb/redo02.log') SIZE 100M,
GROUP 3 ('/u01/app/oracle/oradata/mynewdb/redo03.log') SIZE 100M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/mynewdb/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u01/app/oracle/oradata/mynewdb/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/app/oracle/oradata/mynewdb/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/mynewdb/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs
DATAFILE '/u01/app/oracle/oradata/mynewdb/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
A database is created with the following characteristics:
- The database is named mynewdb. Its global database name is mynewdb.us.oracle.com, where the domain portion (us.oracle.com) is taken from the initialization file. See "Determining the Global Database Name".
- Three control files are created as specified by the CONTROL_FILES initialization parameter, which was set before database creation in the initialization parameter file. See "Sample Initialization Parameter File" and "Specifying Control Files".
- The passwords for user accounts SYS and SYSTEM are set to the values that you specified. Beginning with Release 11g, the passwords are case-sensitive. The two clauses that specify the passwords for SYS and SYSTEM are not mandatory in this release of Oracle Database. However, if you specify either clause, you must specify both clauses. For further information about the use of these clauses, see "Protecting Your Database: Specifying Passwords for Users SYS and SYSTEM".
- The new database has three redo log files as specified in the LOGFILE clause. MAXLOGFILES, MAXLOGMEMBERS, and MAXLOGHISTORY define limits for the redo log. See Chapter 10, "Managing the Redo Log".
- MAXDATAFILES specifies the maximum number of datafiles that can be open in the database. This number affects the initial sizing of the control file.
Note:
You can set several limits during database creation. Some of these limits are limited by and affected by operating system limits. For example, if you set MAXDATAFILES, Oracle Database allocates enough space in the control file to store MAXDATAFILES filenames, even if the database has only one datafile initially. However, because the maximum control file size is limited and operating system dependent, you might not be able to set all CREATE DATABASE parameters at their theoretical maximums.
For more information about setting limits during database creation, see the Oracle Database SQL Language Reference and your operating system–specific Oracle documentation.
- The US7ASCII character set is used to store data in this database.
- The AL16UTF16 character set is specified as the NATIONAL CHARACTER SET, used to store data in columns specifically defined as NCHAR, NCLOB, or NVARCHAR2.
- The SYSTEM tablespace, consisting of the operating system file /u01/app/oracle/oradata/mynewdb/system01.dbf is created as specified by the DATAFILE clause. If a file with that name already exists, it is overwritten.
- The SYSTEM tablespace is created as a locally managed tablespace. See "Creating a Locally Managed SYSTEM Tablespace".
- A SYSAUX tablespace is created, consisting of the operating system file /u01/app/oracle/oradata/mynewdb/sysaux01.dbf as specified in the SYSAUX DATAFILE clause. See "About the SYSAUX Tablespace".
- The DEFAULT TABLESPACE clause creates and names a default permanent tablespace for this database.
- The DEFAULT TEMPORARY TABLESPACE clause creates and names a default temporary tablespace for this database. See "Creating a Default Temporary Tablespace".
- The UNDO TABLESPACE clause creates and names an undo tablespace that is used to store undo data for this database if you have specified UNDO_MANAGEMENT=AUTO in the initialization parameter file. If you omit this parameter, it defaults to AUTO. See "Using Automatic Undo Management: Creating an Undo Tablespace".
- Redo log files will not initially be archived, because the ARCHIVELOG clause is not specified in this CREATE DATABASE statement. This is customary during database creation. You can later use an ALTER DATABASE statement to switch to ARCHIVELOG mode. The initialization parameters in the initialization parameter file for mynewdb relating to archiving are LOG_ARCHIVE_DEST_1 and LOG_ARCHIVE_FORMAT. See Chapter 11, "Managing Archived Redo Logs".
Tips:
- Ensure that all directories used in the CREATE DATABASE statement exist. The CREATE DATABASE statement does not create directories.
- If you are not using Oracle-managed files, every tablespace clause must include a DATAFILE or TEMPFILE clause.
- If database creation fails, you can look at the alert log to determine the reason for the failure and to determine corrective actions. See "Viewing the Alert Log". If you receive an error message that contains a process number, examine the trace file for that process. Look for the trace file that contains the process number in the trace file name. See "Finding Trace Files" for more information.
- If you want to resubmit the CREATE DATABASE statement after a failure, you must first shut down the instance and delete any files created by the previous CREATE DATABASEstatement.
Example 2
This example illustrates creating a database with Oracle Managed Files, which enables you to use a much simpler CREATE DATABASE statement. To use Oracle Managed Files, the initialization parameter DB_CREATE_FILE_DEST must be set. This parameter defines the base directory for the various database files that the database creates and automatically names. The following statement is an example of setting this parameter in the initialization parameter file:
DB_CREATE_FILE_DEST='/u01/app/oracle/oradata'
With Oracle Managed Files and the following CREATE DATABASE statement, the database creates the SYSTEM and SYSAUX tablespaces, creates the additional tablespaces specified in the statement, and chooses default sizes and properties for all datafiles, control files, and redo log files. Note that these properties and the other default database properties set by this method may not be suitable for your production environment, so it is recommended that you examine the resulting configuration and modify it if necessary.
CREATE DATABASE mynewdb
USER SYS IDENTIFIED BY sys_password
USER SYSTEM IDENTIFIED BY system_password
EXTENT MANAGEMENT LOCAL
DEFAULT TEMPORARY TABLESPACE temp
UNDO TABLESPACE undotbs1
DEFAULT TABLESPACE users;
Tip:
If your CREATE DATABASE statement fails, and if you did not complete Step 7, ensure that there is not a pre-existing server parameter file (SPFILE) for this instance that is setting initialization parameters in an unexpected way. For example, an SPFILE contains a setting for the complete path to all control files, and the CREATE DATABASE statement fails if those control files do not exist. Ensure that you shut down and restart the instance (with STARTUP NOMOUNT) after removing an unwanted SPFILE. See "Managing Initialization Parameters Using a Server Parameter File" for more information.
See Also:
- "Specifying CREATE DATABASE Statement Clauses"
- "Specifying Oracle-Managed Files at Database Creation"
- Chapter 15, "Using Oracle-Managed Files"
- Oracle Database SQL Language Reference for more information about specifying the clauses and parameter values for the CREATE DATABASE statement
Step 10: Create Additional Tablespaces
To make the database functional, you need to create additional tablespaces for your application data. The following sample script creates some additional tablespaces:
CREATE TABLESPACE apps_tbs LOGGING
DATAFILE '/u01/app/oracle/oradata/mynewdb/apps01.dbf'
SIZE 500M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL;
-- create a tablespace for indexes, separate from user tablespace (optional)
CREATE TABLESPACE indx_tbs LOGGING
DATAFILE '/u01/app/oracle/oradata/mynewdb/indx01.dbf'
SIZE 100M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL;
For information about creating tablespaces, see Chapter 12, "Managing Tablespaces".
Step 11: Run Scripts to Build Data Dictionary Views
Run the scripts necessary to build data dictionary views, synonyms, and PL/SQL packages, and to support proper functioning of SQL*Plus:
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
@?/sqlplus/admin/pupbld.sql
EXIT
The at-sign (@) is shorthand for the command that runs a SQL*Plus script. The question mark (?) is a SQL*Plus variable indicating the Oracle home directory. The following table contains descriptions of the scripts:
Script |
Description |
CATALOG.SQL |
Creates the views of the data dictionary tables, the dynamic performance views, and public synonyms for many of the views. Grants PUBLIC access to the synonyms. |
CATPROC.SQL |
Runs all scripts required for or used with PL/SQL. |
PUPBLD.SQL |
Required for SQL*Plus. Enables SQL*Plus to disable commands by user. |
Step 12: Run Scripts to Install Additional Options (Optional)
You may want to run other scripts. The scripts that you run are determined by the features and options you choose to use or install. Many of the scripts available to you are described in the Oracle Database Reference.
If you plan to install other Oracle products to work with this database, see the installation instructions for those products. Some products require you to create additional data dictionary tables. Usually, command files are provided to create and load these tables into the database data dictionary.
See your Oracle documentation for the specific products that you plan to install for installation and administration instructions.
Step 13: Back Up the Database.
Take a full backup of the database to ensure that you have a complete set of files from which to recover if a media failure occurs. For information on backing up a database, see Oracle Database Backup and Recovery User's Guide.
Step 14: (Optional) Enable Automatic Instance Startup
You might want to configure the Oracle instance to start automatically when its host computer restarts. See your operating system documentation for instructions. For example, on Windows, use the following command to configure the database service to start the instance upon computer restart:
ORADIM -EDIT -SID sid -STARTMODE AUTO -SRVCSTART SYSTEM [-SPFILE]
You must use the -SPFILE argument if you want the instance to read an SPFILE upon automatic restart.
See the section "Using ORADIM to Administer an Oracle Database Instance" in Oracle Database Platform Guide for Microsoft Windows for more information on the ORADIM command.
Specifying CREATE DATABASE Statement Clauses
When you execute a CREATE
DATABASE
statement, Oracle Database performs a number of operations. The actual operations performed depend on the clauses that you specify in the CREATEDATABASE
statement and the initialization parameters that you have set. Oracle Database performs at least these operations:
- Creates the datafiles for the database
- Creates the control files for the database
- Creates the redo log files for the database and establishes the
ARCHIVELOG
mode. - Creates the
SYSTEM
tablespace - Creates the
SYSAUX
tablespace - Creates the data dictionary
- Sets the character set that stores data in the database
- Sets the database time zone
- Mounts and opens the database for use
This section discusses several of the clauses of the CREATE
DATABASE
statement. It expands upon some of the clauses discussed in "Step 9: Issue the CREATE DATABASE Statement" and introduces additional ones. Many of the CREATE DATABASE
clauses discussed here can be used to simplify the creation and management of your database.
The following topics are contained in this section:
- Protecting Your Database: Specifying Passwords for Users SYS and SYSTEM
- Creating a Locally Managed SYSTEM Tablespace
- About the SYSAUX Tablespace
- Using Automatic Undo Management: Creating an Undo Tablespace
- Creating a Default Temporary Tablespace
- Specifying Oracle-Managed Files at Database Creation
- Supporting Bigfile Tablespaces During Database Creation
- Specifying the Database Time Zone and Time Zone File
- Specifying FORCE LOGGING Mode
Protecting Your Database: Specifying Passwords for Users SYS and SYSTEM
The clauses of the CREATE
DATABASE
statement used for specifying the passwords for users SYS
and SYSTEM
are:
USER
SYS
IDENTIFIED
BY
passwordUSER
SYSTEM
IDENTIFIED
BY
password
If you omit these clauses, these users are assigned the default passwords change_on_install
and manager
, respectively. A record is written to the alert log indicating that the default passwords were used. To protect your database, you must change these passwords using the ALTER USER
statement immediately after database creation.
Oracle strongly recommends that you specify these clauses, even though they are optional in this release of Oracle Database. The default passwords are commonly known, and if you neglect to change them later, you leave database vulnerable to attack by malicious users.
When choosing a password, keep in mind that beginning in Release 11g, passwords are case sensitive. Also, there may be password formatting requirements for your database. See the section entitled "How Oracle Database Checks the Complexity of Passwords" in Oracle Database Security Guide for more information.
See Also:
"Some Security Considerations"
Creating a Locally Managed SYSTEM Tablespace
Specify the EXTENT MANAGEMENT LOCAL
clause in the CREATE
DATABASE
statement to create a locally managed SYSTEM
tablespace. The COMPATIBLE
initialization parameter must be set to 10.0.0 or higher for this statement to be successful. If you do not specify the EXTENT MANAGEMENT LOCAL
clause, by default the database creates a dictionary-managed SYSTEM
tablespace. Dictionary-managed tablespaces are deprecated.
If you create your database with a locally managed SYSTEM
tablespace, and if you are not using Oracle-managed files, ensure that the following conditions are met:
- You specify the
DEFAULT
TEMPORARY
TABLESPACE
clause in theCREATE
DATABASE
statement. - You include the
UNDO TABLESPACE
clause in theCREATE
DATABASE
statement.
See Also:
- Oracle Database SQL Language Reference for more specific information about the use of the
DEFAULT TEMPORARY TABLESPACE
andUNDO TABLESPACE
clauses whenEXTENT MANAGEMENT LOCAL
is specified for theSYSTEM
tablespace - "Locally Managed Tablespaces"
- "Migrating the SYSTEM Tablespace to a Locally Managed Tablespace"
About the SYSAUX Tablespace
The SYSAUX
tablespace is always created at database creation. The SYSAUX
tablespace serves as an auxiliary tablespace to the SYSTEM
tablespace. Because it is the default tablespace for many Oracle Database features and products that previously required their own tablespaces, it reduces the number of tablespaces required by the database. It also reduces the load on the SYSTEM
tablespace.
You can specify only datafile attributes for the SYSAUX
tablespace, using the SYSAUX DATAFILE
clause in the CREATE
DATABASE
statement. Mandatory attributes of the SYSAUX
tablespace are set by Oracle Database and include:
PERMANENT
READ
WRITE
EXTENT
MANAGMENT
LOCAL
SEGMENT
SPACE
MANAGMENT
AUTO
You cannot alter these attributes with an ALTER
TABLESPACE
statement, and any attempt to do so will result in an error. You cannot drop or rename the SYSAUX
tablespace.
The size of the SYSAUX
tablespace is determined by the size of the database components that occupy SYSAUX
. See Table 2-2 for a list of all SYSAUX
occupants. Based on the initial sizes of these components, the SYSAUX
tablespace needs to be at least 240 MB at the time of database creation. The space requirements of the SYSAUX
tablespace will increase after the database is fully deployed, depending on the nature of its use and workload. For more information on how to manage the space consumption of the SYSAUX
tablespace on an ongoing basis, please refer to the "Managing the SYSAUX Tablespace".
If you include a DATAFILE
clause for the SYSTEM
tablespace, then you must specify the SYSAUX DATAFILE
clause as well, or the CREATE
DATABASE
statement will fail. This requirement does not exist if the Oracle-managed files feature is enabled (see "Specifying Oracle-Managed Files at Database Creation").
The SYSAUX
tablespace has the same security attributes as the SYSTEM
tablespace.
Note:
This documentation discusses the creation of the SYSAUX
database at database creation. When upgrading from a release of Oracle Database that did not require the SYSAUX
tablespace, you must create the SYSAUX
tablespace as part of the upgrade process. This is discussed in Oracle Database Upgrade Guide.
Table 2-2 lists the components that use the SYSAUX
tablespace as their default tablespace during installation, and the tablespace in which they were stored in earlier releases:
Table 2-2 Database Components and the SYSAUX Tablespace
Component Using SYSAUX |
Tablespace in Earlier Releases |
Analytical Workspace Object Table |
|
Enterprise Manager Repository |
|
LogMiner |
|
Logical Standby |
|
OLAP API History Tables |
|
Oracle Data Mining |
|
Oracle Spatial |
|
Oracle Streams |
|
Oracle Text |
|
Oracle Ultra Search |
|
Oracle interMedia |
|
Oracle interMedia |
|
Oracle interMedia |
|
Server Manageability Components |
|
Statspack Repository |
User-defined |
Oracle Scheduler |
|
Workspace Manager |
|
See Also:
"Managing the SYSAUX Tablespace" for information about managing the SYSAUX
tablespace
Using Automatic Undo Management: Creating an Undo Tablespace
Automatic undo management uses an undo tablespace.To enable automatic undo management, set the UNDO_MANAGEMENT
initialization parameter to AUTO
in your initialization parameter file. Or, omit this parameter, and the database defaults to automatic undo management. In this mode, undo data is stored in an undo tablespace and is managed by Oracle Database. If you want to define and name the undo tablespace yourself, you must include the UNDO TABLESPACE
clause in the CREATE DATABASE
statement at database creation time. If you omit this clause, and automatic undo management is enabled, the database creates a default undo tablespace named SYS_UNDOTBS
.
See Also:
- "Specifying the Method of Undo Space Management"
- Chapter 14, "Managing Undo", for information about the creation and use of undo tablespaces
Creating a Default Permanent Tablespace
The DEFAULT
TABLESPACE
clause of the CREATE
DATABASE
statement specifies a default permanent tablespace for the database. Oracle Database assigns to this tablespace any non-SYSTEM
users for whom you do not explicitly specify a different permanent tablespace. If you do not specify this clause, then the SYSTEM
tablespace is the default permanent tablespace for non-SYSTEM
users. Oracle strongly recommends that you create a default permanent tablespace.
See Also:
Oracle Database SQL Language Reference for the syntax of the DEFAULT TABLESPACE
clause of CREATE DATABASE
and ALTER DATABASE
Creating a Default Temporary Tablespace
The DEFAULT TEMPORARY TABLESPACE
clause of the CREATE
DATABASE
statement creates a default temporary tablespace for the database. Oracle Database assigns this tablespace as the temporary tablespace for users who are not explicitly assigned a temporary tablespace.
You can explicitly assign a temporary tablespace or tablespace group to a user in the CREATE USER
statement. However, if you do not do so, and if no default temporary tablespace has been specified for the database, then by default these users are assigned the SYSTEM
tablespace as their temporary tablespace. It is not good practice to store temporary data in the SYSTEM
tablespace, and it is cumbersome to assign every user a temporary tablespace individually. Therefore, Oracle recommends that you use the DEFAULT TEMPORARY TABLESPACE
clause of CREATE
DATABASE
.
Note:
When you specify a locally managed SYSTEM
tablespace, the SYSTEM
tablespace cannot be used as a temporary tablespace. In this case you must create a default temporary tablespace. This behavior is explained in "Creating a Locally Managed SYSTEM Tablespace".
See Also:
- Oracle Database SQL Language Reference for the syntax of the
DEFAULT TEMPORARY TABLESPACE
clause ofCREATE DATABASE
andALTER DATABASE
- "Temporary Tablespaces" for information about creating and using temporary tablespaces
- "Multiple Temporary Tablespaces: Using Tablespace Groups" for information about creating and using temporary tablespace groups
Specifying Oracle-Managed Files at Database Creation
You can minimize the number of clauses and parameters that you specify in your CREATE
DATABASE
statement by using the Oracle-managed files feature. You do this by specifying either a directory or Automatic Storage Management (ASM) disk group in which your files are created and managed by Oracle Database.
By including any of the initialization parameters DB_CREATE_FILE_DEST,
DB_CREATE_ONLINE_LOG_DEST_
n, or DB_RECOVERY_FILE_DEST
in your initialization parameter file, you instruct Oracle Database to create and manage the underlying operating system files of your database. Oracle Database will automatically create and manage the operating system files for the following database structures, depending on which initialization parameters you specify and how you specify clauses in your CREATE
DATABASE
statement:
- Tablespaces and their datafiles
- Temporary tablespaces and their tempfiles
- Control files
- Redo log files
- Archived redo log files
- Flashback logs
- Block change tracking files
- RMAN backups
See Also:
"Specifying a Flash Recovery Area" for information about setting initialization parameters that create a flash recovery area
The following CREATE
DATABASE
statement shows briefly how the Oracle-managed files feature works, assuming you have specified required initialization parameters:
CREATE DATABASE mynewdb
USER SYS IDENTIFIED BY sys_password
USER SYSTEM IDENTIFIED BY system_password
EXTENT MANAGEMENT LOCAL
UNDO TABLESPACE undotbs
DEFAULT TEMPORARY TABLESPACE tempts1
DEFAULT TABLESPACE users;
- The
SYSTEM
tablespace is created as a locally managed tablespace. Without theEXTENT
MANAGEMENT
LOCAL
clause, theSYSTEM
tablespace is created as dictionary managed, which is not recommended. - No
DATAFILE
clause is specified, so the database creates an Oracle-managed datafile for theSYSTEM
tablespace. - No
LOGFILE
clauses are included, so the database creates two Oracle-managed redo log file groups. - No
SYSAUX DATAFILE
is included, so the database creates an Oracle-managed datafile for theSYSAUX
tablespace. - No
DATAFILE
subclause is specified for theUNDO TABLESPACE
andDEFAULT
TABLESPACE
clauses, so the database creates an Oracle-managed datafile for each of these tablespaces. - No
TEMPFILE
subclause is specified for theDEFAULT TEMPORARY TABLESPACE
clause, so the database creates an Oracle-managed tempfile. - If no
CONTROL_FILES
initialization parameter is specified in the initialization parameter file, then the database also creates an Oracle-managed control file. - If you are using a server parameter file (see "Managing Initialization Parameters Using a Server Parameter File"), the database automatically sets the appropriate initialization parameters.
See Also:
-
- Chapter 15, "Using Oracle-Managed Files", for information about the Oracle-managed files feature and how to use it
- Oracle Database Storage Administrator's Guide. for information about Automatic Storage Management
Supporting Bigfile Tablespaces During Database Creation
Oracle Database simplifies management of tablespaces and enables support for ultra-large databases by letting you create bigfile tablespaces. Bigfile tablespaces can contain only one file, but that file can have up to 4G blocks. The maximum number of datafiles in an Oracle Database is limited (usually to 64K files). Therefore, bigfile tablespaces can significantly enhance the storage capacity of an Oracle Database.
This section discusses the clauses of the CREATE
DATABASE
statement that let you include support for bigfile tablespaces.
See Also:
"Bigfile Tablespaces" for more information about bigfile tablespaces
Specifying the Default Tablespace Type
The SET DEFAULT...TABLESPACE
clause of the CREATE
DATABASE
statement to determines the default type of tablespace for this database in subsequent CREATE
TABLESPACE
statements. Specify either SET DEFAULT BIGFILE TABLESPACE
or SET DEFAULT SMALLFILE TABLESPACE
. If you omit this clause, the default is a smallfile tablespace, which is the traditional type of Oracle Database tablespace. A smallfile tablespace can contain up to 1022 files with up to 4M blocks each.
The use of bigfile tablespaces further enhances the Oracle-managed files feature, because bigfile tablespaces make datafiles completely transparent for users. SQL syntax for the ALTER
TABLESPACE
statement has been extended to allow you to perform operations on tablespaces, rather than the underlying datafiles.
The CREATE
DATABASE
statement shown in "Specifying Oracle-Managed Files at Database Creation" can be modified as follows to specify that the default type of tablespace is a bigfile tablespace:
CREATE DATABASE mynewdb
USER SYS IDENTIFIED BY sys_password
USER SYSTEM IDENTIFIED BY system_password
SET DEFAULT BIGFILE TABLESPACE
UNDO TABLESPACE undotbs
DEFAULT TEMPORARY TABLESPACE tempts1;
To dynamically change the default tablespace type after database creation, use the SET DEFAULT TABLESPACE
clause of the ALTER DATABASE
statement:
ALTER DATABASE SET DEFAULT BIGFILE TABLESPACE;
You can determine the current default tablespace type for the database by querying the DATABASE_PROPERTIES
data dictionary view as follows:
SELECT PROPERTY_VALUE FROM DATABASE_PROPERTIES
WHERE PROPERTY_NAME = 'DEFAULT_TBS_TYPE';
Overriding the Default Tablespace Type
The SYSTEM
and SYSAUX
tablespaces are always created with the default tablespace type. However, you can explicitly override the default tablespace type for the UNDO
and DEFAULT
TEMPORARY
tablespace during the CREATE
DATABASE
operation.
For example, you can create a bigfile UNDO
tablespace in a database with the default tablespace type of smallfile as follows:
CREATE DATABASE mynewdb
...
BIGFILE UNDO TABLESPACE undotbs
DATAFILE '/u01/oracle/oradata/mynewdb/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
You can create a smallfile DEFAULT
TEMPORARY
tablespace in a database with the default tablespace type of bigfile as follows:
CREATE DATABASE mynewdb
SET DEFAULT BIGFILE TABLSPACE
...
SMALLFILE DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/oracle/oradata/mynewdb/temp01.dbf'
SIZE 20M REUSE
...
Specifying the Database Time Zone and Time Zone File
You can specify the database time zone and the supporting time zone file.
Setting the Database Time Zone
Set the database time zone when the database is created by using the SET TIME_ZONE
clause of the CREATE DATABASE
statement. If you do not set the database time zone, then it defaults to the time zone of the server's operating system.
You can change the database time zone for a session by using the SET TIME_ZONE
clause of the ALTER SESSION
statement.
See Also:
Oracle Database Globalization Support Guide for more information about setting the database time zone
Specifying the Database Time Zone File
Two time zone files are included in the Oracle home directory. The default time zone file is $ORACLE_HOME/oracore/zoneinfo/timezonelrg.dat
. A smaller time zone file can be found in $ORACLE_HOME/oracore/zoneinfo/timezone.dat
.
If you are already using the smaller time zone file and you want to continue to use it in an Oracle Database 11g environment or if you want to use the smaller time zone file instead of the default time zone file, then complete the following tasks:
- Shut down the database.
- Set the
ORA_TZFILE
environment variable to the full path name of thetimezone.dat
file. - Restart the database.
If you are already using the default time zone file, then it is not practical to change to the smaller time zone file because the database may contain data with time zones that are not part of the smaller time file.
All databases that share information must use the same time zone datafile.
The time zone files contain the valid time zone names. The following information is also included for each time zone:
- Offset from Coordinated Universal Time (UTC)
- Transition times for Daylight Saving Time
- Abbreviations for standard time and Daylight Saving Time
To view the time zone names in the file being used by your database, use the following query:
SELECT * FROM V$TIMEZONE_NAMES;
Specifying FORCE LOGGING Mode
Some data definition language statements (such as CREATE
TABLE
) allow the NOLOGGING
clause, which causes some database operations not to generate redo records in the database redo log. The NOLOGGING
setting can speed up operations that can be easily recovered outside of the database recovery mechanisms, but it can negatively affect media recovery and standby databases.
Oracle Database lets you force the writing of redo records even when NOLOGGING
has been specified in DDL statements. The database never generates redo records for temporary tablespaces and temporary segments, so forced logging has no affect for objects.
See Also:
Oracle Database SQL Language Reference for information about operations that can be done in NOLOGGING
mode
Using the FORCE LOGGING Clause
To put the database into FORCE LOGGING
mode, use the FORCE LOGGING
clause in the CREATE DATABASE
statement. If you do not specify this clause, the database is not placed into FORCE LOGGING
mode.
Use the ALTER DATABASE
statement to place the database into FORCE LOGGING
mode after database creation. This statement can take a considerable time for completion, because it waits for all unlogged direct writes to complete.
You can cancel FORCE LOGGING
mode using the following SQL statement:
ALTER DATABASE NO FORCE LOGGING;
Independent of specifying FORCE LOGGING
for the database, you can selectively specify FORCE LOGGING
or NO FORCE LOGGING
at the tablespace level. However, if FORCE LOGGING
mode is in effect for the database, it takes precedence over the tablespace setting. If it is not in effect for the database, then the individual tablespace settings are enforced. Oracle recommends that either the entire database is placed into FORCE LOGGING
mode, or individual tablespaces be placed into FORCE LOGGING
mode, but not both.
The FORCE LOGGING
mode is a persistent attribute of the database. That is, if the database is shut down and restarted, it remains in the same logging mode. However, if you re-create the control file, the database is not restarted in the FORCE LOGGING
mode unless you specify the FORCE LOGGING
clause in the CREATE CONTROL FILE
statement.
See Also:
"Controlling the Writing of Redo Records" for information about using the FORCE LOGGING
clause for tablespace creation.
Performance Considerations of FORCE LOGGING Mode
FORCE LOGGING
mode results in some performance degradation. If the primary reason for specifying FORCE LOGGING
is to ensure complete media recovery, and there is no standby database active, then consider the following:
- How many media failures are likely to happen?
- How serious is the damage if unlogged direct writes cannot be recovered?
- Is the performance degradation caused by forced logging tolerable?
If the database is running in NOARCHIVELOG
mode, then generally there is no benefit to placing the database in FORCE LOGGING
mode. Media recovery is not possible in NOARCHIVELOG
mode, so if you combine it with FORCE LOGGING
, the result may be performance degradation with little benefit.
Dropping a Database
Dropping a database involves removing its datafiles, redo log files, control files, and initialization parameter files. The DROP DATABASE
statement deletes all control files and all other database files listed in the control file. To use the DROP DATABASE
statement successfully, all of the following conditions must apply:
- The database must be mounted and closed.
- The database must be mounted exclusively--not in shared mode.
- The database must be mounted as
RESTRICTED.
An example of this statement is:
DROP DATABASE;
The DROP DATABASE
statement has no effect on archived log files, nor does it have any effect on copies or backups of the database. It is best to use RMAN to delete such files. If the database is on raw disks, the actual raw disk special files are not deleted.
If you used the Database Configuration Assistant to create your database, you can use that tool to delete (drop) your database and remove the files.