
- •Contents
- •Send Us Your Comments
- •Preface
- •What’s New in SQL Reference?
- •1 Introduction to Oracle SQL
- •History of SQL
- •SQL Standards
- •Embedded SQL
- •Lexical Conventions
- •Tools Support
- •2 Basic Elements of Oracle SQL
- •Datatypes
- •Oracle Built-in Datatypes
- •ANSI, DB2, and SQL/DS Datatypes
- •Oracle-Supplied Types
- •"Any" Types
- •XML Types
- •Spatial Type
- •Media Types
- •Datatype Comparison Rules
- •Data Conversion
- •Literals
- •Text Literals
- •Integer Literals
- •Number Literals
- •Interval Literals
- •Format Models
- •Number Format Models
- •Date Format Models
- •String-to-Date Conversion Rules
- •XML Format Model
- •Nulls
- •Nulls in SQL Functions
- •Nulls with Comparison Conditions
- •Nulls in Conditions
- •Pseudocolumns
- •CURRVAL and NEXTVAL
- •LEVEL
- •ROWID
- •ROWNUM
- •XMLDATA
- •Comments
- •Comments Within SQL Statements
- •Comments on Schema Objects
- •Hints
- •Database Objects
- •Schema Objects
- •Nonschema Objects
- •Parts of Schema Objects
- •Schema Object Names and Qualifiers
- •Schema Object Naming Rules
- •Schema Object Naming Examples
- •Schema Object Naming Guidelines
- •Syntax for Schema Objects and Parts in SQL Statements
- •How Oracle Resolves Schema Object References
- •Referring to Objects in Other Schemas
- •Referring to Objects in Remote Databases
- •Referencing Object Type Attributes and Methods
- •3 Operators
- •About SQL Operators
- •Unary and Binary Operators
- •Operator Precedence
- •Arithmetic Operators
- •Concatenation Operator
- •Set Operators
- •4 Expressions
- •About SQL Expressions
- •Simple Expressions
- •Compound Expressions
- •CASE Expressions
- •CURSOR Expressions
- •Datetime Expressions
- •Function Expressions
- •INTERVAL Expressions
- •Object Access Expressions
- •Scalar Subquery Expressions
- •Type Constructor Expressions
- •Variable Expressions
- •Expression Lists
- •5 Conditions
- •About SQL Conditions
- •Condition Precedence
- •Comparison Conditions
- •Simple Comparison Conditions
- •Group Comparison Conditions
- •Logical Conditions
- •Membership Conditions
- •Range Conditions
- •Null Conditions
- •EQUALS_PATH
- •EXISTS Conditions
- •LIKE Conditions
- •IS OF type Conditions
- •UNDER_PATH
- •Compound Conditions
- •6 Functions
- •SQL Functions
- •Single-Row Functions
- •Aggregate Functions
- •Analytic Functions
- •Object Reference Functions
- •Alphabetical Listing of SQL Functions
- •ACOS
- •ADD_MONTHS
- •ASCII
- •ASCIISTR
- •ASIN
- •ATAN
- •ATAN2
- •BFILENAME
- •BITAND
- •CAST
- •CEIL
- •CHARTOROWID
- •COALESCE
- •COMPOSE
- •CONCAT
- •CONVERT
- •CORR
- •COSH
- •COUNT
- •COVAR_POP
- •COVAR_SAMP
- •CUME_DIST
- •CURRENT_DATE
- •CURRENT_TIMESTAMP
- •DBTIMEZONE
- •DECODE
- •DECOMPOSE
- •DENSE_RANK
- •DEPTH
- •DEREF
- •DUMP
- •EMPTY_BLOB, EMPTY_CLOB
- •EXISTSNODE
- •EXTRACT (datetime)
- •EXTRACT (XML)
- •EXTRACTVALUE
- •FIRST
- •FIRST_VALUE
- •FLOOR
- •FROM_TZ
- •GREATEST
- •GROUP_ID
- •GROUPING
- •GROUPING_ID
- •HEXTORAW
- •INITCAP
- •INSTR
- •LAST
- •LAST_DAY
- •LAST_VALUE
- •LEAD
- •LEAST
- •LENGTH
- •LOCALTIMESTAMP
- •LOWER
- •LPAD
- •LTRIM
- •MAKE_REF
- •MONTHS_BETWEEN
- •NCHR
- •NEW_TIME
- •NEXT_DAY
- •NLS_CHARSET_DECL_LEN
- •NLS_CHARSET_ID
- •NLS_CHARSET_NAME
- •NLS_INITCAP
- •NLS_LOWER
- •NLSSORT
- •NLS_UPPER
- •NTILE
- •NULLIF
- •NUMTODSINTERVAL
- •NUMTOYMINTERVAL
- •PATH
- •PERCENT_RANK
- •PERCENTILE_CONT
- •PERCENTILE_DISC
- •POWER
- •RANK
- •RATIO_TO_REPORT
- •RAWTOHEX
- •RAWTONHEX
- •REFTOHEX
- •REGR_ (Linear Regression) Functions
- •REPLACE
- •ROUND (number)
- •ROUND (date)
- •ROW_NUMBER
- •ROWIDTOCHAR
- •ROWIDTONCHAR
- •RPAD
- •RTRIM
- •SESSIONTIMEZONE
- •SIGN
- •SINH
- •SOUNDEX
- •SQRT
- •STDDEV
- •STDDEV_POP
- •STDDEV_SAMP
- •SUBSTR
- •SYS_CONNECT_BY_PATH
- •SYS_CONTEXT
- •SYS_DBURIGEN
- •SYS_EXTRACT_UTC
- •SYS_GUID
- •SYS_TYPEID
- •SYS_XMLAGG
- •SYS_XMLGEN
- •SYSDATE
- •SYSTIMESTAMP
- •TANH
- •TO_CHAR (character)
- •TO_CHAR (datetime)
- •TO_CHAR (number)
- •TO_CLOB
- •TO_DATE
- •TO_DSINTERVAL
- •TO_MULTI_BYTE
- •TO_NCHAR (character)
- •TO_NCHAR (datetime)
- •TO_NCHAR (number)
- •TO_NCLOB
- •TO_NUMBER
- •TO_SINGLE_BYTE
- •TO_TIMESTAMP
- •TO_TIMESTAMP_TZ
- •TO_YMINTERVAL
- •TRANSLATE
- •TRANSLATE ... USING
- •TREAT
- •TRIM
- •TRUNC (number)
- •TRUNC (date)
- •TZ_OFFSET
- •UNISTR
- •UPDATEXML
- •UPPER
- •USER
- •USERENV
- •VALUE
- •VAR_SAMP
- •VARIANCE
- •VSIZE
- •WIDTH_BUCKET
- •XMLAGG
- •XMLCOLATTVAL
- •XMLCONCAT
- •XMLELEMENT
- •XMLFOREST
- •XMLSEQUENCE
- •XMLTRANSFORM
- •ROUND and TRUNC Date Functions
- •User-Defined Functions
- •Prerequisites
- •Name Precedence
- •7 Common SQL DDL Clauses
- •allocate_extent_clause
- •constraints
- •deallocate_unused_clause
- •file_specification
- •logging_clause
- •parallel_clause
- •physical_attributes_clause
- •storage_clause
- •8 SQL Queries and Subqueries
- •About Queries and Subqueries
- •Creating Simple Queries
- •Hierarchical Queries
- •The UNION [ALL], INTERSECT, MINUS Operators
- •Sorting Query Results
- •Joins
- •Using Subqueries
- •Unnesting of Nested Subqueries
- •Selecting from the DUAL Table
- •Distributed Queries
- •9 SQL Statements: ALTER CLUSTER to ALTER SEQUENCE
- •Types of SQL Statements
- •Organization of SQL Statements
- •ALTER CLUSTER
- •ALTER DATABASE
- •ALTER DIMENSION
- •ALTER FUNCTION
- •ALTER INDEX
- •ALTER INDEXTYPE
- •ALTER JAVA
- •ALTER MATERIALIZED VIEW
- •ALTER MATERIALIZED VIEW LOG
- •ALTER OPERATOR
- •ALTER OUTLINE
- •ALTER PACKAGE
- •ALTER PROCEDURE
- •ALTER PROFILE
- •ALTER RESOURCE COST
- •ALTER ROLE
- •ALTER ROLLBACK SEGMENT
- •ALTER SEQUENCE
- •10 SQL Statements: ALTER SESSION to ALTER SYSTEM
- •ALTER SESSION
- •ALTER SYSTEM
- •ALTER TABLE
- •ALTER TABLESPACE
- •ALTER TRIGGER
- •ALTER TYPE
- •ALTER USER
- •ALTER VIEW
- •ANALYZE
- •ASSOCIATE STATISTICS
- •AUDIT
- •CALL
- •COMMENT
- •COMMIT
- •13 SQL Statements: CREATE CLUSTER to CREATE JAVA
- •CREATE CLUSTER
- •CREATE CONTEXT
- •CREATE CONTROLFILE
- •CREATE DATABASE
- •CREATE DATABASE LINK
- •CREATE DIMENSION
- •CREATE DIRECTORY
- •CREATE FUNCTION
- •CREATE INDEX
- •CREATE INDEXTYPE
- •CREATE JAVA
- •14 SQL Statements: CREATE LIBRARY to CREATE SPFILE
- •CREATE LIBRARY
- •CREATE MATERIALIZED VIEW
- •CREATE MATERIALIZED VIEW LOG
- •CREATE OPERATOR
- •CREATE OUTLINE
- •CREATE PACKAGE
- •CREATE PACKAGE BODY
- •CREATE PFILE
- •CREATE PROCEDURE
- •CREATE PROFILE
- •CREATE ROLE
- •CREATE ROLLBACK SEGMENT
- •CREATE SCHEMA
- •CREATE SEQUENCE
- •CREATE SPFILE
- •15 SQL Statements: CREATE SYNONYM to CREATE TRIGGER
- •CREATE SYNONYM
- •CREATE TABLE
- •CREATE TABLESPACE
- •CREATE TEMPORARY TABLESPACE
- •CREATE TRIGGER
- •CREATE TYPE
- •CREATE TYPE BODY
- •CREATE USER
- •CREATE VIEW
- •DELETE
- •DISASSOCIATE STATISTICS
- •DROP CLUSTER
- •DROP CONTEXT
- •DROP DATABASE LINK
- •DROP DIMENSION
- •DROP DIRECTORY
- •DROP FUNCTION
- •DROP INDEX
- •DROP INDEXTYPE
- •DROP JAVA
- •DROP LIBRARY
- •DROP MATERIALIZED VIEW
- •DROP MATERIALIZED VIEW LOG
- •DROP OPERATOR
- •DROP OUTLINE
- •DROP PACKAGE
- •DROP PROCEDURE
- •DROP PROFILE
- •DROP ROLE
- •DROP ROLLBACK SEGMENT
- •17 SQL Statements: DROP SEQUENCE to ROLLBACK
- •DROP SEQUENCE
- •DROP SYNONYM
- •DROP TABLE
- •DROP TABLESPACE
- •DROP TRIGGER
- •DROP TYPE
- •DROP TYPE BODY
- •DROP USER
- •DROP VIEW
- •EXPLAIN PLAN
- •GRANT
- •INSERT
- •LOCK TABLE
- •MERGE
- •NOAUDIT
- •RENAME
- •REVOKE
- •ROLLBACK
- •18 SQL Statements: SAVEPOINT to UPDATE
- •SAVEPOINT
- •SELECT
- •SET CONSTRAINT[S]
- •SET ROLE
- •SET TRANSACTION
- •TRUNCATE
- •UPDATE
- •Required Keywords and Parameters
- •Optional Keywords and Parameters
- •Syntax Loops
- •Multipart Diagrams
- •Database Objects
- •ANSI Standards
- •ISO Standards
- •Oracle Compliance
- •FIPS Compliance
- •Oracle Extensions to Standard SQL
- •Character Set Support
- •Using Extensible Indexing
- •Using XML in SQL Statements
- •Index

