Skip Headers
Oracle® Database SQL Reference
10g Release 2 (10.2)

Part Number B14200-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

ALTER TABLE

Purpose

Use the ALTER TABLE statement to alter the definition of a nonpartitioned table, a partitioned table, a table partition, or a table subpartition. For object tables or relational tables with object columns, use ALTER TABLE to convert the table to the latest definition of its referenced type after the type has been altered.

See Also:

Additional Topics:

Prerequisites

The table must be in your own schema, or you must have ALTER object privilege on the table, or you must have ALTER ANY TABLE system privilege.

Additional Prerequisites for Partitioning Operations If you are not the owner of the table, then you need the DROP ANY TABLE privilege in order to use the drop_table_partition or truncate_table_partition clause.

You must also have space quota in the tablespace in which space is to be acquired in order to use the add_table_partition, modify_table_partition, move_table_partition, and split_table_partition clauses.

Additional Prerequisites for Constraints and Triggers To enable a unique or primary key constraint, you must have the privileges necessary to create an index on the table. You need these privileges because Oracle Database creates an index on the columns of the unique or primary key in the schema containing the table.

To enable or disable triggers, the triggers must be in your schema or you must have the ALTER ANY TRIGGER system privilege.

Additional Prerequisites When Using Object Types To use an object type in a column definition when modifying a table, either that object must belong to the same schema as the table being altered, or you must have either the EXECUTE ANY TYPE system privilege or the EXECUTE schema object privilege for the object type.

See Also:

CREATE INDEX for information on the privileges needed to create indexes

Syntax

alter_table::=

Description of alter_table.gif follows
Description of the illustration alter_table.gif

Note:

You must specify some clause after table. That is, none of the clauses after table are required, but you must specify at least one of them.

Groups of ALTER TABLE syntax:

After each clause you will find links to its component subclauses.

alter_table_properties::=

Description of alter_table_properties.gif follows
Description of the illustration alter_table_properties.gif

(physical_attributes_clause::=, logging_clause::=, table_compression ::=, supplemental_table_logging ::=, allocate_extent_clause ::=, deallocate_unused_clause::= , shrink_clause::=, upgrade_table_clause ::=, records_per_block_clause ::=, parallel_clause::=, row_movement_clause::=, alter_iot_clauses::=)

physical_attributes_clause::=

Description of physical_attributes_clause.gif follows
Description of the illustration physical_attributes_clause.gif

(storage_clause::=)

logging_clause::=

Description of logging_clause.gif follows
Description of the illustration logging_clause.gif

table_compression ::=

Description of table_compression.gif follows
Description of the illustration table_compression.gif

supplemental_table_logging ::=

Description of supplemental_table_logging.gif follows
Description of the illustration supplemental_table_logging.gif

supplemental_log_grp_clause::=

Description of supplemental_log_grp_clause.gif follows
Description of the illustration supplemental_log_grp_clause.gif

supplemental_id_key_clause::=

Description of supplemental_id_key_clause.gif follows
Description of the illustration supplemental_id_key_clause.gif

allocate_extent_clause ::=

Description of allocate_extent_clause.gif follows
Description of the illustration allocate_extent_clause.gif

(size_clause::=)

deallocate_unused_clause::=

Description of deallocate_unused_clause.gif follows
Description of the illustration deallocate_unused_clause.gif

(size_clause::=)

shrink_clause::=

Description of shrink_clause.gif follows
Description of the illustration shrink_clause.gif

upgrade_table_clause ::=

Description of upgrade_table_clause.gif follows
Description of the illustration upgrade_table_clause.gif

(column_properties::=)

records_per_block_clause ::=

Description of records_per_block_clause.gif follows
Description of the illustration records_per_block_clause.gif

parallel_clause::=

Description of parallel_clause.gif follows
Description of the illustration parallel_clause.gif

row_movement_clause::=

Description of row_movement_clause.gif follows
Description of the illustration row_movement_clause.gif

alter_iot_clauses::=

Description of alter_iot_clauses.gif follows
Description of the illustration alter_iot_clauses.gif

(alter_overflow_clause ::=, alter_mapping_table_clauses ::=)

index_org_table_clause ::=

Description of index_org_table_clause.gif follows
Description of the illustration index_org_table_clause.gif

