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

DROP TABLESPACE

DROP TABLESPACE

Purpose

Use the DROP TABLESPACE statement to remove a tablespace from the database.

See Also:

CREATE TABLESPACE on page 15-80 for information on creating a tablespace

ALTER TABLESPACE on page 11-102 for information on modifying a tablespace

Prerequisites

You must have the DROP TABLESPACE system privilege. You cannot drop a tablespace if it contains any rollback segments holding active transactions.

Syntax

drop_tablespace::=

DROP

TABLESPACE

tablespace

 

 

 

 

 

 

AND

DATAFILES

CASCADE

CONSTRAINTS

INCLUDING

CONTENTS

 

 

 

 

;

Semantics

tablespace

Specify the name of the tablespace to be dropped.

You can drop a tablespace regardless of whether it is online or offline. Oracle recommends that you take the tablespace offline before dropping it to ensure that no SQL statements in currently running transactions access any of the objects in the tablespace.

You may want to alert any users who have been assigned the tablespace as either a default or temporary tablespace. After the tablespace has been dropped, these users cannot allocate space for objects or sort areas in the tablespace. You can reassign users new default and temporary tablespaces with the ALTER USER statement.

17-10 Oracle9i SQL Reference

DROP TABLESPACE

Oracle removes from the data dictionary all metadata about the tablespace and all datafiles and tempfiles in the tablespace. Oracle also automatically drops from the operating system any Oracle-managed datafiles and tempfiles in the tablespace.

Other datafiles and tempfiles are not removed from the operating system unless you specify INCLUDING CONTENTS AND DATAFILES.

Restrictions on Dropping Tablespaces

You cannot drop the SYSTEM tablespace.

You cannot drop a tablespace that contains a domain index or any objects created by a domain index.

You cannot drop an undo tablespace if it is being used by any instance or if it contains any undo data needed to roll back uncommitted transactions.

See Also: Oracle9i Data Cartridge Developer’s Guide and Oracle9i Database Concepts for more information on domain indexes

INCLUDING CONTENTS

Specify INCLUDING CONTENTS to drop all the contents of the tablespace. You must specify this clause to drop a tablespace that contains any database objects. If you omit this clause, and the tablespace is not empty, then Oracle returns an error and does not drop the tablespace.

For partitioned tables, DROP TABLESPACE will fail even if you specify INCLUDING CONTENTS, if the tablespace contains some, but not all:

Partitions of a rangeor hash-partitioned table, or

Subpartitions of a composite-partitioned table.

Note: If all the partitions of a partitioned table reside in tablespace, then DROP TABLESPACE ... INCLUDING CONTENTS will drop tablespace, as well as any associated index segments, LOB data segments, and LOB index segments in the other tablespace(s).

For a partitioned index-organized table, if all the primary key index segments are in this tablespace, then this clause will also drop any overflow segments that exist in other tablespaces, as well as any associated mapping table in other tablespaces. If some of the primary key index segments are not in this tablespace, then the statement will fail. In that case, before you can drop the tablespace, you must use

SQL Statements: DROP SEQUENCE to ROLLBACK 17-11

DROP TABLESPACE

ALTER TABLE ... MOVE PARTITION to move those primary key index segments into this tablespace, drop the partitions whose overflow data segments are not in this tablespace, and drop the partitioned index-organized table.

If the tablespace contains a master table of a materialized view, then Oracle invalidates the materialized view.

If the tablespace contains a materialized view log, then Oracle drops this log and any other direct-path INSERT refresh information associated with the table.

AND DATAFILES

When you specify INCLUDING CONTENTS, the AND DATAFILES clause lets you instruct Oracle to delete the associated operating system files as well. Oracle writes a message to the alert log for each operating system file deleted. This clause is not needed for Oracle-managed files.

CASCADE CONSTRAINTS

Specify CASCADE CONSTRAINTS to drop all referential integrity constraints from tables outside tablespace that refer to primary and unique keys of tables inside tablespace. If you omit this clause and such referential integrity constraints exist, then Oracle returns an error and does not drop the tablespace.

Example

Dropping a Tablespace: Example The following statement drops the tbs_01 tablespace and drops all referential integrity constraints that refer to primary and unique keys inside tbs_01:

DROP TABLESPACE tbs_01

INCLUDING CONTENTS

CASCADE CONSTRAINTS;

Deleting Operating System Files: Example The following example drops the tbs_02 tablespace and deletes all associated operating system datafiles:

DROP TABLESPACE tbs_02

INCLUDING CONTENTS AND DATAFILES;

17-12 Oracle9i SQL Reference

DROP TRIGGER

DROP TRIGGER

Purpose

Use the DROP TRIGGER statement to remove a database trigger from the database.

See Also:

CREATE TRIGGER on page 15-95 for information on creating triggers

ALTER TRIGGER on page 12-2 for information on enabling, disabling, and compiling triggers

Prerequisites

The trigger must be in your own schema or you must have the DROP ANY TRIGGER system privilege.

In addition, to drop a trigger on DATABASE in another user’s schema, you must have the ADMINISTER DATABASE TRIGGER system privilege.

See Also: CREATE TRIGGER on page 15-95 for information on these privileges

Syntax

drop_trigger::=

 

schema

.

 

DROP

TRIGGER

trigger

;

Semantics

schema

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

trigger

Specify the name of the trigger to be dropped. Oracle removes it from the database and does not fire it again.

SQL Statements: DROP SEQUENCE to ROLLBACK 17-13

DROP TRIGGER

Example

Dropping a Trigger: Example The following statement drops the order trigger in the schema oe:

DROP TRIGGER hr.salary_check;

17-14 Oracle9i SQL Reference

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