CREATE TABLESPACE
CREATE TABLESPACE
Purpose
Use the CREATE TABLESPACE statement to create a tablespace, which is an allocation of space in the database that can contain persistent schema objects.
When you create a tablespace, it is initially a read/write tablespace. You can subsequently use the ALTER TABLESPACE statement to take the tablespace offline or online, add datafiles to it, or make it a read-only tablespace.
You can also drop a tablespace from the database with the DROP TABLESPACE statement.
You can use the CREATE TEMPORARY TABLESPACE statement to create tablespaces that contain schema objects only for the duration of a session.
See Also:
■
■
Oracle9i Database Concepts for information on tablespaces
ALTER TABLESPACE on page 11-102 for information on modifying tablespaces
■DROP TABLESPACE on page 17-10 for information on dropping tablespaces
■CREATE TEMPORARY TABLESPACE on page 15-92
Prerequisites
You must have CREATE TABLESPACE system privilege.
Before you can create a tablespace, you must create a database to contain it, and the database must be open.
See Also: CREATE DATABASE on page 13-23
To use objects in a tablespace other than the SYSTEM tablespace:
■If you are running the database in rollback undo mode, at least one rollback segment (other than the SYSTEM rollback segment) must be online.
■If you are running the database in Automatic Undo Management mode, at least one UNDO tablespace must be online.
15-80 Oracle9i SQL Reference

