Page 435
CAUTION |
Don't use the REUSE option of the CREATE DATABASE command: You could accidentally overwrite a file that is being used by another database. Instead, physically delete the file. You can use REUSE on some platforms when contiguous disk space that you want to reuse already has been allocated to a file. |
The default mode of the database is NOARCHIVELOG.
To specify the maximum number of data files, redo logs, and log members that can exist on the database, use the MAXDATAFILES, MAXLOGMEMBERS, and MAXLOGFILES parameters. If you specify lower limits, fewer resources are used in the SGA. The MAXINSTANCES parameter controls the maximum number of instances that can be connected to the database.
If you set these maximum limits lower than the predefined maximum as part of the CREATE DATABASE statement, you must re-create the control file manually to increase the limits. Instead, you should specify the limits by using the INIT.ORA parameters, which set the limits for that startup of the instance. That way, if you need to increase the limits, simply increase the INIT.ORA parameter and restart the instance.
TIP |
Leave the database mode set to NOARCHIVELOG ”the default ”in the CREATE DATABASE command. Change the mode to ARCHIVELOG when all the application objects are created and populated . This method improves performance while the application objects and data are loaded. |
To create a new database, follow these steps:
Page 436
CONNECT INTERNAL
STARTUP NOMOUNT PFILE=INITMYDB.ORA
CREATE DATABASE mydb DATAFILE `/disk03/mydb/system1.dbf' SIZE 20M LOGFILE `/disk04/mydb/log1.log', `disk05/mydb/log2.log' SIZE 512K;
After the database is created, it is immediately available for use; no further steps are necessary. At this stage, though, you have not created any objects on the database other than the ones automatically created by the CATALOG.SQL file. You now can start building the structure of your application database by defining tablespaces, usernames, tables, and so on.
You might need to run additional scripts to install the objects that enable the Procedural Database option or to store Oracle forms and other programs on the database.
Many objects are present on the database immediately after you create it:
Page 437
SYS has the default password CHANGE_ON_INSTALL, and SYSTEM has the default password MANAGER. To test whether the database was created, try to make a connection using these usernames and passwords. The default passwords should be changed. The SYS account is the Oracle user that owns the core data dictionary tables. Usually, there is little reason to use this account for day-to-day access to the database. The SYSTEM account does not own any of the core data dictionary tables. Instead, it uses a set of views created on the tables. These views help the DBA and developers obtain information on the structure of the database and its objects.
The first set of data files created as part of the CREATE DATABASE statement are allocated to the SYSTEM tablespace. Its initial contents usually are the data dictionary tables and other objects.
Additional rollback segments should be created on the database.
Along with the core data dictionary tables in the user account SYS, data dictionary views that make the information in the core tables easier to view and manage are created. Public synonyms are created for most of the data dictionary views to give Oracle users access to basic information on their user accounts.
Before you can use an Oracle database, an instance must be running. An instance is the combination of the Oracle background processes and the SGA. This section discusses how to initiate and shut down an instance.
For a database to be fully open and usable, the instance must be brought through three stages of startup:
The first stage, starting the instance, involves initiating the Oracle background processes and allocating memory for the SGA. During this stage, the INIT.ORA parameter file is used to determine the mode and instance initialization parameters, such as the sizes of the SGA structures in memory.
The second stage is mounting the database. It involves opening the control file (its location is specified in the INIT.ORA parameter file used in stage 1) and determining the locations and names of the other database and redo log files.
The third stage, opening the database, opens the actual database files and the redo logs. After this stage is complete, you can access and use the database objects.