Oracle8i Administrator's Guide Release 2 (8.1.6) for Windows NT A73008-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 database, 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. |
Although it is possible for Oracle to access database files on remote computers using Universal Naming Convention (UNC), it is not recommended because of performance and network reliability concerns.
UNC is a PC format for specifying the location of resources on a local area network. UNC uses the following format:
\\SERVER-NAME\SHARED-RESOURCE-PATHNAME
For example, to access the file SYSTEM01.DBF in the directory C:\ORACLE\ORADATA\ORCL on the shared server ARGON, you reference the file as:
\\ARGON\ORACLE\ORADATA\ORCL\SYSTEM01.DBF
Note that the location of archive log files cannot be specified using UNC. If you set the LOG_ARCHIVE_DEST_n initialization parameter to a UNC specification, the database does not start and you receive the following errors:
ORA-00256: error occurred in translating archive text string '\meldell\rmdrive' ORA-09291: sksachk: invalid device specified for archive destination OSD-04018: Unable to access the specified directory or device O/S-Error: (OS 2) The system cannot find the file specified
Ensure that you set the LOG_ARCHIVE_DEST_n initialization parameter to a mapped drive.
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:
This chapter describes running Oracle Database Configuration Assistant in standalone mode (that is, after installation). See Chapter 4 of the Oracle8i Installation Guide for Windows NT for information on running Oracle Database Configuration Assistant during installation to create a database.
Note:
To create a database using Oracle Database Configuration Assistant:
The Oracle Database Configuration Assistant Welcome page appears.
The following page appears:
Both the Typical option (through its Create new database files suboption) and the Custom option enable you to specify the type of environment in which to operate your Oracle8i database:
Sample OLTP and Warehousing database schemas are available on the CD-ROM. After you finish creating your Oracle8i database with Oracle Database Configuration Assistant, you can import the appropriate sample schema.
If you selected multipurpose, you do not need to import a sample schema; one is already provided with your database.
To import an OLTP or DSS sample schema into your Oracle8i database:
C:\> SQLPLUS
Enter user-name: SYSTEM/PASSWORD
SQL> CREATE USER SAMPLE_USER IDENTIFIED BY PASSWORD; SQL> GRANT RESOURCE TO SAMPLE_USER; SQL> GRANT CONNECT TO SAMPLE_USER;
where SAMPLE_USER is SAMPLEOLTP for the OLTP sample schema or SAMPLESTAR for the DSS sample schema.
SQL> EXIT
C:\ORACLE\ORA81\ASSISTANTS\DBCA\SAMPLES> IMP SAMPLE_USER/PASSWORD FILE=SAMPLE.DMP FULL=Y LOG=MYIMP.LOG
The Change Database Configuration option enables you to perform the following procedures:
This enables an Oracle8i database to support Advanced Replication functionality and the following as-yet-unconfigured options that you installed from your CD-ROM:
These options (if installed during a separate installation from Oracle8i Enterprise Edition) are not automatically configured during installation. If you installed Oracle options through the Oracle8i Enterprise Edition Typical installation type on the CD-ROM, your options were automatically configured for the starter database.
This lets you choose whether to enable or disable multithreaded server support in your Oracle8i database.
Multithreaded server (MTS) support enables multiple 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. No dedicated server process exists for each remaining user process 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.
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:
C:\> ORADIM -SHUTDOWN -SID ORCL -USRPWD PASSWORD -SHUTTYPE INST -SHUTMODE I
If you are using the starter database ORCL as the basis for your new database, copy INIT.ORA file:
C:\ORACLE\AORACLE_HOME\DMIN\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 NT" 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 service if you want to do one of the following:
Before you create the database, first create a Windows NT service to run the database. This service is the Oracle8i database process, ORACLE.EXE, installed in the form of a Windows NT service.
Use ORADIM to create the service. After it has been created, the service starts automatically. See "Using ORADIM to Administer an Oracle Instance" for information on how to use ORADIM.
To create and start an Oracle service:
C:\> ORADIM -NEW -SID PROD -INTPWD PASSWORD -STARTMODE MANUAL -PFILE C:\ORACLE\ADMIN\PROD\PFILE\INIT.ORA
Note that the previously-created INIT.ORA file is specified, with complete path, including drive name. You can check if the service is started in the services window of the Windows NT Control Panel.
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".
Additional Information:
If creating a tablespace in a raw partition, modify the data file names with a naming convention of \\.\DRIVE_LETTER: or \\.\SYMBOLIC LINK NAME. See Appendix D, "Storing Tablespaces on Raw Partitions" for more information on storing tablespaces in raw partitions. |
To use the BUILD_PROD.SQL script to create a database:
You can also check the status of the service by entering the following at the MS-DOS command prompt:
C:\> NET START
A list of all Windows NT services currently running on the system appears. If OracleServicePROD is missing from the list, enter:
C:\> NET START ORACLESERVICEPROD
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 Service".
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;
Note: You may see messages such as ORA-01432: public synonym to be dropped does not exist while the CATALOG.SQL, CATPROC.SQL, and CATREP.SQL scripts are running. These are information messages and are intended to occur while creating a new database. If you see any unusual errors while examining the BUILD_PROD.LOG log file in step 10, see Oracle8i Error Messages for suggested actions. |
SQL> @C:\ORACLE\ORA81\RDBMS\ADMIN\
CATPROC.SQL;
SQL> @C:\ORACLE\ORA81\RDBMS\ADMIN\
CATREP.SQL;
SQL> SPOOL OFF
SQL> EXIT
C:\> ORADIM -EDIT -SID PROD -STARTMODE AUTO
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:\> REGEDT32
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.
To create the ORACLE_SID parameter:
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.
To back up the new database:
C:\> ORADIM -SHUTDOWN -SID PROD -USRPWD PASSWORD -SHUTTYPE SRVC,INST -SHUTMODE I
WARNING: Although ORADIM 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. |
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 11, "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. |
ORADIM is a command line tool that is only available with the Oracle8i database.
You only need to use ORADIM if you are manually creating, deleting, or modifying databases. Oracle Database Configuration Assistant is an easier tool to use for this purpose.
ORADIM and Oracle Database Configuration Assistant perform similar tasks. The following table compares what you can do with these tools.
ORADIM | Oracle Database Configuration Assistant |
---|---|
When you use ORADIM, a log file called ORADIM.LOG opens in ORACLE_BASE\ORACLE_HOME\DATABASE, or in the directory specified by the ORA_CWD registry parameter. All operations, whether 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 ORADIM commands and parameters. Note that each command is preceded by a dash (-).
To create an instance... | ||
Use this syntax: |
|
|
Example to create an instance called PROD: |
|
|
Syntax description: |
Indicates that you want to create a new instance. This is a mandatory parameter. |
|
|
The name of the instance you want to create. You must specify either this parameter or the -SRVC parameter described below. |
|
|
The name of the service you want to create (OracleServiceSID). You must specify either this parameter or the -SID parameter described above. |
|
|
The password for the INTERNAL account. The -INTPWD option is not required. If you do not specify it, operating system authentication is used, and no password is required. See "Automatically Enabling Operating System Authentication During Installation" for a description of features. |
|
|
The number of users defined in the password file. The default is 5. |
|
|
Indicates whether to start the instance automatically or manually at startup. The default setting is MANUAL. |
|
|
The INIT.ORA file to be used with this instance. Ensure that you specify the complete pathname of this file, including drive letter. |
|
|
Indicates whether to stop the service or the instance. Both can be specified. This is a mandatory parameter. |
To modify an instance... | ||
Use this syntax: |
|
|
Example to modify an instance called PROD: |
|
|
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. |
|
|
The name of the instance you want to modify. This is a mandatory parameter. |
|
|
The new instance name. This is an optional parameter. |
|
|
The password for the INTERNAL account. 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 ORAPWD, or delete the Oracle8i services (this action implicitly deletes the associated password file) and then recreate the Oracle8i services (this action implicitly creates the associated password file). See "Password Utility (ORAPWD)" in Chapter 2, "Database Tools Overview". |
|
|
Indicates whether to start the instance automatically or manually at startup. The default setting is MANUAL. |
|
|
The INIT.ORA file to be used with this instance. Ensure that you specify the complete pathname of this file, including drive letter. |
|
![]() Copyright © 2000 Oracle Corporation. All Rights Reserved. |
|