CREATE TABLESPACE
See Also: CREATE ROLLBACK SEGMENT on page 14-82
Syntax
create_tablespace::=
|
|
|
, |
UNDO |
|
DATAFILE |
datafile_tempfile_spec |
CREATE |
TABLESPACE |
tablespace |
|
K
M
MINIMUM EXTENT
integer
K
BLOCKSIZE integer logging_clause
FORCE LOGGING
data_segment_compression |
|
DEFAULT |
storage_clause |
ONLINE |
|
OFFLINE |
|
PERMANENT |
|
TEMPORARY |
|
extent_management_clause |
|
segment_management_clause |
|
;
(datafile_tempfile_spec::= on page 7-39—part of file_specification, logging_clause::= on page 15-82, data_segment_compression::= on page 15-82, storage_clause::= on page 7-58, extent_management_ clause::= on page 15-82, segment_management_clause::= on page 15-82)
SQL Statements: CREATE SYNONYM to CREATE TRIGGER 15-81

CREATE TABLESPACE
logging_clause::=
LOGGING
NOLOGGING
data_segment_compression::=
COMPRESS
NOCOMPRESS
(storage_clause on page 7-56)
extent_management_clause::=
DICTIONARY
AUTOALLOCATE
EXTENT MANAGEMENT
K
M
SIZE integer
UNIFORM
LOCAL
segment_management_clause::=
MANUAL
SEGMENT SPACE
MANAGEMENT
AUTO
Semantics
UNDO
Specify UNDO to create an undo tablespace. When you run the database in Automatic Undo Management mode, Oracle manages undo space using the undo tablespace instead of rollback segments. This clause is useful if you are now running in Automatic Undo Management mode but your database was not created in Automatic Undo Management mode.
Oracle always assigns an undo tablespace when you start up the database in Automatic Undo Management mode. If no undo tablespace has been assigned to
15-82 Oracle9i SQL Reference

