
Before you can create an Oracle database, you need to configure the kernel for shared memory. In UNIX, shmmax needs to be set properly to allow for the total SGA set in the initialization file. In Windows NT, make sure that virtual memory isn't more than twice the physical memory on the system.
You also need to make certain decisions regarding how the database will be used and configured. These decisions should include the following:
| Protect the password for SYS |
Because SYS is the owner of the data dictionary, you should protect that password. Allowing the pass-word for SYS to get into the wrong hands can lead to tremendous damage to the database to the point that all data can be lost. The default password for SYS is CHANGE_ ON_INSTALL, whereas the default password for SYSTEM is MANAGER. |
| Prepare the operating system environment for database creation |
The operating system memory parameters should also be set properly. Check your operating system-specific documentation for the parameters to set. |
Prepare for and create a database (general steps)
| The DBA's operating system privileges |
Your database administrator login should have administrator privileges on the operating system to be able to create a data-base. |
The instance for the Oracle database is started by using a parameter file (initSID.ora) that should be customized for the database. You can use the operating system to create this file by making a copy of the one provided by Oracle on the distribution media, or by using the init.ora file from the seed database (if installed) as a template. Rename this file as initSID.ora (for example, for the SID ABCD, the name of the initialization file would be initABCD.ora), and then edit it to customize it for your database.
| Change these parameters from their default values |
Most people make the mistake of leaving the initialization parameters to their default value. These default values aren't ideal for most systems. You need to carefully choose the initialization parameters with your data-base environment in mind. |
The parameter file is read-only at instance startup. If it's modified,
you need to shut down and restart the instance for the new values
to take effect. You can edit the parameter file with any operating
system editor. Most parameters have a default value, but some
parameters need to be modified with uniqueness and performance
in mind. Table 2.1 lists parameters that should be specified.
| DB_NAME | Database identifier (maximum of eight characters). To change the name of an existing database, use the CREATE CONTROLFILE statement to recreate your control file(s) and specify a new database name. |
| DB_DOMAIN | The network domain where the database is created. |
| CONTROL_FILES | Names of the control files. If you don't change this parameter, the control files of other databases can be overwritten by the new instance, making the other instances unusable. |
| DB_BLOCK_SIZE | Size in bytes of Oracle database blocks. |
| SHARED_POOL_SIZE | Size in bytes of the shared pool. |
| BACKGROUND_DUMP_DEST | Location where background trace files will be placed. |
| USER_DUMP_DEST | Location where user trace files will be placed. |
| DB_BLOCK_BUFFERS | Number of buffers in the buffer cache. |
| COMPATIBLE | Version of the server that this instance is compatible with. |
| IFILE | Name of another parameter file included for startup. |
| MAX_DUMP_FILE_SIZE | Maximum size in OS blocks of the trace files. |
| PROCESSES | Maximum number of OS processes that can simultaneously connect to this instance. |
| ROLLBACK_SEGMENTS | Rollback segments allocated to this instance. Refer to the Oracle8 tuning manual for information and guidelines on determining the number and size of rollback segments based on the anticipated number of concurrent transactions. |
| LOG_BUFFER | Number of bytes allocated to the redo log buffer in the SGA. |
| LOG_ARCHIVE_START | Enable or disable automatic archiving if the database is in ARCHIVELOG mode. |
| LOG_ARCHIVE_FORMAT | Default filename format used for archived logs. |
| LOG_ARCHIVE_DEST | Location of archived redo log files. |
| LICENSE_MAX_USERS | Maximum number of users created in the database. |
| LICENSE_MAX_SESSIONS | Maximum number of concurrent sessions for the instance. |
| LICENSE_SESSIONS_WARNING | Warning limit on the concurrent sessions. |
| Database names should be unique |
Attempting to mount two databases with the same name will give you the error ORA-01102: cannot mount database in EXCLUSIVE mode during the second mount. |
| Setting the parameters |
The ideal values for these parameters are application dependent and are discussed in more detail in Chapter 21, "Identifying and Reducing Contention," and Chapter 22, "Tuning for Different Types of Applications." Setting these values is based on trial and error. For DSS systems, it's recommended that you choose a large value for these parameters; for OLTP systems, choose a small value for these parameters. |
The following is a sample init.ora file:
db_name = SJR db_files = 1020 control_files = (E:\ORANT\database\ctl1SJR.ora, E:\ORANT\database\ctl2SJR.ora) db_file_multiblock_read_count = 16 db_block_buffers = 550 shared_pool_size = 9000000 log_checkpoint_interval = 8000 processes = 100 dml_locks = 200 log_buffer = 32768 sequence_cache_entries = 30 sequence_cache_hash_buckets = 23 #audit_trail = true #timed_statistics = true background_dump_dest = E:\ORANT\rdbms80\trace user_dump_dest = E:\ORANT\rdbms80\trace db_block_size = 2048 compatible = 8.0.3.0.0 sort_area_size = 65536 log_checkpoint_timeout = 0 remote_login_passwordfile = shared max_dump_file_size = 10240
| %pfile_dir% | ?/dbs | ?/database |
| %config_ora_file% | configSID.ora (created next) | configSID.ora (created next) |
| %rollback_segs% | r01, r02, | r01, r02, |
| %init_ora_comments% | # | # |
Create configSID.ora
Create the database script
When it's run, the crdbSID.sql does the following:
Creating a database is the first step in organizing and managing a database system. You can use the following guidelines for database creation on all operating systems. Check your operating system-specific documentation for platform-specific instructions.
Before creating a database, take a complete backup of all your existing databases to protect against accidental modifications/deletions of existing files during database creation. The backup should contain parameter files, data files, redo log files, and control files.
| Mirror your control and redo log files |
The control files and redo log files help you recover your database. To keep from losing a control file, keep at least two copies of it active on different physical devices. Also, multiplex the redo log files and place the log group members on different disks. |
Also decide on a backup strategy and the size that will be required for online and archived redo logs. Backup strategies are discussed in Chapter 13, "Selecting and Implementing a Backup Strategy."
You organize the database contents by using tablespaces. On some platforms, the Oracle installer creates a seed database, which has a number of predefined tablespaces. The tablespace structure should be carefully chosen by considering the characteristics of the data to minimize disk contention and fragmentation, and to improve overall performance.
In addition to the SYSTEM tablespace provided with the installation, Table 2.2 describes several other suggested tablespaces. You can create these tablespaces by using the CREATE TABLESPACE command, as shown later in the section "Using the CREATE DATABASE Command."
| Use multiple tablespaces |
Production data and indexes should be stored in separate tablespaces. |
| TEMP | Used for sorting and contains temporary segments |
| RBS | Stores additional rollback segments |
| TOOLS | Tables needed by the Oracle Server tools |
| APPS_DATA | Stores production data |
| APPS_IDX | Store indexes associated with production data in APPS_DATA tablespace |
Separating groups of objects, such as tables with different fragmentation
propensity, can minimize contention and fragmentation. You can
use Table 2.3 as a guideline for separating objects.
| Data dictionary | Zero |
| Rollback segments | Medium |
| Temporary segments | High |
| Application data | Low |
You can reduce disk contention by being familiar with the way in which data is accessed and by separating the data segments into groups based on their usage, such as separating
Database sizing issues should be considered to estimate the size of the tables and indexes.
After the database is created, you can't change the character set without recreating the database. If users will access the database by using a different character set, the database character set should be the same as or a superset of all the character sets that would be used. Oracle8 uses encoding schemes that can be commonly characterized as single-byte 7-bit, single-byte 8-bit, varying-width multi-byte, and fixed-width multi-byte. Refer to the Oracle8 Server reference guide for limitations on using these schemes.
SEE ALSO
For more information on Oracle's National Language Support (NLS) feature and character sets,
Make sure that the following parameters are set properly in the environment. If the following parameters aren't set properly, your instance won't start or the wrong instance might start:
After the following environment variables are verified, you can connect to Server Manager as internal and STARTUP NOMOUNT.
Set the environment variables in UNIX
ORACLE_SID XXX; export ORACLE_SID
setenv ORACLE_SID XXX
Echo $ORACLE_SID
$svrmgrl SVRMGR> Connect internal SVRMGR> Startup nomount
C: > set ORACLE_SID=XXX
| Using Instance Manager on Windows NT |
On Windows NT, you can use the ORADIM utility (Instance Manager) to create a new instance and service for your database. |
You have several options to create the database:
After the database is created, you can run catalog.sql and catproc.sql while connected as the SYS of "internal" account to create the data dictionary views.
After the database is created, the SYSTEM tablespace and SYSTEM rollback segment will exist. A second rollback segment must be created and activated in the SYSTEM tablespace before any other tablespace can be created in the database. To create a rollback segment, from the Server Manager prompt type
Svrmgr>Create rollback segment newsegment Tablespace system Storage (...);
Refer to the SQL Language manual for the complete syntax of the CREATE ROLLBACK SEGMENT command.
This menu-driven method is probably the easiest because it runs the necessary scripts for any selected product. You can use this method to create a seed database. The installation guide for your platform should have specific instructions for this purpose.
| Oracle's installer isn't very flexible |
Using the Oracle installer for database creation isn't as flexible as the preceding methods in terms of specifying parameters such as MAXDATAFILES. If this method is used, you'll have to create the other standard non-system tablespaces. |
You also can create a database by using the SQL command CREATE DATABASE:
CREATE DATABASE database
[CONTROLFILE [REUSE]]
[LOGFILE filespec[, ...]]
MAXLOGFILES integer
MAXLOGMEMBERS integer
MAXLOGHISTORY integer
DATAFILE filespec[, ...]
MAXDATAFILES integer
MAXINSTANCES integer
ARCHIVELOG|NOARCHIVELOG
EXCLUSIVE
CHARACTERSET charset
Table 2.4 lists the settings available with the CREATE DATABASE
command.
| database | The name of the database to be created. |
| CONTROLFILE REUSE | Specifies that existing control files specified by the CONTROL_FILES parameter can be reused. If REUSE is omitted and control files exist, you'll get an error. |
| LOGFILE | Specifies one or more files to be used as redo log files. Each filespec specifies a redo log file group containing one or more redo log file members or copies. If you omit this parameter, Oracle will create two redo log file groups by default. |
| MAXLOGFILES | Specifies the maximum number of redo log file groups that can ever be created for this database. |
| MAXLOGMEMBERS | Specifies the maximum number of members or copies for a redo log file group. |
| MAXLOGHISTORY | This parameter is useful only if you're using the PARALLEL SERVER option and in parallel and ARCHIVELOG mode. It specifies the maximum number of archived redo log files for automatic media recovery. |
| DATAFILE | Specifies one or more files to be used as data files. |
| MAXDATAFILES | Specifies the maximum number of data files that can ever be created for this database. |
| MAXINSTANCES | Specifies the maximum number of instances that can simultaneously have this parameter mounted and open. |
| ARCHIVELOG or NOARCHIVELOG | Establishes the mode for the redo log files groups. NOARCHIVELOG is the default mode. |
| EXCLUSIVE | Mounts the database in the exclusive mode after it's created. In this mode, only one instance can access the database. |
| CHARACTERSET | Specifies the character set the database uses to store the data. This parameter can't be changed after the database is created. The supported character sets and default value of this parameter are operating system dependent. |
Oracle performs the following operations when executing the CREATE DATABASE command:
| The data dictionary may not be created automatically |
You need to run the SQL scripts to create the data dictionary (catalog.sql and catproc.sql) if these scripts aren't run from your database creation script. |
The following example shows how to create a simple database:
create database test
controlfile reuse
logfile GROUP 1
('C:\ORANT\DATABASE\log1atest.ora',
'D:\log1btest.ora') size 500K reuse,
GROUP 2
( 'C:\ORANT\DATABASE\log2atest.ora',
'D:\log2btest.ora' ) size 500K reuse
datafile 'C:\ORANT\DATABASE\sys1test.ora'
Âsize 10M reuse autoextend on
next 10M maxsize 200M
character set WE8ISO8859P1;
This command creates a database called TEST with one data file (sys1test.ora) that's 10MB in size and multiplexed redo log files with a size of 500KB each. The character set will be WE8ISO8859P1.
The following steps can be used to create a database called MARS, using the starter (seed) database ORCL. If you don't have the starter database, you can use the sample initialization file INITORCL.80 in the c:\orant\database directory.
Create a database in Windows NT with BUILD_ALL.sql
C: > oradim80 -NEW -SID TEST -INTPWD password -STARTMODE AUTO -PFILE c:\orant\database\inittest.ora
This command creates a new service called TEST, which is started automatically when Windows NT starts. INTPWD is the password for the "internal" account; the PFILE parameter provides the full pathname of initSID.ora.
| When to create Oracle services |
An Oracle serviceshould be created and started only if you want to create a database and don't have any other database on your system, or copy an existing database to a new database and retain the old data-base. |
C: > Set ORACLE_SID=MARS
C: > svrmgr30 C: > connect internal/password
SVRMGR> STARTUP NOMOUNT PFILE=c:\mars\initmars.ora
SVRMGR> SPOOL build.log SVRMGR> @BUILD_MARS.SQL
SVRMGR> @%RDBMS80%\ADMIN\CATALOG.SQL
SVRMGR> @%RDBMS80%\ADMIN\CATPROC.SQL
All the MAX parameters are set when the database is created. To determine what parameters your database has been created with, execute the following:
SVRMGR> Alter database backup controlfile to trace
This command will create an SQL script that contains several database commands:
CREATE CONTROLFILE REUSE DATABASE "SJR" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXDATAFILES 254
MAXINSTANCES 1
MAXLOGHISTORY 899
LOGFILE
GROUP 1 'E:\ORANT\DATABASE\LOGSJR1.ORA' SIZE 200K,
GROUP 2 'E:\ORANT\DATABASE\LOGSJR2.ORA' SIZE 200K
DATAFILE
'E:\ORANT\DATABASE\SYS1SJR.ORA',
'E:\ORANT\DATABASE\RBS1SJR.ORA',
'E:\ORANT\DATABASE\USR1SJR.ORA',
'E:\ORANT\DATABASE\TMP1SJR.ORA',
'E:\ORANT\DATABASE\INDX1SJR.ORA'
;
To generate SQL statements for all the objects in the database, Export must query the data dictionary to find the relevant information about each object. Export uses the view definitions in CATEXP.SQL to get the information it needs. Run this script while connected as SYS or "internal." The views created by CATEXP.SQL are also used by the Import utility. Chapter 25, "Using SQL*Loader and Export/Import," discusses more about Oracle's Export and Import utilities.
| CATALOG.SQL and CATEXP.SQL views don't depend on each other |
You don't need to run CATALOG.SQL before running CATEXP.SQL, even though CATEXP.SQL is called from within CATALOG.SQL. This is because no view in CATEXP.SQL depends on views defined in CATALOG.SQL. |
Create an identical copy of database but with no data
C: > exp system/manager full=y rows=n file=fullexp.dmp
C: > imp system/manager full=y rows=n file=fullexp.dmp
| Creating a new database on the same machine |
If the new database is to be created on the same machine as the old database, you need to pre-create the new tablespaces because the old data files are already in use. |
Use Instance Manager to create a new database in Windows NT
The Oracle Database Assistant can be used to create a database at any time.
Use Oracle Database Assistant to create a new database in Windows NT
In Windows NT, you can set the default SID by setting the Registry entry ORACLE_SID.
Updating ORACLE_SID in the Windows NT Registry
| Don't modify the Registry unless you know what you're doing! |
Be extremely careful when working with the Registry. Improperly set keys may prevent Windows NT from booting up. |
After the database is created, regularly check the status of the database by examining its data dictionary and the alert log.
The data dictionary is one of the most important parts of the Oracle database. The data dictionary is a set of tables and views that you can use to look up valuable information about the database. You can use the data dictionary to obtain various types of information, including:
The catalog.sql and catproc.sql scripts can be used during or after database creation to create the commonly used data dictionary views and for PL/SQL support, respectively.
The data dictionary contains a set of base tables and associated set of views that can be placed in the following categories:
| USER_xxx | Views accessible by any user that provide information on objects owned by them |
| ALL_xxx | Views accessible by any user that provide information on all objects accessible by them |
| DBA_xxx | Views accessible by any user that provide information on any database object |
| Which data dictionary objects do I have? |
All the data dictionary tables and views are owned by SYS. You can query the DICTIONARY table to obtain the list of all dictionary views. |
The following examples show how to query the dictionary tables to obtain information about the database:
Select * from dba_rollback_segs;
Select * from dba_data_files;
Select * from dba_tablespaces;
Select * from dba_users;
Select * from v$database;
Select * from v$parameter;
When diagnosing a database problem, the first place to look for information and errors is the alert log (the name is operating system dependent). If this file isn't present, Oracle will automatically create it during database startup. This file can point you to the location of trace files, which can give a lot of insight into the problems encountered. It also contains additional information to indicate the status of the database and what's now happening in the database.
| Locating trace files |
The trace file would be located in the directory specified by BACKGROUND_DUMP_DEST, USER_DUMP_DEST, or CORE_DUMP_DEST, depending on the exact error and its cause. |
SEE ALSO
For more information on the contents and usage of the alert log,
When the database is started, the following information is recorded in the alert log:
In general, the alert log records all important incidents of the database, including:
Each entry has a timestamp associated with it, and each non-error message has an entry marking its beginning and another entry marking its successful completion. You should frequently check this file for error messages for which the alert log will point to a trace file for more information.
The following is a sample alert log:
![]() | File header showing information about your system |
![]() | Initialization parameters |
![]() | Database in nomount state and CREATE DATABASE command. |
LOGFILE 'E:\ORANT\database\logSJR1.ora' SIZE 200K,
'E:\ORANT\database\logSJR2.ora' SIZE 200K
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXLOGHISTORY 1
DATAFILE 'E:\ORANT\database\Sys1SJR.ora' SIZE 50M
MAXDATAFILES 254
MAXINSTANCES 1
CHARACTER SET WE8ISO8859P1
NATIONAL CHARACTER SET WE8ISO8859P1
Thu Jan 29 09:33:50 1998
Successful mount of redo thread 1.
Thread 1 opened at log sequence 1
Current log# 1 seq# 1 mem# 0: E:\ORANT\DATABASE\LOGSJR1.ORA
Successful open of redo thread 1.
Thu Jan 29 09:33:50 1998
SMON: enabling cache recovery
Thu Jan 29 09:33:50 1998
create tablespace SYSTEM datafile
'E:\ORANT\database\Sys1SJR.ora' SIZE 50M
default storage (initial 10K next 10K) online
Thu Jan 29 09:34:10 1998
Completed: create tablespace SYSTEM datafile 'E:\ORANT\datab
Thu Jan 29 09:34:10 1998
create rollback segment SYSTEM tablespace SYSTEM
storage (initial 50K next 50K)
Completed: create rollback segment SYSTEM tablespace SYSTEM
Thu Jan 29 09:34:14 1998
Thread 1 advanced to log sequence 2
Current log# 2 seq# 2 mem# 0: E:\ORANT\DATABASE\LOGSJR2.ORA
Thread 1 cannot allocate new log, sequence 3
Checkpoint not complete
Current log# 2 seq# 2 mem# 0: E:\ORANT\DATABASE\LOGSJR2.ORA
Thread 1 advanced to log sequence 3
Current log# 1 seq# 3 mem# 0: E:\ORANT\DATABASE\LOGSJR1.ORA
Thread 1 advanced to log sequence 4
Current log# 2 seq# 4 mem# 0: E:\ORANT\DATABASE\LOGSJR2.ORA
© Copyright, Macmillan Computer Publishing. All rights reserved.