Oracle9i SQL Reference Release 2 (9.2) Part Number A96540-01 |
|
SQL Statements: CREATE CLUSTER to CREATE JAVA, 5 of 12
Caution: This statement prepares a database for initial use and erases any data currently in the specified files. Use this statement only when you understand its ramifications. |
Use the CREATE
DATABASE
statement to create a database, making it available for general use.
This statement erases all data in any specified datafiles that already exist in order to prepare them for initial database use. If you use the statement on an existing database, all data in the datafiles is lost.
After creating the database, this statement mounts it in either exclusive or parallel mode (depending on the value of the CLUSTER_DATABASE
initialization parameter) and opens it, making it available for normal use. You can then create tablespaces and rollback segments for the database.
See Also:
|
To create a database, you must have the SYSDBA
system privilege.
If the REMOTE_LOGIN_PASSWORDFILE
initialization parameter is set to EXCLUSIVE
, Oracle returns an error when you attempt to re-create the database. To avoid this message, either set the parameter to SHARED
, or re-create your password file before re-creating the database.
See Also:
Oracle9i Database Reference for more information about the |
create_database::=
redo_log_file_spec::=
, datafile_tempfile_spec::=
, default_temp_tablespace::=
, undo_tablespace_clause::=
, set_time_zone_clause::=
)datafile_tempfile_spec::=
--part of file_specification
)temp_tablespace_extent::=
datafile_tempfile_spec::=
--part of file_specification
)Specify the name of the database to be created. The name can be up to 8 bytes long. The database name can contain only ASCII characters. Oracle writes this name into the control file. If you subsequently issue an ALTER
DATABASE
statement that explicitly specifies a database name, Oracle verifies that name with the name in the control file.
Note: You cannot use special characters from European or Asian character sets in a database name. For example, characters with umlauts are not allowed. |
If you omit the database name from a CREATE
DATABASE
statement, Oracle uses the name specified by the initialization parameter DB_NAME
. If the DB_NAME
initialization parameter has been set, and you specify a different name from the value of that parameter, Oracle returns an error.
See Also:
"Schema Object Naming Guidelines" for additional rules to which database names should adhere |
Use these clauses to establish passwords for the SYS
and SYSTEM
users. These clauses are not mandatory in this release of Oracle9i. However, if you specify either clause, you must specify both clauses.
If you do not specify these clauses, Oracle creates default passwords "change_on_install
" for user SYS
and "manager
" for user SYSTEM
. You can subsequently change these passwords using the ALTER
USER
statement. You can also use ALTER
USER
to add password management attributes after database creation.
Specify CONTROLFILE
REUSE
to reuse existing control files identified by the initialization parameter CONTROL_FILES
, thus ignoring and overwriting any information they currently contain. Normally you use this clause only when you are re-creating a database, rather than creating one for the first time. You cannot use this clause if you also specify a parameter value that requires that the control file be larger than the existing files. These parameters are MAXLOGFILES
, MAXLOGMEMBERS
, MAXLOGHISTORY
, MAXDATAFILES
, and MAXINSTANCES
.
If you omit this clause and any of the files specified by CONTROL_FILES
already exist, Oracle returns an error.
Specify one or more files to be used as redo log files. Each redo_log_file_spec
specifies a redo log file group containing one or more redo log file members (copies). All redo log files specified in a CREATE
DATABASE
statement are added to redo log thread number 1.
See Also:
|
Specify the number that identifies the redo log file group. The value of integer
can range from 1 to the value of the MAXLOGFILES
parameter. A database must have at least two redo log file groups. You cannot specify multiple redo log file groups having the same GROUP
value. If you omit this parameter, Oracle generates its value automatically. You can examine the GROUP
value for a redo log file group through the dynamic performance view V$LOG
.
If you omit the LOGFILE
clause:
DB_CREATE_ONLINE_LOG_DEST_
n
or DB_CREATE_FILE_DEST
initialization parameter (or both) is set, then Oracle creates two Oracle-managed logfiles with system-generated names, 100 MB in size, in the default logfile directory specified in the DB_CREATE_ONLINE_LOG_DEST_
n
parameter, and if it is not set, then in the DB_CREATE_FILE_DEST
parameter.Specify the maximum number of redo log file groups that can ever be created for the database. Oracle uses this value to determine how much space in the control file to allocate for the names of redo log files. The default, minimum, and maximum values depend on your operating system.
Specify the maximum number of members, or copies, for a redo log file group. Oracle uses this value to determine how much space in the control file to allocate for the names of redo log files. The minimum value is 1. The maximum and default values depend on your operating system.
This parameter is useful only if you are using Oracle in ARCHIVELOG
mode with Real Application Clusters. Specify the maximum number of archived redo log files for automatic media recovery Real Application Clusters. Oracle uses this value to determine how much space in the control file to allocate for the names of archived redo log files. The minimum value is 0. The default value is a multiple of the MAXINSTANCES
value and depends on your operating system. The maximum value is limited only by the maximum size of the control file.
Specify the initial sizing of the datafiles section of the control file at CREATE
DATABASE
or CREATE
CONTROLFILE
time. An attempt to add a file whose number is greater than MAXDATAFILES
, but less than or equal to DB_FILES
, causes the Oracle control file to expand automatically so that the datafiles section can accommodate more files.
The number of datafiles accessible to your instance is also limited by the initialization parameter DB_FILES
.
Specify the maximum number of instances that can simultaneously have this database mounted and open. This value takes precedence over the value of initialization parameter INSTANCES
. The minimum value is 1. The maximum and default values depend on your operating system.
Specify ARCHIVELOG
if you want the contents of a redo log file group to be archived before the group can be reused. This clause prepares for the possibility of media recovery.
Specify NOARCHIVELOG
if the contents of a redo log file group need not be archived before the group can be reused. This clause does not allow for the possibility of media recovery.
The default is NOARCHIVELOG
mode. After creating the database, you can change between ARCHIVELOG
mode and NOARCHIVELOG
mode with the ALTER
DATABASE
statement.
Use this clause to put the database into FORCE
LOGGING
mode. Oracle will log all changes in the database except for changes in temporary tablespaces and temporary segments. This setting takes precedence over and is independent of any NOLOGGING
or FORCE
LOGGING
settings you specify for individual tablespaces and any NOLOGGING
settings you specify for individual database objects.
FORCE
LOGGING
mode is persistent across instances of the database. That is, if you shut down and restart the database, the database is still in FORCE
LOGGING
mode. However, if you re-create the control file, Oracle will take the database out of FORCE
LOGGING
mode unless you specify FORCE
LOGGING
in the CREATE
CONTROLFILE
statement.
Note:
|
Specify the character set the database uses to store data. The supported character sets and default value of this parameter depend on your operating system.
Restriction on CHARACTER SET: You cannot specify the AL16UTF16 character set as the database character set.
See Also:
Oracle9i Database Globalization Support Guide for more information about choosing a character set |
Specify the national character set used to store data in columns specifically defined as NCHAR
, NCLOB
, or NVARCHAR2
(either AF16UTF16
or UTF8
). The default is 'AL16UTF16
'.
See Also:
Oracle9i Database Globalization Support Guide for information on Unicode datatype support. |
Specify one or more files to be used as datafiles. All these files become part of the SYSTEM
tablespace.
If you are running the database in automatic undo mode and you specify a datafile name for the SYSTEM
tablespace, then Oracle expects to generate datafiles for all tablespaces. Oracle does this automatically if you are using Oracle-managed files (that is, you have set values for the DB_CREATE_FILE_DEST
or DB_CREATE_ONLINE_LOG_DEST_
n
initialization parameter). However, if you are not using Oracle-managed files and you specify this clause, then you must also specify the undo_tablespace_clause
and the default_temp_tablespace
clause.
If you omit this clause:
DB_CREATE_FILE_DEST
initialization parameter is set, Oracle creates a 100 MB Oracle-managed datafile with a system-generated name in the default file destination specified in the parameter.DB_CREATE_FILE_DEST
initialization parameter is not set, Oracle creates one datafile whose name and size depend on your operating system.
Note: Oracle recommends that the total initial space allocated for the |
See Also:
|
Use this clause to create a locally managed SYSTEM
tablespace. If you omit this clause, the SYSTEM
tablespace will be dictionary managed.
Caution: Once you create a locally managed |
If you specify this clause, the database must have a default temporary tablespace, because a locally managed SYSTEM
tablespace cannot store temporary segments.
EXTENT
MANAGEMENT
LOCAL
but you do not specify the DATAFILE
clause, you can omit the default_temp_tablespace
clause. Oracle will create a default temporary tablespace called TEMP
with one datafile of size 10M with autoextend disabled.EXTENT
MANAGEMENT
LOCAL
and the DATAFILE
clause, then you must also specify the default_temp_tablespace
clause and explicitly specify a datafile for that tablespace.If you have opened the instance in Automatic Undo Management mode, similar requirements exist for the database undo tablespace:
EXTENT
MANAGEMENT
LOCAL
but you do not specify the DATAFILE
clause, you can omit the undo_tablespace_clause
. Oracle will create an undo tablespace named SYS_UNDOTBS
.EXTENT
MANAGEMENT
LOCAL
and the DATAFILE
clause, then you must also specify the undo_tablespace_clause
and explicitly specify a datafile for that tablespace.
See Also:
Oracle9i Database Administrator's Guide for more information on locally managed and dictionary-managed tablespaces |
Specify this clause to create a default temporary tablespace for the database. Oracle will assign to this temporary tablespace any users for whom you do not specify a different temporary tablespace. If you do not specify this clause, the SYSTEM
tablespace is the default temporary tablespace.
The TEMPFILE
clause part of this clause is optional if you have enabled Oracle-managed files by setting the DB_CREATE_FILE_DEST
initialization parameter. If you have not specified a value for this parameter, the TEMPFILE
clause is required.
Restrictions on default temporary tablespaces:
SYSTEM
tablespace in this clause.The temp_tablespace_extent
clause lets you specify how the tablespace is managed.
This clause indicates that some part of the tablespace is set aside for a bitmap. All temporary tablespaces have locally managed extents, so this clause is optional.
Specify the size of the extents of the temporary tablespace in bytes. All extents of temporary tablespaces are the same size (uniform). If you do not specify this clause, Oracle uses uniform extents of 1M.
Specify in bytes the size of the tablespace extents. Use K
or M
to specify the size in kilobytes or megabytes.
If you do not specify SIZE
, Oracle uses the default extent size of 1M.
See Also: Oracle9i Database Concepts for a discussion of locally managed tablespaces |
If you have opened the instance in automatic undo mode (that is, the UNDO_MANAGEMENT
initialization parameter is set to AUTO
), you can specify the undo_tablespace_clause
to create a tablespace to be used for undo data. If you want undo space management to be handled by way of rollback segments, omit this clause. You can also omit this clause if you have set a value for the UNDO_TABLESPACE
initialization parameter. If that parameter has been set, and if you specify this clause, then tablespace
must be the same as that parameter value.
The DATAFILE
clause part of this clause is optional if you have enabled Oracle Managed Files by setting the DB_CREATE_FILE_DEST
initialization parameter. If you have not specified a value for this parameter, the DATAFILE
clause is required.
tablespace
, creates the specified datafiles as part of the undo tablespace, and assigns this tablespace as the undo tablespace of the instance. Oracle will handle management of undo data using this undo tablespace. The DATAFILE
clause of this clause has the same behavior as described in "DATAFILE Clause".
SYS_UNDOTBS
and assigns this default tablespace as the undo tablespace of the instance. This undo tablespace allocates disk space from the default files used by the CREATE
DATABASE
statement, and has an initial extent of 10M. Oracle handles the system-generated datafile as described in "DATAFILE Clause". If Oracle is unable to create the undo tablespace, the entire CREATE
DATABASE
operation fails.
See Also:
|
Use the SET
TIME_ZONE
clause to set the time zone of the database. You can specify the time zone in two ways:
hh:mm
is -12:00 to +14:00.TZNAME
column of the V$TIMEZONE_NAMES
dynamic performance view.
See Also:
Oracle9i Database Reference for information on the dynamic performance views |
Oracle normalizes all TIMESTAMP
WITH
LOCAL
TIME
ZONE
data to the time zone of the database when the data is stored on disk. If you do not specify the SET
TIME_ZONE
clause, Oracle uses the operating system's time zone of the server. If the operating system time zone is not a valid Oracle time zone, the database time zone defaults to UTC.
The following statement creates a database and fully specifies each argument:
CREATE DATABASE sample CONTROLFILE REUSE LOGFILE GROUP 1 ('diskx:log1.log', 'disky:log1.log') SIZE 50K, GROUP 2 ('diskx:log2.log', 'disky:log2.log') SIZE 50K MAXLOGFILES 5 MAXLOGHISTORY 100 MAXDATAFILES 10 MAXINSTANCES 2 ARCHIVELOG CHARACTER SET AL32UTF8 NATIONAL CHARACTER SET AL16UTF16 DATAFILE 'disk1:df1.dbf' AUTOEXTEND ON, 'disk2:df2.dbf' AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED DEFAULT TEMPORARY TABLESPACE temp_ts UNDO TABLESPACE undo_ts SET TIME_ZONE = '+02:00';
This example assumes that you have enabled Oracle Managed Files by specifying a value for the DB_CREATE_FILE_DEST
parameter in your initialization parameter file. Therefore no file specification is needed for the DEFAULT
TEMPORARY
TABLESPACE
and UNDO
TABLESPACE
clauses.
|
![]() Copyright © 1996, 2002 Oracle Corporation. All Rights Reserved. |
|