CREATE TABLESPACE
this instance, then Oracle will use the SYSTEM rollback segment. You can avoid this by creating an undo tablespace, which Oracle will implicitly assign to the instance if no other undo tablespace is currently assigned.
Restrictions on Undo Tablespaces
■You cannot create database objects in this tablespace. It is reserved for system-managed undo data.
■The only clauses you can specify for an undo tablespace are the DATAFILE clause and the extent_management_clause to specify local extent management. (You cannot specify dictionary extent management using the extent_management_clause.) All undo tablespaces are created permanent, read/write, and in logging mode. Values for MINIMUM EXTENT and DEFAULT STORAGE are system generated.
See Also:
■Oracle9i Database Administrator’s Guide for information on Automatic Undo Management and undo tablespaces
■CREATE DATABASE on page 13-23 for information on creating an undo tablespace implicitly or explicitly during database creation
■ALTER TABLESPACE for information about altering undo tablespaces
■DROP TABLESPACE for information about dropping undo tablespaces
■Oracle9i Database Reference for information on opening a database instance in Automatic Undo Management mode using the UNDO_MANAGEMENT parameter
■"Creating an Undo Tablespace: Example" on page 15-89
tablespace
Specify the name of the tablespace to be created.
DATAFILE datafile_tempfile_spec
Specify the datafile or files to make up the tablespace.
SQL Statements: CREATE SYNONYM to CREATE TRIGGER 15-83