mapping_table_clauses::=

Description of mapping_table_clauses.gif follows
Description of the illustration mapping_table_clauses.gif

key_compression::=

Description of key_compression.gif follows
Description of the illustration key_compression.gif

index_org_overflow_clause::=

Description of index_org_overflow_clause.gif follows
Description of the illustration index_org_overflow_clause.gif

(segment_attributes_clause::=)

segment_attributes_clause::=

Description of segment_attributes_clause.gif follows
Description of the illustration segment_attributes_clause.gif

(physical_attributes_clause::=, logging_clause::=)

alter_overflow_clause ::=

Description of alter_overflow_clause.gif follows
Description of the illustration alter_overflow_clause.gif

(segment_attributes_clause::=, allocate_extent_clause ::=, shrink_clause::=, deallocate_unused_clause::=)

add_overflow_clause::=

Description of add_overflow_clause.gif follows
Description of the illustration add_overflow_clause.gif

(segment_attributes_clause::=)

alter_mapping_table_clauses ::=

Description of alter_mapping_table_clauses.gif follows
Description of the illustration alter_mapping_table_clauses.gif

(allocate_extent_clause ::=, deallocate_unused_clause::=)

column_clauses::=

Description of column_clauses.gif follows
Description of the illustration column_clauses.gif

(add_column_clause ::=, modify_column_clauses::=, drop_column_clause ::=, rename_column_clause ::=, modify_collection_retrieval ::=, modify_LOB_storage_clause::=, alter_varray_col_properties::=, encryption_spec::=)

add_column_clause ::=

Description of add_column_clause.gif follows
Description of the illustration add_column_clause.gif

(column_definition::=, column_properties::=)

column_definition::=

Description of column_definition.gif follows
Description of the illustration column_definition.gif

(encryption_spec::=, inline_constraint and inline_ref_constraint: constraint::=)

modify_column_clauses::=

Description of modify_column_clauses.gif follows
Description of the illustration modify_column_clauses.gif

modify_col_properties::=

Description of modify_col_properties.gif follows
Description of the illustration modify_col_properties.gif

(encryption_spec::=, inline_constraint: constraint::=, LOB_storage_clause::=)

encryption_spec::=

Description of encryption_spec.gif follows
Description of the illustration encryption_spec.gif

modify_col_substitutable::=

Description of modify_col_substitutable.gif follows
Description of the illustration modify_col_substitutable.gif

drop_column_clause ::=

Description of drop_column_clause.gif follows
Description of the illustration drop_column_clause.gif

rename_column_clause ::=

Description of rename_column_clause.gif follows
Description of the illustration rename_column_clause.gif

modify_collection_retrieval ::=

Description of modify_collection_retrieval.gif follows
Description of the illustration modify_collection_retrieval.gif

constraint_clauses::=

Description of constraint_clauses.gif follows
Description of the illustration constraint_clauses.gif

(constraint_state: constraint::=)

drop_constraint_clause::=

Description of drop_constraint_clause.gif follows
Description of the illustration drop_constraint_clause.gif

column_properties::=

Description of column_properties.gif follows
Description of the illustration column_properties.gif

object_type_col_properties::=

Description of object_type_col_properties.gif follows
Description of the illustration object_type_col_properties.gif

substitutable_column_clause::=

Description of substitutable_column_clause.gif follows
Description of the illustration substitutable_column_clause.gif

nested_table_col_properties::=

Description of nested_table_col_properties.gif follows
Description of the illustration nested_table_col_properties.gif

object_properties::=

Description of object_properties.gif follows
Description of the illustration object_properties.gif

(inline_constraint, inline_ref_constraint, out_of_line_constraint, out_of_line_ref_constraint: constraint::=)

supplemental_logging_props::=

Description of supplemental_logging_props.gif follows
Description of the illustration supplemental_logging_props.gif

(supplemental_log_grp_clause::=, supplemental_id_key_clause::=)

physical_properties::=

Description of physical_properties.gif follows
Description of the illustration physical_properties.gif

(segment_attributes_clause::=, index_org_table_clause ::=, external_data_properties::=)

varray_col_properties::=

Description of varray_col_properties.gif follows
Description of the illustration varray_col_properties.gif

