Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / SQL reference.pdf
Скачиваний:
24
Добавлен:
12.05.2015
Размер:
11.92 Mб
Скачать

deallocate_unused_clause

deallocate_unused_clause

Purpose

Use the deallocate_unused_clause to explicitly deallocate unused space at the end of a database object segment and make the space available for other segments in the tablespace.

You can deallocate unused space using the following statements:

ALTER CLUSTER (see ALTER CLUSTER on page 9-6)

ALTER INDEX: to deallocate unused space from the index, an index partition, or an index subpartition (see ALTER INDEX on page 9-62)

ALTER MATERIALIZED VIEW: to deallocate unused space from the overflow segment of an index-organized materialized view (see ALTER MATERIALIZED VIEW on page 9-90)

ALTER TABLE: to deallocate unused space from the table, a table partition, a table subpartition, the mapping table of an index-organized table, the overflow segment of an index-organized table, or a LOB storage segment (see ALTER TABLE on page 11-2)

Syntax

deallocate_unused_clause::=

K

M

KEEP integer

DEALLOCATE UNUSED

Semantics

This section describes the semantics of the deallocate_unused_clause. For additional information, refer to the SQL statement in which you set or reset this clause for a particular database object.

Note: You cannot specify both the deallocate_unused_ clause and the allocate_extent_clause in the same statement.

Common SQL DDL Clauses 7-37

deallocate_unused_clause

Oracle frees only unused space above the high water mark (that is, the point beyond which database blocks have not yet been formatted to receive data). Oracle deallocates unused space beginning from the end of the object and moving toward the beginning of the object to the high water mark.

If an extent is completely contained in the deallocation, then the whole extent is freed for reuse. If an extent is partially contained in the deallocation, then the used part up to the high water mark becomes the extent, and the remaining unused space is freed for reuse.

Oracle credits the amount of the released space to the user quota for the tablespace in which the deallocation occurs.

The exact amount of space freed depends on the values of the INITIAL, MINEXTENTS, and NEXT storage parameters.

See Also: storage_clause on page 7-56 for a description of these parameters

KEEP integer

Specify the number of bytes above the high water mark that the segment of the database object is to have after deallocation.

If you omit KEEP and the high water mark is above the size of INITIAL and MINEXTENTS, then all unused space above the high water mark is freed. When the high water mark is less than the size of INITIAL or MINEXTENTS, then all unused space above MINEXTENTS is freed.

If you specify KEEP, then the specified amount of space is kept and the remaining space is freed. When the remaining number of extents is less than MINEXTENTS, then MINEXTENTS is adjusted to the new number of extents. If the initial extent becomes smaller than INITIAL, then INITIAL is adjusted to the new size.

In either case, Oracle sets the value of the NEXT storage parameter to the size of the last extent that was deallocated.

7-38 Oracle9i SQL Reference

file_specification

file_specification

Purpose

Use one of the file_specification forms to specify a file as a datafile or tempfile, or to specify a group of one or more files as a redo log file group.

A file_specification can appear in the following statements:

CREATE CONTROLFILE (see CREATE CONTROLFILE on page 13-15)

CREATE DATABASE (see CREATE DATABASE on page 13-23)

ALTER DATABASE (see ALTER DATABASE on page 9-11)

CREATE TABLESPACE (see CREATE TABLESPACE on page 15-80)

CREATE TEMPORARY TABLESPACE (see CREATE TEMPORARY TABLESPACE on page 15-92)

ALTER TABLESPACE (see ALTER TABLESPACE on page 11-102)

Prerequisites

You must have the privileges necessary to issue one of the statements listed in the preceding section.

Syntax

file_specification::=

datafile_tempfile_spec

redo_log_file_spec

datafile_tempfile_spec::=

 

 

 

 

 

K

 

 

 

 

 

 

M

 

filename

SIZE

integer

REUSE

autoextend_clause

Common SQL DDL Clauses 7-39

file_specification

redo_log_file_spec::=

filename

 

 

 

 

K

 

 

 

 

 

 

 

 

 

,

 

 

 

 

M

 

 

 

 

 

 

 

(

filename

)

SIZE

integer

REUSE

autoextend_clause::=

OFF

 

 

 

 

K

AUTOEXTEND

 

M

 

 

NEXT

integer

maxsize_clause

ON

 

 

maxsize_clause::=

UNLIMITED

K

MAXSIZE

M

integer

Semantics

This section describes the semantics of file_specification. For additional information, refer to the SQL statement in which you specify a datafile, tempfile, or redo log file.

’filename’

For a new file, filename is the name of the new file. If you are not using Oraclemanaged files, then you must specify filename or the statement fails. However, if you are using Oracle-managed files, then filename is optional, as are the remaining clauses of the specification. In this case, Oracle creates a unique name for the file and saves it in the directory specified by either the DB_CREATE_FILE_DEST initialization parameter (for any type of file) or by the DB_CREATE_ONLINE_LOG_ DEST_n initialization parameter (which takes precedence over DB_CREATE_FILE_ DEST for log files).

7-40 Oracle9i SQL Reference

file_specification

See Also: Oracle9i Database Administrator’s Guide for more information on Oracle-managed files, "Specifying a Datafile: Example" on page 7-43, and "Specifying a Log File: Example" on page 7-43