CREATE TABLESPACE
Note: For operating systems that support raw devices, the REUSE keyword of datafile_tempfile_spec has no meaning when specifying a raw device as a datafile. Such a CREATE TABLESPACE statement will succeed whether or not you specify REUSE.
The DATAFILE clause is optional only if the DB_CREATE_FILE_DEST initialization parameter is set. In this case, Oracle creates a system-named 100MB file in the default file destination specified in the parameter. The file has AUTOEXTEND enabled and an unlimited maximum size.
See Also:
■file_specification on page 7-39 for a full description, including the AUTOEXTEND parameter
■"Enabling Autoextend for a Tablespace: Example" on
page 15-90 and "Creating Oracle-managed Files: Examples" on page 15-91
MINIMUM EXTENT Clause
Specify the minimum size of an extent in the tablespace. This clause lets you control free space fragmentation in the tablespace by ensuring that every used or free extent size in a tablespace is at least as large as, and is a multiple of, integer.
Note: This clause is not relevant for a dictionary-managed temporary tablespace.
See Also: Oracle9i Database Concepts for more information about using MINIMUM EXTENT to control fragmentation and "Specifying Minimum Extent Size: Example" on page 15-90
BLOCKSIZE Clause
Use the BLOCKSIZE clause to specify a nonstandard block size for the tablespace. In order to specify this clause, you must have the DB_CACHE_SIZE and at least one DB_nK_CACHE_SIZE parameter set, and the integer you specify in this clause must correspond with the setting of one DB_nK_CACHE_SIZE parameter setting.
15-84 Oracle9i SQL Reference

CREATE TABLESPACE
Restriction on BLOCKSIZE You cannot specify nonstandard block sizes for a temporary tablespace (that is, if you also specify TEMPORARY) or if you intend to assign this tablespace as the temporary tablespace for any users.
See Also: Oracle9i Database Administrator’s Guide for information on allowing multiple block sizes in the buffer cache, and for restrictions on using multiple block sizes in partitioned objects
logging_clause
Specify the default logging attributes of all tables, indexes, materialized views, materialized view logs, and partitions within the tablespace. LOGGING is the default.
The tablespace-level logging attribute can be overridden by logging specifications at the table, index, materialized view, materialized view log, and partition levels.
See Also: logging_clause on page 7-45 for a full description of this clause
FORCE LOGGING
Use this clause to put the tablespace into FORCE LOGGING mode. Oracle will log all changes to all objects in the tablespace except changes to temporary segments, overriding any NOLOGGING setting for individual objects. The database must be open and in READ WRITE mode.
This setting does not exclude the NOLOGGING attribute. That is, you can specify both FORCE LOGGING and NOLOGGING. In this case, NOLOGGING is the default logging mode for objects subsequently created in the tablespace, but Oracle ignores this default as long as the tablespace (or the database) is in FORCE LOGGING mode. If you subsequently take the tablespace out of FORCE LOGGING mode, then the NOLOGGING default is once again enforced.
Note: FORCE LOGGING mode can have performance effects. Please refer to Oracle9i Database Administrator’s Guide for information on when to use this setting.
Restriction on Forced Logging You cannot specify FORCE LOGGING for an undo or temporary tablespace.
SQL Statements: CREATE SYNONYM to CREATE TRIGGER 15-85

CREATE TABLESPACE
DEFAULT storage_clause
Specify the default storage parameters for all objects created in the tablespace.
For a dictionary-managed temporary tablespace, Oracle considers only the NEXT parameter of the storage_clause.
See Also: storage_clause on page 7-56 for information on storage parameters and "Creating a Tablespace with Default Storage: Example" on page 15-90
ONLINE | OFFLINE Clauses
ONLINE Specify ONLINE to make the tablespace available immediately after creation to users who have been granted access to the tablespace. This is the default.
OFFLINE Specify OFFLINE to make the tablespace unavailable immediately after creation.
The data dictionary view DBA_TABLESPACES indicates whether each tablespace is online or offline.
PERMANENT | TEMPORARY Clauses
PERMANENT Specify PERMANENT if the tablespace will be used to hold permanent objects. This is the default.
TEMPORARY Specify TEMPORARY if the tablespace will be used only to hold temporary objects, for example, segments used by implicit sorts to handle ORDER BY clauses.
Temporary tablespaces created with this clause are always dictionary managed, so you cannot specify the EXTENT MANAGEMENT LOCAL clause. To create a locally managed temporary tablespace, use the CREATE TEMPORARY TABLESPACE statement.
Note: Oracle Corporation strongly recommends that you create locally managed temporary tablespaces containing tempfiles by using the CREATE TEMPORARY TABLESPACE statement. The creation of new dictionary-managed tablespaces is scheduled for desupport.
15-86 Oracle9i SQL Reference