(substitutable_column_clause::=)

LOB_storage_clause::=

Description of LOB_storage_clause.gif follows
Description of the illustration LOB_storage_clause.gif

LOB_parameters::=

Description of LOB_parameters.gif follows
Description of the illustration LOB_parameters.gif

(storage_clause::=, logging_clause::=)

modify_LOB_storage_clause::=

Description of modify_LOB_storage_clause.gif follows
Description of the illustration modify_LOB_storage_clause.gif

modify_LOB_parameters::=

Description of modify_LOB_parameters.gif follows
Description of the illustration modify_LOB_parameters.gif

(storage_clause::=, logging_clause::=, allocate_extent_clause ::=, shrink_clause::=, deallocate_unused_clause::=)

alter_varray_col_properties::=

Description of alter_varray_col_properties.gif follows
Description of the illustration alter_varray_col_properties.gif

LOB_partition_storage ::=

Description of LOB_partition_storage.gif follows
Description of the illustration LOB_partition_storage.gif

(LOB_storage_clause::=, varray_col_properties::=)

XMLType_column_properties::=

Description of XMLType_column_properties.gif follows
Description of the illustration XMLType_column_properties.gif

XMLType_storage::=

Description of XMLType_storage.gif follows
Description of the illustration XMLType_storage.gif

XMLSchema_spec::=

Description of XMLSchema_spec.gif follows
Description of the illustration XMLSchema_spec.gif

alter_external_table_clauses ::=

Description of alter_external_table_clauses.gif follows
Description of the illustration alter_external_table_clauses.gif

(add_column_clause ::=, modify_column_clauses::=, drop_column_clause ::=, drop_constraint_clause::=, parallel_clause::=)

external_data_properties::=

Description of external_data_properties.gif follows
Description of the illustration external_data_properties.gif

alter_table_partitioning ::=

Description of alter_table_partitioning.gif follows
Description of the illustration alter_table_partitioning.gif

