Planning for Database Creation
Consider what time zones your database must support.
Oracle uses a time zone file, located in the Oracle home directory, as the source of valid time zones. If you determine that you need to use a time zone that is not in the default time zone file (timezone.dat), but that is present in the larger time zone file (timezlrg.dat), then you must set the ORA_TZFILE environment variable to point to the larger file.
Manually Creating an Oracle Database
SQL scripts that are required for optimal operation of Oracle
Creating the Data Dictionary
Script Name Needed For Description
catalog.sql All databases Creates the data dictionary and public synonyms for many of its views
Grants PUBLIC access to the synonyms
catproc.sql All databases Runs all scripts required for, or used with PL/SQL
catclust.sql Real Creates Oracle9i Real Application Clusters data dictionary views
Application
Clusters
Creating Additional Data Dictionary Structures
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96536/ch53.htm
The "NO" Scripts
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96536/ch54.htm
Java Scripts
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96536/ch56.htm
Using Automatic Undo Management: Creating an Undo Tablespace
You must include the following initialization parameter if you want to operate your database in automatic undo management mode:
UNDO_MANAGEMENT=AUTO
If you want to create and name a specific tablespace for the undo tablespace, you can include the UNDO TABLESPACE clause at database creation time. If you omit this clause, and automatic undo management is specified, Oracle creates a default undo tablespace named SYS_UNDOTBS.
Using Oracle-Managed Files
指定 DB_CREATE_FILE_DEST or DB_CREATE_ONLINE_LOG_DEST_n 初始参数
CREATE DATABASE rbdb1
USER SYS IDENTIFIED BY pz6r58
USER SYSTEM IDENTIFIED BY y1tz5p
UNDO TABLESPACE undotbs
DEFAULT TEMPORARY TABLESPACE tempts1;
Creating a Locally Managed SYSTEM Tablespace
The COMPATIBLE initialization parameter must be set to 9.2 or higher, When you specify the EXTENT MANAGEMENT LOCAL clause in the CREATE DATABASE statement.
If you do not specify the EXTENT MANAGEMENT LOCAL clause, the default is to create a dictionary-managed SYSTEM tablespace.
It is not possible to create a locally managed SYSTEM tablespace and specify UNIFORM extent size.
When you create your database with a locally managed SYSTEM tablespace, ensure the following conditions are met:
There must be a default temporary tablespace, and that tablespace cannot be the SYSTEM tablespace.
You must not create rollback segments in dictionary-managed tablespaces. Attempting to create a rollback segment in a dictionary-managed tablespace will fail if the SYSTEM tablespace is locally managed.
When your SYSTEM tablespace is locally managed, there are restrictions on other tablespaces in the database. These restrictions are:
You cannot create any dictionary-managed tablespaces in the database.
You cannot migrate a locally managed tablespace to a dictionary-managed tablespace.
You can transport dictionary-managed tablespaces into the database, but you are not allowed to alter them to read-write.
Preexisting dictionary-managed tablespaces are allowed to remain in the database, but only in READ ONLY mode. They cannot be altered to READ WRITE.
Oracle also allows you to migrate an existing dictionary-managed SYSTEM tablespace to a locally managed tablespace. using the DBMS_SPACE_ADMIN package. However, there is no procedure for backward migration.
Specifying the Database Time Zone and Time Zone File
Specifying the Database Time Zone
You set the database's default time zone by specifying the SET TIME_ZONE clause of the CREATE DATABASE statement. If omitted, the default database time zone is the operating system time zone. The database time zone can be changed for a session with an ALTER SESSION statement.
Specifying the Database Time Zone File
There are 2 time zone files under the Oracle installation directory:
$ORACLE_HOME/oracore/zoneinfo/timezone.dat
This is the default. It contains the most commonly used time zones and is smaller, thus enabling better database performance.
$ORACLE_HOME/oracore/zoneinfo/timezlrg.dat
This file contains the larger set of defined time zones and should be used by users who require zones that are not defined in the default timezone.dat file. Note that this larger set of zone information may affect performance.
To enable the use of the larger time zone datafile, do the following:
1.Shut down the database.
2.Set the environment variable ORA_TZFILE to the full path name of the location for the timezlrg.dat file.
3.Restart the database.
Once the larger timezlrg.dat is used, it must continue to be used unless you are sure that none of the nondefault zones are used for data that is stored in the database. Also, all databases that share information must use the same time zone datafile.
To view the time zone names, use the following query:
SELECT * FROM V$TIMEZONE_NAMES;
Specifying FORCE LOGGING Mode
Oracle provides a means of forcing the writing of redo records for changes against the database, even where NOLOGGING has been specified in DDL statements. Oracle never generates redo records for temporary tablespaces and temporary segments, so forced logging has no affect for these.
Using the FORCE LOGGING Clause
1.CREATE DATABASE 语句中使用 FORCE LOGGING 语句
2.数据库创建之后,用 ALTER DATABASE FORCE LOGGING 语句
3.取消 FORCE LOGGING 模式:ALTER DATABASE NO FORCE LOGGING
Independent of specifying FORCE LOGGING for the database, you can selectively specify FORCE LOGGING or NO FORCE LOGGING at the tablespace level. However, if FORCE LOGGING mode is in effect for the database, it takes precedence over the tablespace mode setting. If it is not in effect for the database, then the individual tablespace settings are enforced. Oracle recommends that either the entire database is placed into FORCE LOGGING mode, or individual tablespaces be placed into FORCE LOGGING mode, but not both.
If the database is shut down and restarted, it remains in the same logging mode state. However, if you re-create the control file, the database not restarted in the FORCE LOGGING mode unless you specify the FORCE LOGGING clause in the CREATE CONTROL FILE statement.
Determining the Global Database Name
You can rename the GLOBAL_NAME of your database using the ALTER DATABASE RENAME GLOBAL_NAME statement. However, you must also shut down and restart the database after first changing the DB_NAME and DB_DOMAIN initialization parameters and re-creating the control file.
DB_NAME Initialization Parameter
DB_NAME must be set to a text string of no more than eight characters. During database creation, the name provided for DB_NAME is recorded in the datafiles, redo log files, and control file of the database. If during database instance startup the value of the DB_NAME parameter (in the parameter file) and the database name in the control file are not the same, the database does not start.
Specifying Database Block Sizes
Non-Standard Block Sizes
Tablespaces of non-standard block sizes can be created using the CREATE TABLESPACE statement and specifying the BLOCKSIZE clause. These non-standard block sizes can have any power-of-two value between 2K and 32K: specifically, 2K, 4K, 8K, 16K or 32K. Platform-specific restrictions regarding the maximum block size apply, so some of these sizes may not be allowed on some platforms.
To use non-standard block sizes, you must configure sub-caches within the buffer cache area of the SGA memory for all of the non-standard block sizes that you intend to use.
Setting Initialization Parameters that Affect the Size of the SGA
The memory for dynamic components in the SGA is allocated in the unit of granules. Granule size is determined by total SGA size. Generally speaking, on most platforms, if the total SGA size is equal to or less than 128 MB, then granule size is 4 MB. Otherwise, granule size is 16 MB.
However, there may be some platform dependency. For example, on 32-bit Windows NT, the granule size is 8 MB for SGAs larger than 128 MB. Consult your operating system specific documentation for more details.
You can query the V$SGA_DYNAMIC_COMPONENTS view to see the granule size that is being used by an instance. The same granule size is used for all dynamic components in the SGA.
If you specify a size for a component that is not a multiple of granule size, Oracle will round the specified size up to the nearest multiple. For example, if the granule size is 4 MB and you specify DB_CACHE_SIZE as 10 MB, you will actually be allocated 12 MB.
You can see a summary of information about the dynamic components of the SGA in the V$SGA_DYNAMIC_COMPONENTS view. Information about on-going SGA resize operations can be found in the V$SGA_CURRENT_RESIZE_OPS view, and information about the last 100 completed SGA resize operations can be found in the V$SGA_RESIZE_OPS view. To find the amount of SGA memory available for future dynamic SGA resize operations, query the V$SGA_DYNAMIC_FREE_MEMORY view.
Setting the Buffer Cache Initialization Parameters
If you intend to use multiple block sizes in your database, you must have the DB_CACHE_SIZE and at least one DB_nK_CACHE_SIZE parameter set. Oracle assigns an appropriate default value to the DB_CACHE_SIZE parameter, but the DB_nK_CACHE_SIZE parameters default to 0, and no additional block size caches are configured.
DB_nK_CACHE_SIZE Initialization Parameters
These parameters cannot be used to size the cache for the standard block size. For example, if the value of DB_BLOCK_SIZE is 2K, it is illegal to set DB_2K_CACHE_SIZE. The size of the cache for the standard block size is always determined from the value of DB_CACHE_SIZE.
Specifying the Maximum Number of Processes
The PROCESSES initialization parameter determines the maximum number of operating system processes that can be connected to Oracle concurrently. The value of this parameter must be 6 or greater (5 for the background processes plus 1 for each user process). For example, if you plan to have 50 concurrent users, set this parameter to at least 55.
UNDO_TABLESPACE Initialization Parameter
When the instance starts up in automatic undo management mode, it selects the first available undo tablespace in the instance for storing undo. A default undo tablespace named SYS_UNDOTBS is automatically created when you execute a CREATE DATABASE statement and the UNDO_MANAGEMENT initialization parameter is set to AUTO. This is the undo tablespace that Oracle normally selects whenever you start up the database.
If there is no undo tablespace available, the instance will start, but uses the SYSTEM rollback segment. This is not recommended in normal circumstances, and an alert message is written to the alert file to warn that the system is running without an undo tablespace.
ROLLBACK_SEGMENTS Initialization Parameter
The ROLLBACK_SEGMENTS parameter is a list of the non-system rollback segments an Oracle instance acquires at database startup if the database is to operate in manual undo management mode. List your rollback segments as the value of this parameter. If no rollback segments are specified, the system rollback segment is used.
Setting License Parameters
Oracle no longer offers licensing by the number of concurrent sessions. Therefore the LICENSE_MAX_SESSIONS and LICENSE_SESSIONS_WARNING initialization parameters have been deprecated.
If you use named user licensing, Oracle can help you enforce this form of licensing. You can set a limit on the number of users created in the database. Once this limit is reached, you cannot create more users.
Note:
This mechanism assumes that each person accessing the database has a unique user name and that no people share a user name. Therefore, so that named user licensing can help you ensure compliance with your Oracle license agreement, do not allow multiple users to log in using the same user name.
To limit the number of users created in a database, set the LICENSE_MAX_USERS initialization parameter in the database's initialization parameter file, as shown in the following example:
LICENSE_MAX_USERS = 200
Setting or Changing Initialization Parameter Values
For dynamic parameters, you can also specify the DEFERRED keyword. When specified, the change is effective only for future sessions.
A COMMENT clause allows a comment string to be associated with the parameter update. When you specify SCOPE as SPFILE or BOTH, the comment is written to the server parameter file.
Example:
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=50
COMMENT='temporary change on Nov 29'
SCOPE=MEMORY;
Another example illustrates setting a complex initialization parameter that takes a list of strings.
ALTER SYSTEM
SET LOG_ARCHIVE_DEST_4='LOCATION=/u02/oracle/rbdb1/',MANDATORY,'REOPEN=2'
COMMENT='Add new destimation on Nov 29'
SCOPE=SPFILE;
Note that when a value consists of a list of strings, the syntax of the ALTER SYSTEM SET statement does not support editing each element of the list of values by the position or ordinal number. You must specify the complete list of values each time the parameter is updated, and the new list completely replaces the old list.
Deleting Initialization Parameter Values
For initialization parameters whose values are string values you can restore a parameter to its default value (effectively deleting it), by using the following syntax:
ALTER SYSTEM SET parameter = '';
For numeric and boolean value parameters, you must specifically set the parameter back to its original default value.
Viewing Parameter Settings
SHOW PARAMETERS
This SQL*Plus command displays the currently in use parameter values.
CREATE PFILE
This SQL statement creates a text initialization parameter file from the binary server parameter file.
V$PARAMETER
This view displays the currently in effect parameter values.
V$PARAMETER2
This view displays the currently in effect parameter values. It is easier to distinguish list parameter values in this view because each list parameter value appears as a row.
V$SPPARAMETER
This view displays the current contents of the server parameter file. The view returns NULL values if a server parameter file is not being used by the instance.