CREATE TABLESPACE
Restriction on Temporary Tablespaces If you specify TEMPORARY, then you cannot specify the BLOCKSIZE clause.
extent_management_clause
The extent_management_clause lets you specify how the extents of the tablespace will be managed.
Note: Once you have specified extent management with this clause, you can change extent management only by migrating the tablespace.
■Specify LOCAL if you want the tablespace to be locally managed. Locally managed tablespaces have some part of the tablespace set aside for a bitmap. This is the default.
■AUTOALLOCATE specifies that the tablespace is system managed. Users cannot specify an extent size. This is the default if the COMPATIBLE initialization parameter is set to 9.0.0 or higher.
■UNIFORM specifies that the tablespace is managed with uniform extents of SIZE bytes. Use K or M to specify the extent size in kilobytes or megabytes. The default SIZE is 1 megabyte.
■Specify DICTIONARY if you want the tablespace to be managed using dictionary tables. This is the default if the COMPATIBLE initialization parameter is set less than 9.0.0.
Restriction on Dictionary-managed Tablespaces You cannot specify
DICTIONARY if the SYSTEM tablespace of the database is locally managed.
Note: Oracle Corporation strongly recommends that you create only locally managed tablespaces. Locally managed tablespaces are much more efficiently managed than dictionary-managed tablespaces. The creation of new dictionary-managed tablespaces is scheduled for desupport.
If you do not specify the extent_management_clause, then Oracle interprets the
COMPATIBLE setting, the MINIMUM EXTENT clause and the DEFAULT storage_ clause to determine extent management. If the COMPATIBLE initialization
SQL Statements: CREATE SYNONYM to CREATE TRIGGER 15-87

