Oracle8
Enterprise Edition Getting Started
Release 8.0.5 for Windows NT A64416-01 |
|
This chapter describes how to create a database.
Specific topics discussed are:
Before you create a database, consider the following requirements:
Before creating a database, it is important to understand
that starting with Oracle8 Enterprise Edition, all mounted Oracle databases
in a network must have unique database names. A database name is
associated with a database at "CREATE DATABASE" time and stored in the
control file(s) of the database. If the database keyword is provided in
the CREATE DATABASE statement, then that value becomes the database name
for that database. If not, then the value of the DB_NAME parameter in the
INITSID.ORA file is used. If the DB_NAME parameter is not specified,
then the default DB_NAME value is ORCx.
If you attempt to mount two Oracle8 databases with the same database name, you receive the following error during the second mount:
ORA-01102: cannot mount database in EXCLUSIVE mode
If there are two or more Oracle8 databases on the same computer located in different Oracle homes:
To change the name of an existing database, you must use
the CREATE CONTROLFILE statement to recreate your control file(s) and specify
a new database name. This restriction is imposed only on Oracle8 instances.
Any Oracle7 instances running simultaneously with an Oracle8 instance are
not subject to this restriction.
Note that the Oracle8 Server RDBMS component (the database
software) must be installed from either the Oracle8 Enterprise Edition
or Custom Installation options on Windows NT. It is not available with
the Client option. See Oracle8
Enterprise Edition Installation for Windows NT for more information.
This section describes how to create a new database. You can choose either of the following tools to create a database:
Use Oracle Database Assistant to create a database because
it is the easiest method. If you want to create a database using command
line tools, you can use the BUILD_DB.SQL script located in ORACLE_HOME\RDBMS80\ADMIN.
During installation of Oracle8 Enterprise Edition, you can select either of the following options to install Oracle Database Assistant. If you select:
To create a database using Oracle Database Assistant:
The Oracle Database Assistant welcome window appears:
The following window appears:
You can modify an Oracle8 database to support the following cartridges that you installed from your CD-ROM, but have not yet configured:
These cartridges (if installed during a separate installation
from Oracle8 Enterprise Edition) are not automatically configured
during installation. The Oracle ConText Cartridge is never automatically
configured. The Modify option of Oracle Database Assistant automatically
configures your cartridges. If you installed Oracle cartridges through
the Oracle8 Enterprise Edition option on the CD-ROM, your cartridges were
automatically configured for the starter database ORCL.
The Delete a Database option of Oracle Database Assistant
lets you quickly and easily delete databases.
You can choose options in Oracle Database Assistant to enable
or disable multi-threaded server support in your Oracle8 database. Multi-threaded
server (MTS) support enables many client user processes to share a small
number of server processes. Many client users can connect to a dispatcher
process. The dispatcher process then routes client requests to the next
available shared server process. There is no dedicated server process for
each user process that remains associated with the client user process
for the duration of the connection. Instead, inactive server processes
are "recycled" and used as needed. This reduces system overhead and enables
you to increase the number of supported users. See Net8 Administrator's
Guide, Oracle8 Concepts, and Oracle8 Reference for more information.
This section describes the steps to create a database manually using a SQL script. There are a number of ways to create a database depending on if you want to:
The table below summarizes the steps to create a new database
for each of the above database creation scenarios. Each step is explained
in detail in the following sub-sections.
An example is used in the following sections to demonstrate
the commands to create a database. In this example, you will copy an existing
database (the starter database with a SID of ORCL located in the C:\ ORANT
directory) to a new database with a SID of PROD located in the C:\MYDIR
directory. You will delete the ORCL database after you have created the
PROD database.
Create a directory, for example, C:\MYDIR in which to put
the new database PROD.
It is only necessary to export if you want to copy the contents
of an existing database to a new database. You must perform this task if
you are going to remove the old database and put its data in the new database.
If you are going to create an additional database, you only need to do
this if you want a copy of the data from the old database in the new database.
You can invoke the Export Utility using parameter mode or
interactive mode. Parameter mode is the recommended mode. Interactive mode
provides less functionality than parameter mode. It exists for backward
compatibility.
C:\ORANT> EXP80 SYSTEM/PASSWORD FILE=MYEXP.DMP FULL=Y
LOG=MYEXP.LOG
C:\ORANT> EXP80 SYSTEM/PASSWORD
Enter only the command EXP80 USERNAME/PASSWORD to
begin an interactive session and let the Export Utility prompt you for
the information it needs.
See Oracle8 Utilities
for more information on using the Export Utility in parameter or interactive
mode.
To export all data from an existing database to a new database:
C:\ORANT> SET ORACLE_SID=ORCL
C:\ORANT> EXP80 SYSTEM/PASSWORD FILE=MYEXP.DMP FULL=Y LOG=MYEXP.LOG
You now have a full database export of the starter database ORCL in the file MYEXP.DMP, with all messages from the Export utility logged in the MYEXP.LOG file.
It is only necessary to delete database files if you want
to copy an existing database to a new database and then remove the old
database. In the following example, we delete the database files of the
starter database ORCL.
To delete database files:
C:\ORANT> ORADIM80 -SHUTDOWN -SID ORCL -USRPWD PASSWORD -SHUTTYPE INST -SHUTMODE I
LOG3ORCL.ORA AND LOG4ORCL.ORA database files are only available
with release 7.3.4 and 8.0.4 databases. Do not delete the INITORCL.ORA
file, as it will be the basis for the new initialization parameter file
INITPROD.ORA in "Modify the INITSID.ORA File".
If you are using the starter database ORCL as the basis for
your new database, copy C:\ORANT\DATABASE\INITORCL.ORA to C:\MYDIR\DATABASE\
INITPROD.ORA and modify the file.
If you do not have an existing database on your system, you
cannot copy an initialization parameter file to use as the basis for your
INITPROD.ORA file. You can use the sample initialization parameter file
INITORCL.80 provided in the C:\ORANT\DATABASE directory as the basis for
INITPROD.ORA.
You must modify the CONTROL_FILES and DB_NAME initialization
parameters in the INITPROD.ORA file or you will not be able to start the
PROD database. Modifying the initialization parameters GLOBAL_NAMES and
DB_FILES is highly recommended to optimize performance.
Initialization Parameter | How to Modify... |
---|---|
CONTROL_FILES |
This parameter lists the control files of the database. You do not have the control files on your file system at this point, because the control files are created when you execute the CREATE DATABASE statement. Ensure you specify the complete path and file name, including drive letter. For example, CONTROL_FILES = (C:\MYDIR\DATABASE\CTL1PROD.ORA, ORACLE_HOME\DATABASE\CTL2PROD.ORA) |
DB_NAME |
This parameter indicates the name of the database, and must match the name used in the CREATE DATABASE statement in "Using BUILD_DB.SQL" in this chapter. This name does not need to match the SID of the database service. You give a unique database name to each database. For example, You can use up to eight characters for the database name. |
GLOBAL_NAMES |
The default value of this parameter is FALSE; however, it is recommended to set this parameter to TRUE. See the Oracle8 Administrator's Guide to find out more about global names and how they relate to database links. |
DB_FILES |
Set this initialization parameter to the same number as the value of the MAXDATAFILES option of the CREATE DATABASE statement. The value of 100 is used for this example. DB_FILES=100 |
Additional
Information:
See Appendix B, "Oracle8 Database Specifications for Windows NT" for information on other initialization parameters you may want to add to the INITPROD.ORA file. |
It is only necessary to create and start an Oracle8 service if you want to:
Before you create the database, first create a Windows NT
service to run the database. This service is the Oracle8 database process,
ORACLE80.EXE, installed in the form of a Windows NT service. Use ORADIM80
to create the service. Upon creation, the service starts automatically.
See section, "Using ORADIM80 to Administer the
Oracle Instance" for information on how to use ORADIM80.
To create a Windows NT service:
C:\> CD MYDIR
C:\MYDIR> ORADIM80 -NEW -SID PROD -INTPWD PASSWORD -STARTMODE AUTO -PFILE C:\MYDIR\DATABASE\INITPROD.ORA
Note that the previously created INITPROD.ORA file is specified, with complete path, including drive name. You do not receive a message indicating the success or failure of this command. You can check if the service is started in the services window of the Windows NT Control Panel.
C:\MYDIR> SET ORACLE_SID=PROD
The CREATE DATABASE statement is a sequence of SQL statements
that creates the database. Create a script containing this statement that
you can reuse anytime you want to create a database. Use the BUILD_DB.SQL
script located in C:\ORANT\RDBMS80\ADMIN as a basis for your script.
To prepare the CREATE DATABASE script:
A sample script follows:
-- This file must be run out of the directory containing the -- initialization file. startup nomount pfile=C:\mydir\DATABASE\initprod.ora -- Create database create database prod controlfile reuse logfile 'C:\mydir\DATABASE\log1prod.ora' size 1M reuse, 'C:\mydir\DATABASE\log2prod.ora' size 1M reuse, 'C:\mydir\DATABASE\log3prod.ora' size 1M reuse, 'C:\mydir\DATABASE\log4prod.ora' size 1M reuse datafile 'C:\mydir\DATABASE\sys1prod.ora' size 10M reuse autoextend on next 10M maxsize 200M character set WE8ISO8859P1; create rollback segment rb_temp; -- Create additioanal tablespaces ... -- USER_DATA: Create user sets this as the default tablespace -- TEMPORARY_DATA: Create user sets this as the temporary tablespace -- ROLLBACK_DATA: For rollback segments create tablespace user_data datafile 'C:\mydir\DATABASE\usr1prod.ora' size 3M reuse autoextend on next 5M maxsize 150M; create tablespace rollback_data datafile 'C:\mydir\DATABASE\rbs1prod.ora' size 5M reuse autoextend on next 5M maxsize 150M; create tablespace temporary_data datafile 'C:\mydir\DATABASE\tmp1prod.ora' size 2M reuse autoextend on next 5M maxsize 150M; alter rollback segment rb_temp online;\x7f -- Change the SYSTEM users' password, default tablespace and -- temporary tablespace. alter user system temporary tablespace temporary_data; alter user system default tablespace user_data; -- Create 16 rollback segments. Allows 16 concurrent users with open -- transactions updating the database. This should be enough. create public rollback segment rb1 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb2 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb3 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb4 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb5 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb6 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb7 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb8 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb9 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb10 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb11 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb12 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb13 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb14 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb15 storage(initial 50K next 50K) tablespace rollback_data; create public rollback segment rb16 storage(initial 50K next 50K) tablespace rollback_data;
You will run this script at the Server Manager prompt in
the section, "Create a Database".
Before you run the BUILD_PROD.SQL script to create a database, you must perform the following tasks:
C:\MYDIR> NET START
A list of all Windows NT services currently running on the system appears. If OracleServicePROD is missing from the list, enter:
C:\MYDIR> NET START ORACLESERVICEPROD
C:\MYDIR> SET ORACLE_SID=PROD
C:\MYDIR> SVRMGR30 SVRMGR> CONNECT INTERNAL/PASSWORD
The password is the one you previously used to create the service, with the ORADIM80 -NEW command in section, "To create a Windows NT service:". You should see the message Connected.
SVRMGR> STARTUP NOMOUNT PFILE=C:\MYDIR\DATABASE\INITPROD.ORA
When the initialization parameter file INITPROD.ORA is located in the DATABASE subdirectory of your Oracle home directory, the PFILE specification is optional. Otherwise, you must specify the PFILE option with the complete path and file name of the initialization parameter file. Note that there is an equal sign (=) between the keyword PFILE and the path/filename. There are no space characters around the equal sign (=).
SVRMGR> SPOOL BUILD_PROD.LOG SVRMGR> @BUILD_PROD.SQL
This command assumes the script file is located in the directory from which Server Manager was invoked. If this is not the case, specify the complete path in front of the file name. If the database is created successfully, the message Statement processed appears. If you receive any errors, there are three possible causes:
Cause of Error | Solution |
---|---|
The BUILD_PROD.SQL script contained syntax errors. |
Correct them. |
Some of the files to be created by the BUILD_PROD.SQL script already exist in the file system. |
Make sure you are not using any file names already used by another database on the system. |
There was an error at the operating system level, such as a file or directory permission problem. |
You should have received a series of errors in Server Manager, the last one of which should have the OSD- prefix. At the end of the OSD error you typically see an operating system error number in parentheses. To see what the error means: From the MS-DOS command prompt, enter: From the Server Manager prompt, enter: where n is the operating system error number. See "Operating System Permission Issues" in Appendix F, "Troubleshooting" for more information. |
You must correct these problems before attempting to recreate a database.
SVRMGR> @%RDBMS80%\ADMIN\CATALOG.SQL
SVRMGR> @%RDBMS80%\ADMIN\CATPROC.SQL
Run the following script if you want Advanced Replication functionality with the new database. Ensure that the rollback segments are large enough and are online before you run CATREP8M.SQL.
SVRMGR> @%RDBMS80%\ADMIN\CATREP8M.SQL
Note that CATREP8M.SQL requires at least an hour to run, depending on your system.
SVRMGR> SPOOL OFF
Note: You may see many messages such as object to be dropped
does not exist and name already used by another object while
the scripts are running. These are information messages and are intended
to occur while creating a new database. If you see any unusual errors in
the BUILD_PROD.SQL.LOG log file, see Oracle8
Error Messages for suggested actions.
|
You can choose to import the full export created in the section,
"Export an Existing Database" into the new database.
You can invoke the Import Utility using Parameter mode or
Interactive mode. Parameter mode is the recommended mode. Interactive mode
provides less functionality than parameter mode. It exists for backward
compatibility.
C:\ORANT> IMP80 SYSTEM/PASSWORD FILE=MYEXP.DMP FULL=Y
LOG=MYEXP.LOG
C:\ORANT> IMP80 SYSTEM/PASSWORD
Enter only the command IMP80 USERNAME/PASSWORD to
begin an interactive session and let the Export Utility prompt you for
the information it needs.
See Oracle8 Utilities
for more information on using the Import Utility in parameter or interactive
mode.
To import data:
SVRMGR> EXIT
C:\MYDIR> IMP80 SYSTEM/PASSWORD FILE=MYEXP.DMP FULL=Y LOG=MYIMP.LOG
If this is the first database on the system or if you want to make the new database the default database, you must make a change in the registry.
C:\MYDIR> REGEDT32
The registry editor window appears.
If you do not have ORACLE_SID because this is the first database
on your system, you must create the ORACLE_SID parameter.
To create ORACLE_SID parameter:
C:\> REGEDT32
The registry editor window appears.
The Add Value dialog box appears:
A string editor dialog box appropriate for the data type appears:
The registry editor adds the ORACLE_SID parameter.
The registry exits.
WARNING: If anything goes wrong while operating the new database without a backup, you must repeat the database creation procedure. Back up your database now to prevent such damage. |
To back up the new database:
C:\MYDIR> ORADIM80 -SHUTDOWN -SID PROD -USRPWD PASSWORD -SHUTTYPE SRVC,INST -SHUTMODE I
WARNING: Although ORADIM80 returns the prompt immediately, you must wait for the database and the service to stop completely before continuing to Step 2. Wait until the Control Panel indicates the OracleServicePROD service has stopped. If you do not do this, the backup may be useless as it was taken while data was being written to the data files. |
You can now start the database again, create users and objects
if necessary, make any other changes, and use the database. Ensure you
make a database backup, if possible, after making any significant change
to the database, such as switching the ARCHIVELOG mode or adding a tablespace
or data file.
Additional
Information:
See Chapter 13, "Backing Up and
Recovering Database Files", Oracle8
Concepts, Oracle8 Backup and Recovery,
and Oracle8 Administrator's Guide
for more information on archiving and backup/recovery.
|
ORADIM80 is a command line tool that is only available on Oracle8 Enterprise Edition for Windows NT. This is the only manual in the documentation set where you will find information on this tool. ORADIM80 and Oracle Database Assistant perform similar tasks. The following table compares what you can do with these two tools:
ORADIM80 | Oracle Database Assistant |
---|---|
When you use ORADIM80, a log file called ORADIM80.LOG is opened in ORACLE_HOME\RDBMS80. All operations (both successful and failed) are logged in this file. You must check this file to verify the success of an operation. The following sections describe the ORADIM80 commands and parameters. Note that each command is preceded by a dash (-).
To Get a List of ORADIM80 Parameters And Descriptions: | ||
Use this syntax: |
ORADIM80 -? | -H | -HELP | |
Example: |
C:\MYDIR> ORADIM80 -? |
To Modify an Instance: | ||
Use this syntax: |
ORADIM80 -EDIT -SID SID [-NEWSID
NEWSID] -INTPWD INTERNAL_PWD
[-STARTMODE AUTO, MANUAL][-PFILE FILENAME] |
|
Example to modify an instance called PROD: |
C:\MYDIR> ORADIM80 -EDIT -SID PROD -NEWSID LYNX -INTPWD MYCAT123 -STARTMODE AUTO -PFILE C:\MYDIR\DATABASE\INITLYNX.ORA |
|
Note: |
You can modify an existing instance, in this example PROD, to change such values as the instance name, the password, the startup mode, and the number of users. |
|
Syntax description: |
indicates that you want to modify an instance. This is a mandatory parameter. |
|
|
is the name of the instance you want to modify. This is a mandatory parameter. |
|
|
is the new instance name. This is an optional parameter. |
|
|
is the password for the INTERNAL account. This is a mandatory parameter unless DBA_AUTHORIZATION or DBA_SID_AUTHORIZATION is set to BYPASS in the registry. Note: This parameter cannot be used to change the password, as it does not overwrite the existing password file. It can only create a new password file when none already exists. To create a new password file, use ORAPWD80, or delete the Oracle8 services (this action implicitly deletes the associated password file) and then recreate the Oracle8 services (this action implicitly creates the associated password file). See the section, "Password Utility (ORAPWD80)" in Chapter 3, "Database Tools Overview". |
|
|
indicates whether to start the instance automatically or manually at startup. The default setting is MANUAL. |
|
|
is the INITSID.ORA file to be used with this instance. Ensure you specify the complete pathname of this file, including drive letter. |