0435-0437

Previous Table of Contents Next

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:

  1. Plan for the creation. Make sure that there is adequate disk space for the database. It is useful to do a sizing exercise to estimate the amount of storage required to hold the data for the application system. Determine the names and locations of the database files, the control file, and the redo log files.
    Make sure that the memory on the machine is enough for the new database, including the memory for the SGA, the PGA, and the programs on the database server machine. All the Oracle memory structures should fit into the machine's real memory.
  2. Make sure that the operating system user account you use has the INTERNAL privilege. This privilege enables your operating system account to run the CREATE DATABASE, STARTUP, and SHUTDOWN commands from the Instance Manager tool. Lower-level forms of the INTERNAL privilege are the SYSOPER and SYSDBA roles. INTERNAL, SYSOPER, and SYSDBA are assigned using operating system security mechanisms ”groups on a UNIX machine or process rights on a VMS machine. Operating system administrators generally grant your account these privileges.

Page 436

  1. Decide what the Oracle instance identifier is going to be, and set the appropriate operating system variable names. The Oracle SID should not have the same name as an existing instance on the same machine.
  2. Create the INIT.ORA file for your database. The easiest way to do this is to copy an existing INIT.ORA file. Rename this file to indicate the SID used for the instance ”for example, INITMYDB.ORA. Specify the name and location of the control file in the CONTROL_FILES parameter. Specify the name of the database ”typically, the same as the instance ID ”in the DB_NAME parameter. The name of the database must match the name given in the CREATE DATABASE command. The database name is recorded in all the database files, the control file, and the redo logs for the database. If you want to change the DB_BLOCK_SIZE parameter, you must do so now; you cannot modify it later.
  3. Initiate the Instance Manager tool, and make a connection to the Oracle RDBMS software by using the INTERNAL account. Although the syntax of the CONNECT command looks similar to a normal connect, no password is specified:
     CONNECT INTERNAL 
  4. Start the Oracle background processes, and allocate memory for the SGA by starting up the Oracle instance. Use this code, for example:
     STARTUP NOMOUNT PFILE=INITMYDB.ORA 
  5. Run the CREATE DATABASE statement with the parameters specific to your requirements. Use this code, for example:
     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.

The First Objects Created

Many objects are present on the database immediately after you create it:

  • The Oracle users SYS and SYSTEM
  • A tablespace called SYSTEM
  • A rollback segment called SYSTEM
  • The core data dictionary tables in the user account SYS
  • The CONNECT, RESOURCE, and DBA roles, which provide backward compatibility with granting privileges

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.

Startup and Shutdown

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.

Startup Stages

For a database to be fully open and usable, the instance must be brought through three stages of startup:

  1. Starting the instance
  2. Mounting the database
  3. Opening the database

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.

Previous Table of Contents Next


Oracle Unleashed
Oracle Development Unleashed (3rd Edition)
ISBN: 0672315750
EAN: 2147483647
Year: 1997
Pages: 391

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net