Oracle8(TM)
Getting Started for Windows NT Release 8.0.3 A54894-01 |
|
This chapter describes how to create a new database.
Specific topics discussed are:
Before creating a database, it is important to understand that starting with Oracle8, all mounted Oracle databases on a given computer 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 ORACLE.
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
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.
Oracle Corporation recommends you use Oracle Database Assistant as the simplest and quickest method to create or delete a database. During installation of Oracle8, you are prompted to create a database with this wizard if Oracle Installer detects that no database exists on your system. If you already have a database, or do not want to create a database during the installation process, you can choose to use this wizard to create a database at a later date.
Additional
Information:
See Oracle8 Installation for Windows NT CD-ROM Insert for information on how to install Oracle Database Assistant. |
To create a database using Oracle Database Assistant:
The Oracle Database Assistant welcome screen appears:
The following screen appears:
Additional
Information:
Click Help to access the online documentation. |
This section describes steps to create a database manually. An example is used in the following sections to demonstrate the commands involved. In this example:
The following table summarizes the database creation steps and indicates when each step is required, depending on if you want to:
CAUTION:
Database creation is an advanced function. Oracle Corporation recommends that you use the standard starter database and expand it to suit your needs if you are not an experienced user. |
Note:
Assume all operations are performed in the C:\MYDIR\ directory for examples used in the following sections. |
Note:
This step is necessary only if you want to copy the contents of an existing database to a new database. |
To use the Export utility to export all data from an existing database to the new database:
C:\MYDIR> SET ORACLE_SID=ORCL
C:\MYDIR> 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.
Note:
This step is necessary only if you want to replace an existing database. |
To delete database files:
C:\MYDIR> ORADIM80 -SHUTDOWN -SID ORCL -USRPWD PASSWORD -SHUTTYPE INST -SHUTMODE I
If you are replacing the starter database ORCL, copy INITORCL.ORA to INITPROD.ORA and modify the file. You must modify the CONTROL_FILES initialization parameter in the INITPROD.ORA file. Modifying the initialization parameters DB_NAME, GLOBAL_NAMES, and DB_FILES is highly recommended. If you do not have an existing INITORCL.ORA file to copy, create INITPROD.ORA.
Additional
Information:
See the Appendix B, "Initialization Parameter Files" for information on how to create an initialization parameter file. |
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. For example, CONTROL_FILES = (ORACLE_HOME\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 to be executed in "Step 5: Prepare CREATE DATABASE SQL Statement". This name does not need to match the SID of the database service. Oracle Corporation recommends that you give a unique database name to each database. For example, DB_NAME=PROD_DB. 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 Server 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 |
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.
To create a Windows NT service
C:\MYDIR> ORADIM80 -NEW -SID PROD -INTPWD PASSWORD -STARTMODE AUTO -PFILE ORACLE_HOME\DATABASE\INITPROD.ORA
Note that the previously created INITPROD.ORA file is specified, with complete path.
C:\MYDIR> SET ORACLE_SID=PROD
Additional
Information:
See the section, "Using ORADIM80" in Chapter 4, "Database Tools". |
You can enter the CREATE DATABASE statement directly in Server Manager. Alternatively, you can use a text editor to create a SQL script containing the CREATE DATABASE statement, and then execute the script in Server Manager. In this example, this script is called CREATE_PROD_DB.SQL, located in the C:\MYDIR directory.
Additional
Information:
See Oracle8 Server SQL Reference for the complete syntax of the CREATE DATABASE statement. |
The text of the CREATE_PROD_DB.SQL script is given below.
CREATE DATABASE PROD_DB LOGFILE 'C:\MYDIR\DATABASE\LOG1PROD.ORA' SIZE 500K, 'C:\MYDIR\DATABASE\LOG2PROD.ORA' SIZE 500K MAXDATAFILES 100 DATAFILE 'C:\MYDIR\DATABASE\SYS1PROD.ORA' SIZE 20M NOARCHIVELOG CHARACTER SET WE8ISO8859P1;
This statement creates a database where:
Parameter |
Description |
---|---|
PROD_DB |
Is the name of the database (the same name as entered for DB_NAME in the INITPROD.ORA file). |
LOGFILE |
Specifies two (minimum required) online redo log files of 500 KB each in size. It also reserves space for 100 data files in the control file, and creates a single data file of 20 MB in size, to be used for the SYSTEM tablespace. |
MAXDATAFILES |
Sets the maximum number of data files that can ever be used by the new database. If you subsequently want to increase this limit, you must re-create the control files of the database. See the explanation of the CREATE CONTROLFILE statement in Oracle8 Server SQL Reference for more information. The default value of MAXDATAFILES on Windows NT is 32, and the maximum value is 1022. |
NOARCHIVELOG |
Is the default setting. If you want to enable archiving, change this entry to ARCHIVELOG. |
CHARACTER SET |
WE8ISO8859P1 is the recommended 8-bit character set for Western European languages, which includes English. This 8-bit character set is recommended over the default set US7ASCII, which can handle 7-bit characters only and is therefore of little use for languages other than English. Note the default character set used by Oracle client applications on various Windows operating systems is WE8ISO8859P1. |
Note:
The file names, locations, and sizes in the CREATE_PROD_DB.SQL script are only examples. Your database will have different values to suit your requirements. |
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:\MYDIR> SET ORACLE_SID=PROD
The second command overrides the setting of the LOCAL environment variable, if it is set in the registry or the AUTOEXEC.BAT file. Without overriding LOCAL, it is possible to receive an ORA-3121, ORA-9352, ORA-12154, or ORA-12203 error in Step 3.
Additional
Information:
See Oracle8 Server Error Messages for information on the meaning of each error. |
C:\MYDIR> SVRMGR30 SVRMGR> CONNECT INTERNAL/PASSWORD
The password is the one you previously used to create the service, with the ORADIM80 -NEW command. You should see the message Connected to an idle instance.
SVRMGR> STARTUP NOMOUNT PFILE=ORACLE_HOME\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 must be no space characters around the equal sign (=).
SVRMGR> SPOOL CREATE_PROD_DB.LOG SVRMGR> @CREATE_PROD_DB.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:
From the MS-DOS command prompt, enter:
C:\> NET HELPMSG n
or
From the Server Manager prompt, enter:
SVRMGR> HOST NET HELPMSG n
where n is the operating system error number. See the section, "Operating System Permission Issues" in Appendix G, "Troubleshooting" for more information.
Note:
You must correct these problems before attempting to re-create a new database. |
SVRMGR> @%ORACLE_HOME %\RDBMS80\ADMIN\CATALOG.SQL SVRMGR> @%ORACLE_HOME%\RDBMS80\ADMIN\CATPROC.SQL
The first script generates the data dictionary, the second script installs the objects used by the Oracle8 database's PL/SQL functionality.
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 CREATE_PROD_DB.LOG log file, see Oracle8 Server Error Messages for suggested actions.
|
You can choose to import the full export created in the section "Step 1: Export an Existing Database" into the new database.
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.
To make a change in the registry:
C:\MYDIR> REGEDT32
If you do not have ORACLE_SID because this is the first database on your system, you must create the ORACLE_SID parameter, called a value in Windows NT terminology.
WARNING:
If anything goes wrong while operating the new database without a backup, must repeat the database creation procedure. Back up your database now to prevent such a disaster. |
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 12, "Backing Up and Recovering Database Files", Oracle8 Server Concepts, Oracle8 Server Backup and Recovery Guide, and Oracle8 Server Administrator's Guide for more information on archiving and backup/recovery.
|
|
Copyright © 1997 Oracle Corporation. All Rights Reserved. |
|