(modify_table_default_attrs ::=, set_subpartition_template ::=, modify_table_partition::=, modify_table_subpartition::=, move_table_partition ::=, move_table_subpartition::=, add_table_partition::=, coalesce_table_partition::=, drop_table_partition::=, drop_table_subpartition ::=, rename_partition_subpart::=, truncate_partition_subpart::=, split_table_partition::=, split_table_subpartition ::=, merge_table_partitions ::=, merge_table_subpartitions ::=, exchange_partition_subpart ::=

modify_table_default_attrs ::=

Description of modify_table_default_attrs.gif follows
Description of the illustration modify_table_default_attrs.gif

(segment_attributes_clause::=, table_compression ::=, key_compression::=, LOB_parameters::=, alter_overflow_clause ::=)

set_subpartition_template ::=

Description of set_subpartition_template.gif follows
Description of the illustration set_subpartition_template.gif

(list_values_clause::=, partitioning_storage_clause::=)

modify_table_partition::=

Description of modify_table_partition.gif follows
Description of the illustration modify_table_partition.gif

(modify_range_partition::=, modify_hash_partition::=, modify_list_partition::=)

modify_range_partition::=

Description of modify_range_partition.gif follows
Description of the illustration modify_range_partition.gif

(partition_attributes::=, update_index_clauses::=, alter_mapping_table_clauses ::=)

modify_hash_partition::=

Description of modify_hash_partition.gif follows
Description of the illustration modify_hash_partition.gif

(partition_attributes::=, add_hash_subpartition ::=, parallel_clause, alter_mapping_table_clauses ::=)

modify_list_partition::=

Description of modify_list_partition.gif follows
Description of the illustration modify_list_partition.gif

(partition_attributes::=, add_list_subpartition::=)

modify_table_subpartition::=

Description of modify_table_subpartition.gif follows
Description of the illustration modify_table_subpartition.gif

(modify_hash_subpartition::=, modify_list_subpartition ::=)

move_table_partition ::=

Description of move_table_partition.gif follows
Description of the illustration move_table_partition.gif

(table_partition_description::=, update_index_clauses::=, parallel_clause::=)

move_table_subpartition::=

Description of move_table_subpartition.gif follows
Description of the illustration move_table_subpartition.gif

(subpartition_spec::=, update_index_clauses::=, parallel_clause::=)

add_table_partition::=

Description of add_table_partition.gif follows
Description of the illustration add_table_partition.gif

add_range_partition_clause::=

Description of add_range_partition_clause.gif follows
Description of the illustration add_range_partition_clause.gif

(range_values_clause::=, table_partition_description::=, update_index_clauses::=)

add_hash_partition_clause ::=

Description of add_hash_partition_clause.gif follows
Description of the illustration add_hash_partition_clause.gif

(partitioning_storage_clause::=, update_index_clauses::=, parallel_clause::=)

add_list_partition_clause ::=

Description of add_list_partition_clause.gif follows
Description of the illustration add_list_partition_clause.gif

(list_values_clause::=, table_partition_description::=, update_index_clauses::=)

coalesce_table_partition::=

Description of coalesce_table_partition.gif follows
Description of the illustration coalesce_table_partition.gif

(update_index_clauses::=, parallel_clause::=)

drop_table_partition::=

Description of drop_table_partition.gif follows
Description of the illustration drop_table_partition.gif

(update_index_clauses::=, parallel_clause::=)

drop_table_subpartition ::=

Description of drop_table_subpartition.gif follows
Description of the illustration drop_table_subpartition.gif

(update_index_clauses::=, parallel_clause::=)

rename_partition_subpart::=

Description of rename_partition_subpart.gif follows
Description of the illustration rename_partition_subpart.gif

truncate_partition_subpart::=

Description of truncate_partition_subpart.gif follows
Description of the illustration truncate_partition_subpart.gif

(update_index_clauses::=, parallel_clause::=)

split_table_partition::=

Description of split_table_partition.gif follows
Description of the illustration split_table_partition.gif

(partition_spec::=, update_index_clauses::=, parallel_clause::=)

split_table_subpartition ::=

Description of split_table_subpartition.gif follows
Description of the illustration split_table_subpartition.gif

(subpartition_spec::=, update_index_clauses::=, parallel_clause::=)

merge_table_partitions ::=

Description of merge_table_partitions.gif follows
Description of the illustration merge_table_partitions.gif

(partition_spec::=, update_index_clauses::=, parallel_clause::=)

merge_table_subpartitions ::=

Description of merge_table_subpartitions.gif follows
Description of the illustration merge_table_subpartitions.gif

(subpartition_spec::=, parallel_clause::=)

exchange_partition_subpart ::=

Description of exchange_partition_subpart.gif follows
Description of the illustration exchange_partition_subpart.gif

(update_index_clauses::=, parallel_clause::=)

exceptions_clause::=

Description of exceptions_clause.gif follows
Description of the illustration exceptions_clause.gif

list_values_clause::=

Description of list_values_clause.gif follows
Description of the illustration list_values_clause.gif

range_values_clause::=

Description of range_values_clause.gif follows
Description of the illustration range_values_clause.gif

partitioning_storage_clause::=

Description of partitioning_storage_clause.gif follows
Description of the illustration partitioning_storage_clause.gif

partition_attributes::=

Description of partition_attributes.gif follows
Description of the illustration partition_attributes.gif

(physical_attributes_clause::=, logging_clause::=, allocate_extent_clause ::=, deallocate_unused_clause::=, shrink_clause::=, table_compression ::=, modify_LOB_parameters::=)

add_hash_subpartition ::=

Description of add_hash_subpartition.gif follows
Description of the illustration add_hash_subpartition.gif

(subpartition_spec::=, update_index_clauses::=, parallel_clause::=)

add_list_subpartition::=

Description of add_list_subpartition.gif follows
Description of the illustration add_list_subpartition.gif

(subpartition_spec::=, update_index_clauses::=)

modify_hash_subpartition::=

Description of modify_hash_subpartition.gif follows
Description of the illustration modify_hash_subpartition.gif

(allocate_extent_clause ::=, deallocate_unused_clause::=, shrink_clause::=, modify_LOB_parameters::=)

modify_list_subpartition ::=

Description of modify_list_subpartition.gif follows
Description of the illustration modify_list_subpartition.gif

(allocate_extent_clause ::=, deallocate_unused_clause::=, shrink_clause::=, modify_LOB_parameters::=)

table_partition_description::=

Description of table_partition_description.gif follows
Description of the illustration table_partition_description.gif

(segment_attributes_clause::=, table_compression ::=, key_compression::=, LOB_storage_clause::=, varray_col_properties::=)

partition_level_subpartition::=

Description of partition_level_subpartition.gif follows
Description of the illustration partition_level_subpartition.gif

(subpartition_spec::=)

partition_spec::=

Description of partition_spec.gif follows
Description of the illustration partition_spec.gif

(table_partition_description::=)

subpartition_spec::=

Description of subpartition_spec.gif follows
Description of the illustration subpartition_spec.gif

(list_values_clause::=, partitioning_storage_clause::=)

update_index_clauses::=

Description of update_index_clauses.gif follows
Description of the illustration update_index_clauses.gif

(update_global_index_clause ::=, update_all_indexes_clause::=)

update_global_index_clause ::=

Description of update_global_index_clause.gif follows
Description of the illustration update_global_index_clause.gif

update_all_indexes_clause::=

Description of update_all_indexes_clause.gif follows
Description of the illustration update_all_indexes_clause.gif

update_index_partition::=

Description of update_index_partition.gif follows
Description of the illustration update_index_partition.gif

update_index_subpartition::=

Description of update_index_subpartition.gif follows
Description of the illustration update_index_subpartition.gif

index_partition_description::=

Description of index_partition_description.gif follows
Description of the illustration index_partition_description.gif

index_subpartition_clause::=

Description of index_subpartition_clause.gif follows
Description of the illustration index_subpartition_clause.gif

parallel_clause ::=

Description of parallel_clause.gif follows
Description of the illustration parallel_clause.gif

move_table_clause ::=

Description of move_table_clause.gif follows
Description of the illustration move_table_clause.gif

(segment_attributes_clause::=, table_compression ::=, index_org_table_clause ::=, LOB_storage_clause::=, varray_col_properties::=)

enable_disable_clause::=

Description of enable_disable_clause.gif follows
Description of the illustration enable_disable_clause.gif

(using_index_clause::=, exceptions_clause::=,)

using_index_clause::=

Description of using_index_clause.gif follows
Description of the illustration using_index_clause.gif

(create_index::=, index_properties::=)

index_properties::=

Description of index_properties.gif follows
Description of the illustration index_properties.gif

(global_partitioned_index ::=, local_partitioned_index ::=--part of CREATE INDEX, index_attributes::=, domain_index_clause: not supported in using_index_clause)

index_attributes::=

Description of index_attributes.gif follows
Description of the illustration index_attributes.gif

(physical_attributes_clause::=, logging_clause::=, key_compression::=, parallel_clause: not supported in using_index_clause)

Semantics

Many clauses of the ALTER TABLE statement have the same functionality they have in a CREATE TABLE statement. For more information on such clauses, please see CREATE TABLE.

Note:

Operations performed by the ALTER TABLE statement can cause Oracle Database to invalidate procedures and stored functions that access the table. For information on how and when the database invalidates such objects, see Oracle Database Concepts.

schema

Specify the schema containing the table. If you omit schema, then Oracle Database assumes the table is in your own schema.

table

Specify the name of the table to be altered.

Note:

If you alter a table that is a master table for one or more materialized views, then Oracle Database marks the materialized views INVALID. Invalid materialized views cannot be used by query rewrite and cannot be refreshed. For information on revalidating a materialized view, see ALTER MATERIALIZED VIEW.

See Also:

Oracle Data Warehousing Guide for more information on materialized views in general

Restrictions on Altering Temporary Tables You can modify, drop columns from, or rename a temporary table. However, for a temporary table you cannot:

Restrictions on Altering External Tables You can add, drop, or modify the columns of an external table. However, for an external table you cannot:

alter_table_properties

Use the alter_table_clauses to modify a database table.

physical_attributes_clause

The physical_attributes_clause lets you change the value of the PCTFREE, PCTUSED, and INITRANS parameters and storage characteristics. Please refer to physical_attributes_clause and storage_clause for a full description of these parameters and characteristics.

Restrictions on Altering Table Physical Attributes Altering physical attributes is subject to the following restrictions:

Cautions on Altering Tables Physical Attributes The values you specify in this clause affect the table as follows:

logging_clause

Use the logging_clause to change the logging attribute of the table. The logging_clause specifies whether subsequent ALTER TABLE ... MOVE and ALTER TABLE ... SPLIT operations will be logged or not logged.

When used with the modify_table_default_attrs clause, this clause affects the logging attribute of a partitioned table.

See Also:

table_compression

The table_compression clause is valid only for heap-organized tables. Use this clause to instruct Oracle Database whether to compress data segments to reduce disk and memory use. The COMPRESS keyword enables table compression. The NOCOMPRESS keyword disables table compression.

Note:

The first time a table is altered in such a way that compressed data will be added, all bitmap indexes and bitmap index partitions on that table must be marked UNUSABLE.

See Also:

supplemental_table_logging

Use the supplemental_table_logging clause to add or drop a redo log group or one or more supplementally logged columns in a redo log group.

The supplemental_log_grp_clause and the supplemental_id_key_clause have the same semantics in CREATE TABLE and ALTER TABLE statements. For full information on these clauses, please refer to supplemental_log_grp_clause and supplemental_id_key_clause in the documentation on CREATE TABLE.

See Also:

Oracle Data Guard Concepts and Administration for information on supplemental redo log groups

allocate_extent_clause

Use the allocate_extent_clause to explicitly allocate a new extent for the table, the partition or subpartition, the overflow data segment, the LOB data segment, or the LOB index.

Restriction on Allocating Table Extents You cannot allocate an extent for a temporary table or for a range- or composite-partitioned table.

See Also:

allocate_extent_clause for a full description of this clause and "Allocating Extents: Example"

deallocate_unused_clause

Use the deallocate_unused_clause to explicitly deallocate unused space at the end of the table, partition or subpartition, overflow data segment, LOB data segment, or LOB index and make the space available for other segments in the tablespace.

See Also:

deallocate_unused_clause for a full description of this clause and "Deallocating Unused Space: Example"

shrink_clause

The shrink clause lets you manually shrink space in a table, index-organized table or its overflow segment, index, partition, subpartition, LOB segment, materialized view, or materialized view log. This clause is valid only for segments in tablespaces with automatic segment management. By default, Oracle Database compacts the segment, adjusts the high water mark, and releases the recuperated space immediately.

Compacting the segment requires row movement. Therefore, you must enable row movement for the object you want to shrink before specifying this clause. Further, if your application has any rowid-based triggers, you should disable them before issuing this clause.

COMPACT If you specify COMPACT, then Oracle Database only defragments the segment space and compacts the table rows for subsequent release. The database does not readjust the high water mark and does not release the space immediately. You must issue another ALTER TABLE ... SHRINK SPACE statement later to complete the operation. This clause is useful if you want to accomplish the shrink operation in two shorter steps rather than one longer step.

For an index or index-organized table, specifying ALTER [INDEX | TABLE] ... SHRINK SPACE COMPACT is equivalent to specifying ALTER [INDEX | TABLE ... COALESCE. The shrink_clause can be cascaded (please refer to the CASCADE clause, which follows) and compacts the segment more densely than does a coalesce operation, which can improve performance. However, if you do not want to release the unused space, then you can use the appropriate COALESCE clause.

CASCADE If you specify CASCADE, then Oracle Database performs the same operations on all dependent objects of table, including secondary indexes on index-organized tables.

Restrictions on the shrink_clause The shrink_clause is subject to the following restrictions:

CACHE | NOCACHE

The CACHE and NOCACHE clauses have the same semantics in CREATE TABLE and ALTER TABLE statements. For complete information on these clauses, please refer to "CACHE | NOCACHE | CACHE READS" in the documentation on CREATE TABLE. If you omit both of these clauses in an ALTER TABLE statement, then the existing value is unchanged.

upgrade_table_clause

The upgrade_table_clause is relevant for object tables and for relational tables with object columns. It lets you instruct Oracle Database to convert the metadata of the target table to conform with the latest version of each referenced type. If table is already valid, then the table metadata remains unchanged.

Restriction on Upgrading Object Tables and Columns Within this clause, you cannot specify object_type_col_properties as a clause of column_properties.

INCLUDING DATA Specify INCLUDING DATA if you want Oracle Database to convert the data in the table to the latest type version format. You can define the storage for any new column while upgrading the table by using the column_properties and the LOB_partition_storage . This is the default.

You can convert data in the table at the time you upgrade the type by specifying CASCADE INCLUDING TABLE DATA in the dependent_handling_clause of the ALTER TYPE statement. See dependent_handling_clause . For information on whether a table contains data based on an older type version, refer to the DATA_UPGRADED column of the USER_TAB_COLUMNS data dictionary view.

NOT INCLUDING DATA Specify NOT INCLUDING DATA if you want Oracle Database to leave column data unchanged.

Restriction on NOT INCLUDING DATA You cannot specify NOT INCLUDING DATA if the table contains columns in Oracle8 release 8.0.x image format. To determine whether the table contains such columns, refer to the V80_FMT_IMAGE column of the USER_TAB_COLUMNS data dictionary view.

See Also:

records_per_block_clause

The records_per_block_clause lets you specify whether Oracle Database restricts the number of records that can be stored in a block. This clause ensures that any bitmap indexes subsequently created on the table will be as compressed as possible.

Restrictions on Records in a Block The record_per_block_clause is subject to the following restrictions:

MINIMIZE Specify MINIMIZE to instruct Oracle Database to calculate the largest number of records in any block in the table and to limit future inserts so that no block can contain more than that number of records.

Oracle recommends that a representative set of data already exist in the table before you specify MINIMIZE. If you are using table compression (see table_compression ), then a representative set of compressed data should already exist in the table.

Restriction on MINIMIZE You cannot specify MINIMIZE for an empty table.

NOMINIMIZE Specify NOMINIMIZE to disable the MINIMIZE feature. This is the default.

row_movement_clause

This clause has the same semantics in CREATE TABLE and ALTER TABLE statements. For complete information on these clauses, please refer to row_movement_clause in the documentation on CREATE TABLE.

RENAME TO

Use the RENAME clause to rename table to new_table_name.

Note:

Using this clause invalidates any dependent materialized views. For more information on materialized views, see CREATE MATERIALIZED VIEW and Oracle Data Warehousing Guide.

alter_iot_clauses

index_org_table_clause

This clause lets you change a table that is not index organized into an index-organized table. Index-organized tables keep data sorted on the primary key and are therefore best suited for primary-key-based access and manipulation.See index_org_table_clause in the context of CREATE TABLE.

key_compression

This clause is relevant only if table is index organized. Specify COMPRESS to instruct Oracle Database to combine the primary key index blocks of the index-organized table where possible to free blocks for reuse. You can specify this clause with the parallel_clause.

PCTTHRESHOLD integer Please refer to "PCTTHRESHOLD integer" in the documentation of CREATE TABLE.

INCLUDING column_name Please refer to "INCLUDING column_name" in the documentation of CREATE TABLE.

overflow_attributes

The overflow_attributes let you specify the overflow data segment physical storage and logging attributes to be modified for the index-organized table. Parameter values specified in this clause apply only to the overflow data segment.

See Also:

CREATE TABLE

add_overflow_clause

The add_overflow_clause lets you add an overflow data segment to the specified index-organized table. You can also use this clause to explicitly allocate an extent to or deallocate unused space from an existing overflow segment.

Use the STORE IN tablespace clause to specify tablespace storage for the entire overflow segment. Use the PARTITION clause to specify tablespace storage for the segment by partition.

For a partitioned index-organized table:

You can find the order of the partitions by querying the PARTITION_NAME and PARTITION_POSITION columns of the USER_IND_PARTITIONS view.

If you do not specify TABLESPACE for a particular partition, then the database uses the tablespace specified for the table. If you do not specify TABLESPACE at the table level, then the database uses the tablespace of the partition primary key index segment.

Restrictions on Overflow Attributes Within the segment_attributes_clause:

Additional restrictions apply if table is in a locally managed tablespace, because in such tablespaces several segment attributes are managed automatically by the database.

See Also:

allocate_extent_clause and deallocate_unused_clause for full descriptions of these clauses of the add_overflow_clause

alter_overflow_clause

The alter_overflow_clause lets you change the definition of the overflow segment of an existing index-organized table.

The restrictions that apply to the add_overflow_clause also apply to the alter_overflow_clause.

Note:

When you add a column to an index-organized table, Oracle Database evaluates the maximum size of each column to estimate the largest possible row. If an overflow segment is needed but you have not specified OVERFLOW, then the database raises an error and does not execute the ALTER TABLE statement. This checking function guarantees that subsequent DML operations on the index-organized table will not fail because an overflow segment is lacking.

alter_mapping_table_clauses

The alter_mapping_table_clauses is valid only if table is index organized and has a mapping table.

allocate_extent_clause Use the allocate_extent_clause to allocate a new extent at the end of the mapping table for the index-organized table. Please refer to allocate_extent_clause for a full description of this clause.

deallocate_unused_clause Specify the deallocate_unused_clause to deallocate unused space at the end of the mapping table of the index-organized table. Please refer to deallocate_unused_clause for a full description of this clause.

Oracle Database automatically maintains all other attributes of the mapping table or its partitions.

COALESCE Clause

Specify COALESCE to instruct Oracle Database to merge the contents of index blocks of the index the database uses to maintain the index-organized table where possible to free blocks for reuse. Please refer to the shrink_clause for information on the relationship between these two clauses.

column_clauses

Use these clauses to add, drop, or otherwise modify a column.

add_column_clause

The add_column_clause lets you add a column to a table.

See Also:

CREATE TABLE for a description of the keywords and parameters of this clause and "Adding a Table Column: Example"

column_definition

Unless otherwise noted in this section, the elements of column_definition have the same behavior when adding a column to an existing table as they do when creating a new table. Please refer to column_definition for information.

Restriction on column_definition The SORT parameter is valid only when creating a new table. You cannot specify SORT in the column_definition of an ALTER TABLE ... ADD statement.

If you add a column, then the initial value of each row for the new column is null unless you specify the DEFAULT clause. In this case, Oracle Database updates each row in the new column with the value you specify for DEFAULT. This update operation, in turn, fires any AFTER UPDATE triggers defined on the table.

Note:

If a column has a default value, then you can use the DEFAULT clause to change the default to NULL, but you cannot remove the default value completely. That is, if a column has ever had a default value assigned to it, then the DATA_DEFAULT column of the USER_TAB_COLUMNS data dictionary view will always display either a default value or NULL.

You can add an overflow data segment to each partition of a partitioned index-organized table.

You can add LOB columns to nonpartitioned and partitioned tables. You can specify LOB storage at the table and at the partition or subpartition level.

If you previously created a view with a query that used the SELECT * syntax to select all columns from table, and you now add a column to table, then the database does not automatically add the new column to the view. To add the new column to the view, re-create the view using the CREATE VIEW statement with the OR REPLACE clause. Please refer to CREATE VIEW for more information.

Restrictions on Adding Columns The addition of columns is subject to the following restrictions:

DEFAULT

Use the DEFAULT clause to specify a default for a new column or a new default for an existing column. Oracle Database assigns this value to the column if a subsequent INSERT statement omits a value for the column. If you are adding a new column to the table and specify the default value, then the database inserts the default column value into all rows of the table.

The datatype of the default value must match the datatype specified for the column. The column must also be large enough to hold the default value.

Restrictions on Default Column Values Default column values are subject to the following restrictions:

inline_constraint

Use inline_constraint to add a constraint to the new column.

inline_ref_constraint

This clause lets you describe a new column of type REF. Please refer to constraint for syntax and description of this type of constraint, including restrictions.

column_properties

The clauses of column_properties determine the storage characteristics of an object type, nested table, varray, or LOB column.

object_type_col_properties This clause is valid only when you are adding a new object type column or attribute. To modify the properties of an existing object type column, use the modify_column_clauses. The semantics of this clause are the same as for CREATE TABLE unless otherwise noted.

Use the object_type_col_properties clause to specify storage characteristics for a new object column or attribute or an element of a collection column or attribute.

For complete information on this clause, please refer to object_type_col_properties in the documentation on CREATE TABLE.

nested_table_col_properties The nested_table_col_properties clause lets you specify separate storage characteristics for a nested table, which in turn lets you to define the nested table as an index-organized table. You must include this clause when creating a table with columns or column attributes whose type is a nested table. (Clauses within this clause that function the same way they function for parent object tables are not repeated here.)