For an existing file, you must specify a filename. Specify the name of either a datafile, tempfile, or a redo log file member. The filename can contain only singlebyte characters from 7-bit ASCII or EBCDIC character sets. Multibyte characters are not valid.

A redo log file group can have one or more members (copies). Each filename must be fully specified according to the conventions for your operating system.

SIZE Clause

Specify the size of the file in bytes. Use K or M to specify the size in kilobytes or megabytes.

For undo tablespaces, you must specify the SIZE clause for each datafile. For other tablespaces, you can omit this parameter if the file already exists, or if you are creating an Oracle-managed file.

If you omit this clause when creating an Oracle-managed file, then Oracle creates a 100M file.

The size of a tablespace must be one block greater than the sum of the sizes of the objects contained in it.

See Also: Oracle9i Database Administrator’s Guide for information on Automatic Undo Management and undo tablespaces and "Adding a Log File: Example" on page 7-43

REUSE

Specify REUSE to allow Oracle to reuse an existing file. You must specify REUSE if you specify a filename that already exists.

If the file already exists, then Oracle reuses the filename and applies the new size (if you specify SIZE) or retains the original size.

If the file does not exist, then Oracle ignores this clause and creates the file.

Restriction on the REUSE Clause You cannot specify REUSE unless you have specified filename.

Common SQL DDL Clauses 7-41

file_specification

Note: Whenever Oracle uses an existing file, the file’s previous contents are lost.

See Also: "Adding a Datafile: Example" on page 7-44 and "Adding a Log File: Example" on page 7-43

autoextend_clause

Use the autoextend_clause to enable or disable the automatic extension of a new datafile or tempfile. If you omit this clause:

For Oracle-managed files:

If you specify SIZE, Oracle creates a file of the specified size with

AUTOEXTEND disabled.

If you do not specify SIZE, Oracle creates a 100M file with AUTOEXTEND enabled and MAXSIZE unlimited.

For user-managed files, with or without SIZE specified, Oracle creates a file with AUTOEXTEND disabled.

ON Specify ON to enable autoextend.

OFF Specify OFF to turn off autoextend if is turned on.

Note: When you turn off autoextend, the values of NEXT and MAXSIZE are set to zero. If you turn autoextend back on in a subsequent statement, you must reset these values.

NEXT Use the NEXT clause to specify the size in bytes of the next increment of disk space to be allocated automatically when more extents are required. Use K or M to specify this size in kilobytes or megabytes. The default is the size of one data block.

MAXSIZE Use the MAXSIZE clause to specify the maximum disk space allowed for automatic extension of the datafile.

UNLIMITED Use the UNLIMITED clause if you do not want to limit the disk space that Oracle can allocate to the datafile or tempfile.

7-42 Oracle9i SQL Reference

file_specification

Restriction on the autoextend_clause You cannot specify this clause as part of datafile_tempfile_spec in a CREATE CONTROLFILE statement or in an

ALTER DATABASE CREATE DATAFILE clause.

Examples

Specifying a Log File: Example The following statement creates a database named payable that has two redo log file groups, each with two members, and one datafile:

CREATE DATABASE payable

LOGFILE GROUP 1 (’diska:log1.log’, ’diskb:log1.log’) SIZE 50K, GROUP 2 (’diska:log2.log’, ’diskb:log2.log’) SIZE 50K

DATAFILE ’diskc:dbone.dat’ SIZE 30M;

The first file specification in the LOGFILE clause specifies a redo log file group with the GROUP value 1. This group has members named ’diska:log1.log’ and ’diskb:log1.log’, each 50 kilobytes in size.

The second file specification in the LOGFILE clause specifies a redo log file group with the GROUP value 2. This group has members named ’diska:log2.log’ and ’diskb:log2.log’, also 50 kilobytes in size.

The file specification in the DATAFILE clause specifies a datafile named ’diskc:dbone.dat’, 30 megabytes in size.

Each file specification specifies a value for the SIZE parameter and omits the REUSE clause, so none of these files can already exist. Oracle must create them.

Adding a Log File: Example The following statement adds another redo log file group with two members to the payable database:

ALTER DATABASE payable

ADD LOGFILE GROUP 3 (’diska:log3.log’, ’diskb:log3.log’)

SIZE 50K REUSE;

The file specification in the ADD LOGFILE clause specifies a new redo log file group with the GROUP value 3. This new group has members named ’diska:log3.log’ and ’diskb:log3.log’, each 50 kilobytes in size. Because the file specification specifies the REUSE clause, each member can (but need not) already exist.

Specifying a Datafile: Example The following statement creates a tablespace named stocks that has three datafiles:

Common SQL DDL Clauses 7-43

file_specification

CREATE TABLESPACE stocks

DATAFILE ’stock1.dat’ SIZE 10M, ’stock2.dat’ SIZE 10M, ’stock3.dat’ SIZE 10M;

The file specifications for the datafiles specify files named ’diskc:stock1.dat’, ’diskc:stock2.dat’, and ’diskc:stock3.dat’.

Adding a Datafile: Example The following statement alters the stocks tablespace and adds a new datafile:

ALTER TABLESPACE stocks

ADD DATAFILE ’stock4.dat’ SIZE 10M REUSE;

The file specification specifies a datafile named ’diskc:stock4.dat’. If the filename does not exist, then Oracle simply ignores the REUSE keyword.

7-44 Oracle9i SQL Reference

Соседние файлы в папке Oracle selected docs