CREATE TABLESPACE
parameter is less than 9.0.0, then Oracle creates a dictionary managed tablespace. If COMPATIBLE = 9.0.0 or higher:
■If you do not specify the DEFAULT storage_clause, then Oracle creates a locally managed autoallocated tablespace.
■If you did specify the DEFAULT storage_clause:
■If you specified the MINIMUM EXTENT clause, then Oracle evaluates whether the values of MINIMUM EXTENT, INITIAL, and NEXT are equal and the value of PCTINCREASE is 0. If so, Oracle creates a locally managed uniform tablespace with extent size = INITIAL. If the MINIMUM EXTENT, INITIAL, and NEXT parameters are not equal, or if PCTINCREASE is not 0, Oracle ignores any extent storage parameters you may specify and creates a locally managed, autoallocated tablespace.
■If you did not specify MINIMUM EXTENT clause, then Oracle evaluates only whether the storage values of INITIAL and NEXT are equal and PCTINCREASE is 0. If so, the tablespace is locally managed and uniform. Otherwise, the tablespace is locally managed and autoallocated.
See Also: Oracle9i Database Concepts for a discussion of locally managed tablespaces
Restrictions on Extent Management
■A permanent locally managed tablespace can contain only permanent objects. If you need a locally managed tablespace to store temporary objects (for example, if you will assign it as a user’s temporary tablespace, use the CREATE TEMPORARY TABLESPACE statement.
■If you specify LOCAL, then you cannot specify DEFAULT storage_clause,
MINIMUM EXTENT, or TEMPORARY.
See Also: Oracle9i Database Migration Guide for information on changing extent management by migrating tablespaces and "Creating a Locally Managed Tablespace: Example" on page 15-90
segment_management_clause
The segment_management_clause is relevant only for permanent, locally managed tablespaces. It lets you specify whether Oracle should track the used and free space in the segments in the tablespace using free lists or bitmaps.
15-88 Oracle9i SQL Reference

CREATE TABLESPACE
MANUAL Specify MANUAL if you want Oracle to manage the free space of segments in the tablespace using free lists.
AUTO Specify AUTO if you want Oracle to manage the free space of segments in the tablespace using a bitmap. If you specify AUTO, then Oracle ignores any specification for PCTUSED, FREELIST, and FREELIST GROUPS in subsequent storage specifications for objects in this tablespace. This setting is called automatic segment-space management.
To determine the segment management of an existing tablespace, query the
SEGMENT_SPACE_MANAGEMENT column of the DBA_TABLESPACES or USER_ TABLESPACES data dictionary view.
Notes: If you specify AUTO, then:
■If you set extent management to LOCAL UNIFORM, then you must ensure that each extent contains at least 5 database blocks, given the database block size.
■If you set extent management to LOCAL AUTOALLOCATE, and if the database block size is 16K or greater, then Oracle manages segment space by creating extents with a minimum size of 1M.
Restrictions on Automatic Segment-space Management
■You can specify this clause only for permanent, locally managed tablespace.
■You cannot specify this clause for the SYSTEM tablespace.
See Also:
■Oracle9i Database Administrator’s Guide for information on automatic segment-space management and when to use it
■
■
Oracle9i Database Reference for information on the data dictionary views
"Specifying Segment Space Management for a Tablespace: Example" on page 15-90
Examples
Creating an Undo Tablespace: Example The following example creates a 10 MB undo tablespace undots1 with datafile undotbs_1a.f:
SQL Statements: CREATE SYNONYM to CREATE TRIGGER 15-89

CREATE TABLESPACE
CREATE UNDO |
TABLESPACE |
undots1 |
DATAFILE |
’undotbs_1a.f’ |
|
SIZE 10M |
AUTOEXTEND |
ON; |
Creating a Tablespace with Default Storage: Example This statement creates a tablespace named tbs_01 with one datafile:
CREATE TABLESPACE tbs_01
DATAFILE ’tbs_f2.dat’ SIZE 40M
DEFAULT STORAGE (INITIAL 128K NEXT 128K
MINEXTENTS 1 MAXEXTENTS 999)
ONLINE;
Enabling Autoextend for a Tablespace: Example This statement creates a tablespace named tbs_02 with one datafile. When more space is required, 500 kilobyte extents will be added up to a maximum size of 10 megabytes:
CREATE TABLESPACE tbs_02
DATAFILE ’diskb:tbs_f5.dat’ SIZE 500K REUSE
AUTOEXTEND ON NEXT 500K MAXSIZE 100M;
Specifying Minimum Extent Size: Example This statement creates tablespace tbs_03 with one datafile and allocates every extent as a multiple of 500K:
CREATE TABLESPACE tbs_03
DATAFILE ’tbs_f03.dbf’ SIZE 20M
MINIMUM EXTENT 500K
DEFAULT STORAGE (INITIAL 128K NEXT 128K)
LOGGING;
Creating a Locally Managed Tablespace: Example In the following statement, we assume that the database block size is 2K.
CREATE TABLESPACE tbs_04 DATAFILE ’file_1.f’ SIZE 10M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K;
This statement creates a locally managed tablespace in which every extent is 128K and each bit in the bit map describes 64 blocks.
Specifying Segment Space Management for a Tablespace: Example The following example creates a tablespace with automatic segment-space management:
CREATE TABLESPACE auto_seg_ts DATAFILE ’file_2.f’ SIZE 1M EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO;
15-90 Oracle9i SQL Reference

CREATE TABLESPACE
Creating Oracle-managed Files: Examples The following example sets the default location for datafile creation and creates a tablespace with a datafile in the default location. The datafile is 100M and is autoextensible with an unlimited maximum size:
ALTER SYSTEM SET DB_CREATE_FILE_DEST = ’$ORACLE_HOME/rdbms/log’;
CREATE TABLESPACE omf_ts1;
The following example creates a tablespace with an Oracle managed datafile of 100M that is not autoextensible:
CREATE TABLESPACE omf_ts2 DATAFILE AUTOEXTEND OFF;
SQL Statements: CREATE SYNONYM to CREATE TRIGGER 15-91