|Oracle® Database Administrator's Guide
11g Release 1 (11.1)
|PDF · Mobi · ePub|
A cluster can be dropped if the tables within the cluster are no longer needed. When a cluster is dropped, so are the tables within the cluster and the corresponding cluster index. All extents belonging to both the cluster data segment and the index segment of the cluster index are returned to the containing tablespace and become available for other segments within the tablespace.
DROP CLUSTER emp_dept;
If the cluster contains one or more clustered tables and you intend to drop the tables as well, add the
INCLUDING TABLES clause of the
DROP CLUSTER statement, as follows:
DROP CLUSTER emp_dept INCLUDING TABLES;
INCLUDING TABLES clause is not included and the cluster contains tables, an error is returned.
If one or more tables in a cluster contain primary or unique keys that are referenced by
FOREIGN KEY constraints of tables outside the cluster, the cluster cannot be dropped unless the dependent
FOREIGN KEY constraints are also dropped. This can be easily done using the
CASCADE CONSTRAINTS clause of the
DROP CLUSTER statement, as shown in the following example:
DROP CLUSTER emp_dept INCLUDING TABLES CASCADE CONSTRAINTS;
The database returns an error if you do not use the
CASCADE CONSTRAINTS clause and constraints exist.
See Also:Oracle Database SQL Language Reference for syntax of the
To drop a cluster, your schema must contain the cluster or you must have the
DROP ANY CLUSTER system privilege. You do not need additional privileges to drop a cluster that contains tables, even if the clustered tables are not owned by the owner of the cluster.
Clustered tables can be dropped individually without affecting the cluster, other clustered tables, or the cluster index. A clustered table is dropped just as a nonclustered table is dropped, with the
DROP TABLE statement. See "Dropping Table Columns".
Note:When you drop a single table from a cluster, the database deletes each row of the table individually. To maximize efficiency when you intend to drop an entire cluster, drop the cluster including all tables by using the
DROP CLUSTERstatement with the
INCLUDING TABLESclause. Drop an individual table from a cluster (using the
DROP TABLEstatement) only if you want the rest of the cluster to remain.
A cluster index can be dropped without affecting the cluster or its clustered tables. However, clustered tables cannot be used if there is no cluster index; you must re-create the cluster index to allow access to the cluster. Cluster indexes are sometimes dropped as part of the procedure to rebuild a fragmented cluster index. For information about dropping an index, see "Dropping Indexes".