4.3 Overview of Database Creation Tasks on Windows Using Command-Line Tools
Learn how to create a new database manually. As part of its database software files, Oracle Database provides a sample initialization parameter file, which can you can edit to suit your needs.
You can choose to create database creation scripts using Oracle Database Configuration Assistant.
The following are the types of Database creation tasks:
-
Copy an existing database and delete the old database.
-
Copy an existing database and keep the old database.
-
Create a new database when no database exists on your system.
Manual Database Creation Tasks
Use Manual Database Creation Tasks to understand the manual tasks involved in creating a new database for each of these database creation categories. Each step is explained in detail in the following subsections.
Table 4-1 Manual Database Creation Tasks
Task | Copy existing database and delete old database | Copy existing database and keep old database | Create new database when no database exists on system |
---|---|---|---|
About Exporting an Existing Database |
Yes |
Note 1 |
Not applicable |
Deleting Database Files |
Yes |
No |
Not applicable |
Modifying the Initialization Parameter File |
Yes |
Yes |
Yes |
Starting an Oracle Database Instance |
Yes |
Yes |
Yes |
About Creating and Starting an Oracle Database Service |
No |
Yes |
Yes |
Putting the CREATE DATABASE Statement in a Script |
Yes |
Yes |
Yes |
Running the CREATE DATABASE Script |
Yes |
Yes |
Yes |
About Importing a Database |
Yes |
Note 2 |
Not applicable |
Updating ORACLE_SID in the Registry |
No |
Only if you change the default |
Yes |
Backing Up the New Database |
Yes |
Yes |
Yes |
Note 1
Yes if you copy data from the existing database to the new database; otherwise, no.
Note 2
Yes if you import tables and other objects exported from the existing database; otherwise, no.
An example in the following sections demonstrates how to create a database. In this example, the existing database is the starter database with a SID
of orcl
located in directory C
:\app\username\oradata\orcl
. Copy orcl
to a new database with a database name and SID
of prod
located in the directory C:
\app\username\oradata\prod
. Then, delete the starter database orcl
.
Topics:
- About Exporting an Existing Database
You are required to export an existing database only if you intend to copy its contents to a new database. - Deleting Database Files
Deleting database files is required only when you copy an existing database to a new database to replace the old database. - Modifying the Initialization Parameter File
Describes how to modify the initialization parameter file. - About Creating and Starting an Oracle Database Service
Learn how to create and start an Oracle Database service. - Starting an Oracle Database Instance
Learn how to start an instance without mounting a database. - Adding the CREATE DATABASE Statement in a Script
TheCREATE DATABASE
statement is a SQL statement that creates the database. - Running the CREATE DATABASE Script
Use this procedure to run the CREATE DATABASE script. - About Importing a Database
Learn how to use Data Pump Import or Import. - Updating ORACLE_SID in the Registry
If this is the first database on your computer or if you intend to make the new database the default database, then you must make a change in the registry. - Creating the ORACLE_SID Parameter
If you do not yet have the parameterORACLE_SID
, because this is the first database on your system, then you must create it. - Backing Up the New Database
Use this procedure to prevent data loss.
4.3.1 About Exporting an Existing Database
You are required to export an existing database only if you intend to copy its contents to a new database.
If you are working with data from an earlier Oracle release, then you can use Export for this task. If you are using Oracle Database 10g Release 1 (10.1) or later data, then Oracle recommends that you use Data Pump Export because it supports new Oracle Database 10g Release 1 (10.1) or later features, such as floating points.
Although you can start Data Pump Export or Export in either the parameter mode or an interactive mode, Oracle recommends parameter mode. Interactive mode provides less functionality than the parameter mode and exists for backward compatibility only.
The syntax for Data Pump Export parameter mode is:
C:\> expdp SYSTEM DUMPFILE=myexp.dmp FULL=y LOGFILE=myexp.log Password: password
The syntax for Data Pump Export interactive mode is:
C:\> expdp SYSTEM Password: password
Enter only the command expdp
SYSTEM
to begin an interactive session and let Data Pump Export prompt you for information it needs.
Note:
If you use the parameter mode, then Data Pump Export considers the file names and the directory names to be invalid if they contain one or more blank spaces. The workaround is to enclose the full path in the DUMPFILE=
parameter in triple quotation marks. For example:
DUMPFILE="""C:\program files\export.dmp"""
If Data Pump Export is used in an interactive mode, then the file name or the directory name can contain a space without quotation marks.
The syntax for Export parameter mode is:
C:\> exp SYSTEM FILE=myexp.dmp FULL=y LOG=myexp.log Password: password
The syntax for the Export interactive mode is:
C:\> exp SYSTEM
Password: password
Enter only the command exp
SYSTEM
to begin an interactive session and let Export prompt you for information it needs.
Note:
If you use the parameter mode, then Export considers the file names and the directory names to be invalid if they contain one or more blank spaces. The workaround is to enclose the full path in the FILE=
parameter in triple quotation marks. For example:
FILE="""C:\program files\export.dmp"""
If Export is used in an interactive mode, then the file name or the directory name can contain a space without quotation marks.
Topics:
- Exporting All Data from an Existing Database
Describes how to export all data from an existing database to a new database.
See Also:
Oracle Database Utilities for more information about using Data Pump Export or Export
4.3.2 Deleting Database Files
Deleting database files is required only when you copy an existing database to a new database to replace the old database.
In the following example, you delete the database files of the starter database orcl
.
To delete database files:
4.3.3 Modifying the Initialization Parameter File
Describes how to modify the initialization parameter file.
To use the starter database orcl
as the basis for your new database:
-
Copy
ORACLE_BASE
\admin\orcl\pfile\init.ora
. -
Place the copy in
ORACLE_BASE
\admin\prod\pfile\init.ora
. -
Modify the file by performing the following tasks:
Note:
Starting with Oracle9i Release 2 (9.2), nesting of quotation marks using the backslash (\) escape character is no longer supported. This affects how Oracle Database interprets the parameter values in your initialization parameter file. For example, if you specified
CONTROL_FILES = "ctlfile\'1.ora"
in releases before release 9.2, the file name was interpreted asctlfile'1.ora
. Starting with release 9.2, the file name will be interpreted asctlfile\'1.ora
.Oracle highly recommends modifying your parameter files to remove such references and other methods of nesting quotation marks in the initialization parameter values.
-
If you do not have an existing database on your system, then you cannot copy an existing initialization parameter file to use as the basis for your new initialization parameter file. However, you can use the sample initialization parameter file
initsmpl.ora
provided in:ORACLE_HOME\admin\sample\pfile
This is the basis for the initialization parameter file for the database
prod
. -
If you use the
initsmpl.ora
file as the basis for the initialization parameter file, then the following parameters must be set to the indicated values, otherwise you cannot start databaseprod
:DB_NAME=prod.domain
The parameter
DB_NAME
indicates the database name and must match the name used in theCREATE DATABASE
statement. Give a unique database name to each database. You can use eight characters for a database name. The name is not required to match theSID
of the database service.INSTANCE_NAME=prod.domain
SERVICE_NAMES=prod.domain
CONTROL_FILES = (
"C:\app\
username
\oradata\prod\control01.ctl",
"C:\app\
username
\oradata\prod\control02.ctl",
"C:\app\
username
\oradata\prod\control03.ctl")
The parameter
CONTROL_FILES
lists the database control files. You do not have to control files on your file system at this point, because control files are created when you run theCREATE DATABASE
statement. Ensure that you specify the complete path and the file name, including the drive letter.DB_FILES=100
Modifying the initialization parameter
DB_FILES
is not required, but it is recommended to optimize performance. Set this parameter to the same number as the value of theMAXDATAFILES
option of theCREATE DATABASE
statement. The value of100
is used for this example.The
DIAGNOSTIC_DEST
initialization parameter sets the location of the Automatic Diagnostic Repository (ADR), which is a directory structure stored outside of the database. The ADR is used in problem diagnostics.Use
DIAGNOSTIC_DEST =
ORACLE_HOME\log
if the environment variableORACLE_BASE
is not set.Use
DIAGNOSTIC_DEST =
ORACLE_BASE
variable if the environment variableORACLE_BASE
is set.See Also:
-
Oracle Database Installation Guide for Microsoft Windows for information about ADR
-
Oracle Database Reference for information about other initialization parameters that you can add or modify
-
-
Related Topics
4.3.4 About Creating and Starting an Oracle Database Service
Learn how to create and start an Oracle Database service.
Perform either of the following steps:
-
Copy an existing database to a new database and keep the old database
-
Create a new database when you have no other database to copy
Before you create the database, first create a Windows service to run the database. This service is the Oracle Database process, oracle.exe
, installed in the form of a Windows service.
Use ORADIM to create the service.
Topics:
- Creating and Starting an Oracle Database Service
Learn how to create and start an Oracle Database service. - Access to Oracle Wallets in a File System for Oracle Database Services
Discusses about accessing Oracle Wallets.
Related Topics
4.3.4.1 Creating and Starting an Oracle Database Service
Learn how to create and start an Oracle Database service.
To create and start an Oracle Database service:
4.3.4.2 Access to Oracle Wallets in a File System for Oracle Database Services
Discusses about accessing Oracle Wallets.
When an Oracle wallet is created in the file system, only the user creating the wallet is granted access to that wallet by wallet creation tools. Therefore, Oracle Database services (running as the Windows User Account) might not be able to access the wallet unless you explicitly grant access to the wallet using Windows tools.
Related Topics
4.3.5 Starting an Oracle Database Instance
Learn how to start an instance without mounting a database.
Start an instance without mounting a database.
SQL> STARTUP NOMOUNT
You must not specify the PFILE
clause in this example, because the initialization parameter file is stored in the default location. At this point, there is no database. Only the System Global Area (SGA) is created and the background processes are started in preparation for the creation of a new database.
4.3.6 Adding the CREATE DATABASE Statement in a Script
The CREATE DATABASE
statement is a SQL statement that creates the database.
A script containing this statement can be used anytime you create a database.
The CREATE DATABASE
statement has the following parameters:
-
MAXDATAFILES
- default value: 32, maximum value: 65534 -
MAXLOGFILES
- default value: 32, maximum value: 255
The CHARACTER SET
parameter determines the database character set of the new database. The default value is US7ASCII, however the recommended value is AL32UTF8. AL32UTF8 is the Oracle implementation of the Unicode Standard character set in UTF-8 encoding form. Unicode is suitable for storing text in practically any written language of the world.
When you run the CREATE DATABASE
statement, Oracle Database performs several operations depending upon the clauses that you specified in the CREATE DATABASE
statement or the initialization parameters that you have set.
Note:
Oracle Managed Files is a feature that works with the CREATE DATABASE
statement to simplify administration of Oracle Database. Oracle Managed Files eliminates the requirement to directly manage operating system files comprising an Oracle Database server, because you specify operations in terms of database objects rather than file names.
To create the database prod
, copy and save the following statement in a file named script_name
.sql
:
CREATE DATABASE prod USER SYS IDENTIFIED BY sys_password USER SYSTEM IDENTIFIED BY system_password MAXLOGFILES 5 MAXDATAFILES 100 DATAFILE 'C:\app\username
\oradata\prod\system01.dbf' SIZE 325M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED UNDO TABLESPACE "UNDOTBS" DATAFILE 'app\username
\oradata\prod\undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED CHARACTER SET AL32UTF8 logfile 'C:\app\username\oradata\prod\redo01.log' size 100M reuse, 'C:\app\username\oradata\prod\redo02.log' size 100M reuse, 'C:\app\username\oradata\prod\redo03.log' size 100M reuse EXTENT MANAGEMENT LOCAL;
See Also:
-
Oracle Database Administrator's Guide for more information about using Oracle Managed Files
-
Oracle Database Installation Guide for Microsoft Windows for more information about recommended database character sets
4.3.7 Running the CREATE DATABASE Script
Use this procedure to run the CREATE DATABASE script.
To use the SQL script to create a database:
Related Topics
4.3.8 About Importing a Database
Learn how to use Data Pump Import or Import.
You can use Data Pump Import (for Oracle Database 10g Release 1 (10.1) or later data) or Import (for earlier data) to import the full export created into the new database. Although you can start Data Pump Import or Import using either the parameter mode or the interactive mode, Oracle recommends the parameter mode because it provides more functionality. Interactive mode exists solely for backward compatibility.
The syntax for Data Pump Import parameter mode is:
C:\> impdp SYSTEM DUMPFILE=myexp.dmp FULL=y LOG=myexp.log Password: password
The syntax for Data Pump Import interactive mode is:
C:\> impdp SYSTEM
Password: password
Enter only impdp
SYSTEM
to begin an interactive session and let Data Pump Import prompt you for information it needs.
Note:
-
If you use the parameter mode, then Data Pump Import considers the file names and the directory names to be invalid if they contain one or more blank spaces. The workaround is to enclose the full path in the
DUMPFILE=
parameter in triple quotation marks. For example:DUMPFILE="""C:\program files\export.dmp"""
If you use Data Pump Import in an interactive mode, then the file name or the directory name can contain a space without the quotation marks.
-
If the original database from which the export file was generated contains a tablespace that is not in the new database, then Import tries to create that tablespace with associated data files.
The easy solution is to ensure that both the databases contain the same tablespaces. Data files are not required to be identical. Only the tablespace names are important.
Related Topics
See Also:
Oracle Database Utilities for more information about using Data Pump Import or Import
4.3.9 Updating ORACLE_SID in the Registry
If this is the first database on your computer or if you intend to make the new database the default database, then you must make a change in the registry.
Perform the following steps:
Related Topics
4.3.11 Backing Up the New Database
Use this procedure to prevent data loss.
Note:
If anything goes wrong while operating the new database without a backup, then you must repeat the database creation procedure. Back up your database now to prevent loss of data.
To back up the new database:
Note:
Do not store database files on a compressed drive. This can result in write errors and a decreased performance.