| Oracle8i Personal Edition Administrator's Guide Release 2 (8.1.6) for Windows 98 A85313-01 |
|
This chapter describes how to create a database with Oracle Database Configuration Assistant or the BUILD_DB.SQL script after installing Oracle.
Specific topics discussed are:
Before you create a database, consider the following requirements described below.
With Oracle8i databaseOracle8i, all mounted Oracle databases in a network must have unique database names.
A name is associated with a database at database creation time and stored in its control files. If the database keyword is provided in the CREATE DATABASE statement or when prompted by the Oracle Database Configuration Assistant, that value becomes the name for that database. If not, the program uses the value of the DB_NAME parameter in the INIT.ORA file.
If you attempt to mount two Oracle8i 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 Oracle8i databases on the same computer, but located in different Oracle homes, the following rules apply:
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 only exists for Oracle8i instances. Any Oracle7 instances running simultaneously with an Oracle8i instance are not subject to this restriction.
|
Note: The directory path examples in this chapter follow Optimal Flexible Architecture (OFA) guidelines (for example, ORACLE_BASE\ORACLE_HOME\RDBMS\ADMIN). If you specified non-OFA compliant directories during installation, your directory paths will differ. See "OFA and Multiple Oracle Home Configurations" for information. |
You can choose either of the following tools to create a database:
Use Oracle Database Configuration Assistant to create a database, because it is the easier method.
If you want to create a database using command line tools, you can use the BUILD_DB.SQL script located in ORACLE_BASE\ORACLE_HOME\RDBMS\ADMIN.
Oracle Database Configuration Assistant enables you to:
|
Note: This chapter describes running Oracle Database Configuration Assistant in standalone mode (that is, after installation). See Chapter 4 of Oracle8i Installation Guide for Windows 98 for information on running Oracle Database Configuration Assistant during installation to create a database. |
To create a database using Oracle Database Configuration Assistant:
The Oracle Database Configuration Assistant Welcome page appears.
The following page appears:
The Delete a Database option of Oracle Database Configuration Assistant lets you quickly and easily delete all database files including the initialization parameter file.
This section describes how to create a new database manually using a SQL script. There are a number of ways to create a database depending on if you want to:
The following table summarizes the steps involved in creating a new database for each of these database creation scenarios. Each step is explained in detail in the following subsections.
An example is used in the following sections to demonstrate how 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:\ORACLE\ORADATA\ORCL directory) to a new database with a database name and SID of PROD located in the C:\ORACLE\ORADATA\PROD directory.
You will delete the starter database ORCL after you have created the PROD database.
|
Note: In this example, ORACLE_BASE is C:\ORACLE. See Chapter 3, "Multiple Oracle Homes and Optimal Flexible Architecture" for more information on ORACLE_BASE. |
Create the following directories in which to put the administration and database files for the new database PROD:
You only need to export an existing database if you want to copy its contents to a new database.
You can invoke the Export Utility by using either parameter mode or interactive mode. However, parameter mode is the recommended mode. Interactive mode provides less functionality than parameter mode and exists for backward compatibility only.
C:\> EXP SYSTEM/PASSWORD FILE=MYEXP.DMP FULL=Y LOG=MYEXP.LOG
C:\> EXP SYSTEM/PASSWORD
Enter only the command EXP SYSTEM/PASSWORD to begin an interactive session and let the Export Utility prompt you for the information it needs.
See Oracle8i Utilities for more information on using the Export Utility.
To export all data from an existing database to a new database:
C:\> SET ORACLE_SID=ORCL
C:\> EXP 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. All messages from the Export Utility are logged in the file MYEXP.LOG.
Deleting database files is only required when you want to 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:
If you are using the starter database ORCL as the basis for your new database, copy INIT.ORA file:
C:\ORACLE\ORACLE_HOME\ADMIN\ORCL\PFILE\INIT.ORA
to
C:\ORACLE\ORACLE_HOME\ADMIN\PROD\PFILE\INIT.ORA
and modify the file as described in this section.
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 new INIT.ORA file. However, you can use the sample initialization parameter file INITSMPL.ORA provided in the ORACLE_BASE\ORACLE_HOME\ADMIN\SAMPLE\PFILE directory as the basis for the INIT.ORA file for the PROD database.
If you use INITSMPL.ORA as the basis for the INIT.ORA file, you must modify the following initialization parameters in the INIT.ORA file, or you will not be able to start the PROD database:
Modifying the DB_FILES initialization parameter is recommended to optimize performance.
| Initialization Parameter | Modification Instructions. |
|---|---|
|
DB_NAME |
This parameter indicates the name of the database, and must match the name used in the CREATE DATABASE statement in "Putting the CREATE DATABASE Statement in a Script". You give a unique database name to each database. You can use up to eight characters for a database name. The name does not need to match the SID of the database service.
|
|
INSTANCE_NAME |
|
|
SERVICE_NAMES |
|
|
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 run the CREATE DATABASE statement. Ensure that you specify the complete path and file name, including drive letter.
|
|
BACKGROUND_DUMP_DEST |
|
|
USER_DUMP_DEST |
|
|
DB_FILES |
Set this 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.
|
|
See Also::
Appendix B, "Oracle8i Database Specifications for Windows 98" and Oracle8i Reference for information on other initialization parameters that you may want to add or modify. |
You only need to create and start an Oracle instance if you want to do one of the following:
To create an Oracle instance:
C:\> ORADIM -NEW -SID PROD -INTPWD PASSWORD -STARTMODE MANUAL -PFILE C:\ORACLE\ADMIN\PROD\PFILE\INIT.ORA -ORA_REQ_HOME HOME_NAME
Note that the previously-created INIT.ORA file is specified, with complete path, including drive name.
C:\> 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.
Open the BUILD_DB.SQL script located in C:\ORACLE\ORA81\RDBMS\ADMIN and save it as BUILD_PROD.SQL.
This file becomes the basis for your script.
To prepare the CREATE DATABASE script:
Make the following changes to the BUILD_PROD.SQL script.
The following is the sample BUILD_DB.SQL script. Areas that you must modify to create a database called PROD are highlighted.
-- -- This file must be run out of the directory containing the -- initialization file. startup nomount pfile=C:\Oracle\ADMIN\SAMPLE\pfile\initsmpl.ora -- Create database create database SAMPLE controlfile reuse logfile 'C:\Oracle\ORADATA\SAMPLE\redo01.log' size 1M reuse, 'C:\Oracle\ORADATA\SAMPLE\redo02.log' size 1M reuse, 'C:\Oracle\ORADATA\SAMPLE\redo03.log' size 1M reuse datafile 'C:\Oracle\ORADATA\SAMPLE\system01.dbf' size 10M reuse autoextend on next 10M maxsize 200M character set WE8ISO8859P1; create rollback segment rb_temp storage (initial 100 k next 250 k); -- Create additional tablespaces ... -- USERs: Create user sets this as the default tablespace -- TEMP: Create user sets this as the temporary tablespace -- RBS: For rollback segments create tablespace users datafile 'C:\Oracle\ORADATA\SAMPLE\users01.dbf' size 3M reuse autoextend on next 5M maxsize 150M; create tablespace rbs datafile 'C:\Oracle\ORADATA\SAMPLE\rbs01.dbf' size 5M reuse autoextend on next 5M maxsize 150M; create tablespace temp datafile 'C:\Oracle\ORADATA\SAMPLE\temp01.dbf' size 2M reuse autoextend on next 5M maxsize 150M; create tablespace oem_repository datafile 'C:\Oracle\ORADATA\SAMPLE\oemrep01.dbf' size 3M reuse autoextend on next 5M maxsize 150M; create tablespace indx; datafile 'C:\Oracle\ORADATA\SAMPLE\indx01.dbf' size 2M reuse autoextend on next 5M maxsize 150M; -- next 5M maxsize 150M; alter rollback segment rb_temp online; -- Change the SYSTEM users' password, default tablespace and -- temporary tablespace. alter user system temporary tablespace temp; alter user system default tablespace users; -- 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 250K) tablespace rbs; create public rollback segment rb2 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb3 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb4 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb5 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb6 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb7 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb8 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb9 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb10 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb11 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb12 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb13 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb14 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb15 storage(initial 50K next 250K) tablespace rbs; create public rollback segment rb16 storage(initial 50K next 250K) tablespace rbs;
You will run this script at the SQL*Plus prompt in "Creating a Database".
To use the BUILD_PROD.SQL script to create a database:
C:\> SET ORACLE_SID=PROD
C:\> SQLPLUS SQL> CONNECT INTERNAL/PASSWORD
The password is the one that you used to create the service, with the ORADIM -NEW command in "Creating and Starting an Oracle Instance".
The message Connected appears.
SQL> SPOOL BUILD_PROD.LOG
SQL> @C:\ORACLE\ORA81\RDBMS\ADMIN\BUILD_PROD.SQL;
If the database is created successfully, the instance is started and the message Statement processed appears numerous times.
If you receive any errors, there are three possible causes, as illustrated below.
You must correct these problems before making another attempt to create a database.
SQL> @C:\ORACLE\ORA81\RDBMS\ADMIN\CATALOG.SQL;
SQL> @C:\ORACLE\ORA81\RDBMS\ADMIN\CATPROC.SQL;
SQL> SPOOL OFF
SQL> EXIT
You can import the full export created in "Exporting an Existing Database" into the new database.
You can also invoke the Import Utility, using parameter mode or interactive mode. Parameter mode is recommended, because interactive mode provides less functionality. Interactive mode exists solely for backward compatibility.
C:\> IMP SYSTEM/PASSWORD FILE=MYEXP.DMP FULL=Y LOG=MYEXP.LOG
C:\> IMP SYSTEM/PASSWORD
Enter only the command IMP SYSTEM/PASSWORD to begin an interactive session and let the Import Utility prompt you for the information it needs.
See Oracle8i Utilities for more information on using the Import Utility.
To import a database:
C:\> IMP 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:\> REGEDIT
The registry editor window appears.
See Appendix C, "Oracle8i Configuration Parameters and the Registry" for more information on the subkey locations for multiple Oracle homes.
See Also:
If you do not yet have the ORACLE_SID parameter, because this is the first database on your system, you must create it.
|
Additional Information: To create the ORACLE_SID parameter, see Appendix C "Adding a Registry Parameter with REGEDIT": |
To back up the new database:
See "Starting and Shutting Down a Database Using OSTART and OSTOP" for more information on how to use OSTART and OSTOP.
When the backup is complete, you can start the database again, create users and objects, if necessary, make any other changes, and use the database.
Be sure to back up the database backup after making any significant changes to the database, such as switching the ARCHIVELOG mode, or adding a tablespace or data file.
|
See Also::
Chapter 9, "Backing Up and Recovering Database Files", Oracle8i Concepts, Oracle8i Backup and Recovery Guide, and Oracle8i Administrator's Guide for more information on archiving and backup/recovery. |
|
|
![]() Copyright © 2000 Oracle Corporation. All Rights Reserved. |
|