Oracle8i SQL Reference Release 8.1.5 A67779-01 |
|
To remove a database link from the database.
To drop a private database link, the database link must be in your own schema. To drop a PUBLIC database link, you must have the DROP PUBLIC DATABASE LINK system privilege.
For information on creating database links, see "CREATE DATABASE LINK".
The following statement drops a private database link named BOSTON:
DROP DATABASE LINK boston;
To remove the named dimension.
For information on materialized views and their use of dimensions, see Oracle8i Concepts. See also "CREATE DIMENSION".
The dimension must be in your own schema or you must have the DROP ANY DIMENSION system privilege to use this statement.
This example drops the TIME dimension:
DROP DIMENSION time;
Use DROP DIRECTORY to remove a directory object from the database.
For information on creating a directory, see "CREATE DIRECTORY".
To drop a directory you must have the DROP ANY DIRECTORY system privilege.
The following statement drops the directory object BFILE_DIR:
DROP DIRECTORY bfile_dir;
To remove a standalone stored function from the database. For information on creating a function, see "CREATE FUNCTION".
The function must be in your own schema or you must have the DROP ANY PROCEDURE system privilege.
schema |
is the schema containing the function. If you omit schema, Oracle assumes the function is in your own schema. |
function_name |
is the name of the function to be dropped. Oracle invalidates any local objects that depend on, or call, the dropped function. If you subsequently reference one of these objects, Oracle tries to recompile the object and returns an error if you have not re-created the dropped function. For more information on how Oracle maintains dependencies among schema objects, including remote objects, see . |
|
If any statistics types are associated with the function, Oracle disassociates the statistics types with the FORCE option and drops any user-defined statistics collected with the statistics type. For more information on statistics type associations, see "ASSOCIATE STATISTICS" and "DISASSOCIATE STATISTICS". |
The following statement drops the function NEW_ACCT in the schema RIDDLEY and invalidates all objects that depend upon NEW_ACCT:
DROP FUNCTION riddley.new_acct;
To remove an index or domain index from the database.
For more information on indexes, see "CREATE INDEX" and "ALTER INDEX". For more information on domain indexes, see the domain_index_clause of "CREATE INDEX".
The index must be in your own schema or you must have the DROP ANY INDEX system privilege.
schema |
is the schema containing the index. If you omit schema, Oracle assumes the index is in your own schema. |
|
index |
is the name of the index to be dropped. When the index is dropped, all data blocks allocated to the index are returned to the index's tablespace. If you drop a domain index:
|
|
|
If you drop a global partitioned index, a range-partitioned, or a hash-partitioned index, all the index partitions are also dropped. If you drop a a composite-partitioned index, all the index partitions and subpartitions are also dropped. |
|
FORCE |
applies only to domain indexes. This clause drops the domain index even if the indextype routine invocation returns an error or the index is marked LOADING. Without FORCE, you cannot drop a domain index if its indextype routine invocation returns an error or the index is marked LOADING. |
This statement drops an index named MONOLITH:
DROP INDEX monolith;
To drop an indextype, as well as any association with a statistics type.
For more information on indextypes, see "CREATE INDEXTYPE".
The indextype must be in your own schema or you must have the DROP ANY INDEXTYPE system privilege.
schema |
is the schema containing the indextype. If you omit schema, Oracle assumes the indextype is in your own schema. |
|
indextype |
is the name of the indextype to be dropped. If any statistics types have been associated with indextype, Oracle disassociates the statistics type from the indextype and drops any statistics that have been collected using the statistics type. For more information on statistics associations, see "ASSOCIATE STATISTICS" and "DISASSOCIATE STATISTICS". |
|
FORCE |
drops the indextype even if the indextype is currently being referenced by one or more domain indexes, and marks those domain indexes INVALID. Without FORCE, you cannot drop an indextype if any domain indexes reference the indextype. |
The following statement drops the indextype TEXTINDEXTYPE and marks INVALID any domain indexes defined on this indextype:
DROP INDEXTYPE textindextype FORCE;
To drop a Java source, class, or resource schema object.
For more information on resolving Java sources, classes, and resources, see Oracle8i Java Stored Procedures Developer's Guide.
The Java source, class, or resource must be in your own schema or you must have the DROP ANY PROCEDURE system privilege. You also must have the EXECUTE object privilege on Java classes to use this command.
The following statement drops the Java class MyClass
:
DROP JAVA CLASS "MyClass";
To remove an external procedure library from the database.
For information on creating a library, see "CREATE LIBRARY".
You must have the DROP LIBRARY system privilege.
library_name |
is the name of the external procedure library being dropped. |
The following statement drops the EXT_PROCS library:
DROP LIBRARY ext_procs;
To remove an existing materialized view from the database.
The terms "snapshot" and "materialized view" are synonymous. For more information on materialized views, including a description of the various types of materialized views, see "CREATE MATERIALIZED VIEW / SNAPSHOT". For information on materialized views in a replication environment, see Oracle8i Replication. For information on materialized views in a data warehousing environment, see Oracle8i Tuning.
The materialized view must be in your own schema or you must have the DROP ANY MATERIALIZED VIEW (or DROP ANY SNAPSHOT) system privilege. You must also have the privileges to drop the internal table, views, and index that Oracle uses to maintain the materialized view's data.
For information on these privileges, see "DROP TABLE", "DROP VIEW", and "DROP INDEX".
The following statement drops the materialized view PARTS owned by the user HQ:
DROP SNAPSHOT hq.parts;
The following statement drops the SALES_BY_MONTH materialized view and the underlying table of the materialized view (unless the underlying table was registered in the CREATE MATERIALIZED VIEW statement with the ON PREBUILT TABLE clause):
DROP MATERIALIZED VIEW sales_by_month;
To remove a materialized view log from the database.
The terms "snapshot" and "materialized view" are synonymous. For more information on materialized views, including a description of the various types of materialized views and refreshing materialized views, see "CREATE MATERIALIZED VIEW / SNAPSHOT" and "ALTER MATERIALIZED VIEW / SNAPSHOT".
For information on materialized view logs, see "CREATE MATERIALIZED VIEW LOG / SNAPSHOT LOG".
For information on materialized views in a replication environment, see Oracle8i Replication. For information on materialized views in a data warehousing environment, see Oracle8i Tuning.
A materialized view log consists of a table and a trigger. To drop a materialized view log, you must have the privileges listed for "DROP TABLE".
The following statement drops the materialized view log on the PARTS master table:
DROP MATERIALIZED VIEW LOG ON parts;
To drop a user-defined operator.
For more information on operators, see "User-Defined Operators", Oracle8i Data Cartridge Developer's Guide and "CREATE OPERATOR".
The operator must be in your schema or you must have the DROP ANY OPERATOR system privilege.
The following statement drops the operator MERGE:
DROP OPERATOR ordsys.merge;
Because the FORCE clause is not specified, this operation will fail if any of the bindings of this operator are referenced by an indextype.
To drop a stored outline.
For more information on outlines, see "CREATE OUTLINE" and Oracle8i Tuning.
To drop an outline, you must have the DROP ANY OUTLINE system privilege.
The following statement drops the stored outline called SALARIES.
DROP OUTLINE salaries;
To remove a stored package from the database. This statement drops the body and specification of a package.
Note: Do not use this statement to remove a single object from a package. Instead, re-create the package without the object using the CREATE PACKAGE and CREATE PACKAGE BODY statements with the OR REPLACE clause. See "CREATE PACKAGE". |
The package must be in your own schema or you must have the DROP ANY PROCEDURE system privilege.
BODY |
drops only the body of the package. If you omit this clause, Oracle drops both the body and specification of the package. When you drop only the body of a package but not its specification, Oracle does not invalidate dependent objects. However, you cannot call one of the procedures or stored functions declared in the package specification until you re-create the package body. |
schema |
is the schema containing the package. If you omit schema, Oracle assumes the package is in your own schema. |
package |
is the name of the package to be dropped. Oracle invalidates any local objects that depend on the package specification. If you subsequently reference one of these objects, Oracle tries to recompile the object and returns an error if you have not re-created the dropped package. For information on how Oracle maintains dependencies among schema objects, including remote objects, see . If any statistics types are associated with the package, Oracle disassociates the statistics types with the FORCE clause and drops any user-defined statistics collected with the statistics types. For more information, see "ASSOCIATE STATISTICS" and "DISASSOCIATE STATISTICS". |
The following statement drops the specification and body of the BANKING package, invalidating all objects that depend on the specification:
DROP PACKAGE banking;
To remove a standalone stored procedure from the database. Do not use this statement to remove a procedure that is part of a package. Instead, either drop the entire package using the DROP PACKAGE statement, or redefine the package without the procedure using the CREATE PACKAGE statement with the OR REPLACE clause.
For information on creating a procedure, see "CREATE PROCEDURE".
The procedure must be in your own schema or you must have the DROP ANY PROCEDURE system privilege.
The following statement drops the procedure TRANSFER owned by the user KERNER and invalidates all objects that depend upon TRANSFER:
DROP PROCEDURE kerner.transfer
To remove a profile from the database.
For information on creating a profile, see "CREATE PROFILE".
You must have the DROP PROFILE system privilege.
The following statement drops the profile ENGINEER:
DROP PROFILE engineer CASCADE;
Oracle drops the profile ENGINEER and assigns the DEFAULT profile to any users currently assigned the ENGINEER profile.
To remove a role from the database. When you drop a role, Oracle revokes it from all users and roles to whom it has been granted and removes it from the database.
For information on creating roles, see "CREATE ROLE". For information on disabling roles for the current session, see "SET ROLE".
You must have been granted the role with the ADMIN OPTION or you must have the DROP ANY ROLE system privilege.
role |
is the role to be dropped. |
To drop the role FLORIST, issue the following statement:
DROP ROLE florist;
To remove a rollback segment from the database. When you drop a rollback segment, all space allocated to the rollback segment returns to the tablespace.
For information on creating a rollback segment, see CREATE ROLLBACK SEGMENT. See also "CREATE TABLESPACE".
You must have the DROP ROLLBACK SEGMENT system privilege.
rollback_segment |
is the name the rollback segment to be dropped. Restrictions:
|
The following statement drops the rollback segment ACCOUNTING:
DROP ROLLBACK SEGMENT accounting;
To remove a sequence from the database.
You can also use this statement to restart a sequence by dropping and then re-creating it. For example, if you have a sequence with a current value of 150 and you would like to restart the sequence with a value of 27, you can drop the sequence and then re-create it with the same name and a START WITH value of 27.
For more information on creating and modifying sequences, see "CREATE SEQUENCE" and "ALTER SEQUENCE".
The sequence must be in your own schema or you must have the DROP ANY SEQUENCE system privilege.
schema |
is the schema containing the sequence. If you omit schema, Oracle assumes the sequence is in your own schema. |
sequence_name |
is the name of the sequence to be dropped. |
The following statement drops the sequence ESEQ owned by the user ELLY. To issue this statement, you must either be connected as user ELLY or have DROP ANY SEQUENCE system privilege:
DROP SEQUENCE elly.eseq;
In Oracle8i, "snapshots" are synonymous with "materialized views." Please see "DROP MATERIALIZED VIEW / SNAPSHOT".
In Oracle8i, "snapshots" are synonymous with "materialized views." Please see "DROP MATERIALIZED VIEW LOG / SNAPSHOT LOG".
To remove a synonym from the database, or to change the definition of a synonym by dropping and re-creating it.
For more information on synonyms, see "CREATE SYNONYM".
To drop a private synonym, either the synonym must be in your own schema or you must have the DROP ANY SYNONYM system privilege.
To drop a PUBLIC synonym, either the synonym must be in your own schema or you must have the DROP ANY PUBLIC SYNONYM system privilege.
To drop a synonym named MARKET, issue the following statement:
DROP SYNONYM market;
To remove a table or an object table and all its data from the database.
For information on creating tables, see "CREATE TABLE". For information on modifying tables, see "ALTER TABLE".
The table must be in your own schema or you must have the DROP ANY TABLE system privilege.
schema |
is the schema containing the table. If you omit schema, Oracle assumes the table is in your own schema. |
table |
is the name of the table, object table, or index-organized table to be dropped. Oracle automatically performs the following operations: |
|
|
|
|
|
|
|
|
|
|
|
Note: To drop a cluster and all its the tables, use the DROP CLUSTER statement with the INCLUDING TABLES clause to avoid dropping each table individually. See "DROP CLUSTER". |
CASCADE CONSTRAINTS |
drops all referential integrity constraints that refer to primary and unique keys in the dropped table. If you omit this clause, and such referential integrity constraints exist, Oracle returns an error and does not drop the table. |
The following statement drops the TEST_DATA table:
DROP TABLE test_data;
To remove a tablespace from the database.
For information on creating and modifying tablespaces, see "CREATE TABLESPACE" and "ALTER TABLESPACE".
You must have the DROP TABLESPACE system privilege. You cannot drop a tablespace if it contains any rollback segments holding active transactions.
The following statement drops the MFRG tablespace and all its contents:
DROP TABLESPACE mfrg INCLUDING CONTENTS CASCADE CONSTRAINTS;
To remove a database trigger from the database.
For information on creating triggers, see "CREATE TRIGGER".
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. For more information on database triggers, see "CREATE TRIGGER".
The following statement drops the REORDER trigger in the schema RUTH:
DROP TRIGGER ruth.reorder;
To drop the specification and body of an object, a varray, or nested table type. To drop just the body of an object type, see "DROP TYPE BODY".
For more information on types, see "CREATE TYPE".
The object, varray, or nested table type must be in your own schema or you must have the DROP ANY TYPE system privilege.
schema |
is the schema containing the type. If you omit schema, Oracle assumes the type is in your own schema. |
type_name |
is the name of the object, varray, or nested table type to be dropped. You can drop only types with no type or table dependencies. If type_name is a statistics type, this statement will fail unless you also specify FORCE. If you specify FORCE, Oracle first disassociates all objects that are associated with type_name, and then drops type_name. For more information on statistics types, see "ASSOCIATE STATISTICS" and "DISASSOCIATE STATISTICS". |
|
If type_name is an object type that has been associated with a statistics type, Oracle first attempts to disassociate type_name from the statistics type and then drop type_name. However, if statistics have been collected using the statistics type, Oracle will be unable to disassociate type_name from the statistics type, and this statement will fail. |
|
If type_name is an implementation type for an indextype, the indextype will be marked INVALID. For more information, see "CREATE INDEXTYPE". Unless you specify FORCE, you can drop only object, nested table, or varray types that are standalone schema objects with no dependencies. This is the default behavior. |
FORCE |
forces the type to be dropped even if it has dependent database objects. Oracle marks UNUSED all columns dependent on the type to be dropped, and those columns become inaccessible. |
|
WARNING: Oracle does not recommend that you specify FORCE to drop types with dependencies. This operation is not recoverable and could cause the data in the dependent tables or columns to become inaccessible. For information about type dependencies, see . |
The following statement removes object type PERSON_T:
DROP TYPE person_t;
To drop the body of an object, varray, or nested table type. When you drop a type body, the object type specification still exists, and you can re-create the type body. Prior to re-creating the body, you can still use the object type, although you cannot call the member functions.
To drop the specification of an object, see "DROP TYPE". For more information on type bodies, see "CREATE TYPE BODY".
The object type body must be in your own schema, and you must have
The following statement removes object type body RATIONAL:
DROP TYPE BODY rational;
To remove a database user and optionally remove the user's objects. For information on creating a user, see "CREATE USER". For information on modifying the definition of a user, see "ALTER USER".
You must have the DROP USER system privilege.
If user BRADLEY's schema contains no objects, you can drop BRADLEY by issuing the statement:
DROP USER bradley;
If BRADLEY's schema contains objects, you must use the CASCADE clause to drop BRADLEY and the objects:
DROP USER bradley CASCADE;
To remove a view or an object view from the database. You can change the definition of a view by dropping and re-creating it. For more information, see "CREATE VIEW".
The view must be in your own schema or you must have the DROP ANY VIEW system privilege.
schema |
is the schema containing the view. If you omit schema, Oracle assumes the view is in your own schema. |
view |
is the name of the view to be dropped. Views, materialized views, and synonyms that refer to the view are not dropped, but become invalid. You can drop them or redefine views and synonyms, or you can define other views in such a way that the invalid views and synonyms become valid again. See "CREATE TABLE" and "CREATE SYNONYM". To revalidate invalid materialized views, see "ALTER MATERIALIZED VIEW / SNAPSHOT". |
The following statement drops the VIEW_DATA view:
DROP VIEW view_data;
To determine the execution plan Oracle follows to execute a specified SQL statement. This statement inserts a row describing each step of the execution plan into a specified table. If you are using cost-based optimization, this statement also determines the cost of executing the statement. If any domain indexes are defined on the table, user-defined CPU and I/O costs will also be inserted. See Oracle8i Tuning for information on the output of EXPLAIN PLAN.
The definition of a sample output table PLAN_TABLE is available in a SQL script on your distribution media. Your output table must have the same column names and datatypes as this table. The common name of this script is UTLXPLAN.SQL. The exact name and location depend on your operating system.
You can also issue the EXPLAIN PLAN statement as part of the SQL trace facility. For information on how to use the SQL trace facility, as well as a detailed discussion of how to generate and interpret execution plans, see Oracle8i Tuning.
To issue an EXPLAIN PLAN statement, you must have the privileges necessary to insert rows into an existing output table that you specify to hold the execution plan. For information on these privileges, see "INSERT".
You must also have the privileges necessary to execute the SQL statement for which you are determining the execution plan. If the SQL statement accesses a view, you must have privileges to access any tables and views on which the view is based. If the view is based on another view that is based on a table, you must have privileges to access both the other view and its underlying table.
To examine the execution plan produced by an EXPLAIN PLAN statement, you must have the privileges necessary to query the output table. For more information on these privileges, see "SELECT and Subqueries".
The EXPLAIN PLAN statement is a data manipulation language (DML) statement, rather than a data definition language (DDL) statement. Therefore, Oracle does not implicitly commit the changes made by an EXPLAIN PLAN statement. If you want to keep the rows generated by an EXPLAIN PLAN statement in the output table, you must commit the transaction containing the statement.
SET STATEMENT_ID |
specifies the value of the STATEMENT_ID column for the rows of the execution plan in the output table. You can then use this value to identify these rows among others in the output table. Be sure to specify a STATEMENT_ID value if your output table contains rows from many execution plans. If you omit this clause, the STATEMENT_ID value defaults to null. |
INTO |
specifies name of the output table, and optionally its schema and database. This table must exist before you use the EXPLAIN PLAN statement. If you omit schema, Oracle assumes the table is in your own schema. |
|
The dblink can be a complete or partial name of a database link to a remote Oracle database where the output table is located. For information on referring to database links, see the section, "Referring to Objects in Remote Databases". You can specify a remote output table only if you are using Oracle's distributed functionality. If you omit dblink, Oracle assumes the table is on your local database. |
|
If you omit INTO altogether, Oracle assumes an output table named PLAN_TABLE in your own schema on your local database. |
FOR statement |
specifies a SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, or CREATE INDEX statement for which the execution plan is generated. |
|
Note: If statement includes the parallel_clause, the resulting execution plan will indicate parallel execution. However, EXPLAIN PLAN actually inserts the statement into the plan table, so that the parallel DML statement you submit is no longer the first DML statement in the transaction. This violates the Oracle restriction of one parallel DML statement per transaction, and the statement will be executed serially. To maintain parallel execution of the statements, you must commit or roll back the EXPLAIN PLAN statement, and then submit the parallel DML statement. |
The following statement determines the execution plan and cost for an UPDATE statement and inserts rows describing the execution plan into the specified OUTPUT table with the STATEMENT_ID value of 'Raise in Chicago':
EXPLAIN PLAN SET STATEMENT_ID = 'Raise in Chicago' INTO output FOR UPDATE emp SET sal = sal * 1.10 WHERE deptno = (SELECT deptno FROM dept WHERE loc = 'CHICAGO');
The following SELECT statement queries the OUTPUT table and returns the execution plan and the cost:
SELECT LPAD(' ',2*(LEVEL-1))||operation operation, options, object_name, position FROM output START WITH id = 0 AND statement_id = 'Raise in Chicago' CONNECT BY PRIOR id = parent_id AND statement_id = 'Raise in Chicago';
The query returns this execution plan:
OPERATION OPTIONS OBJECT_NAME POSITION ---------------------------------------------------------- UPDATE STATEMENT 1 FILTER 0 TABLE ACCESS FULL EMP 1 TABLE ACCESS FULL DEPT 2
The value in the POSITION column of the first row shows that the statement has a cost of 1.
Assume that STOCKS is a table with eight partitions on a STOCK_NUM column, and that a local prefixed index STOCK_IX on column STOCK_NUM exists. The partition HIGHVALUES are 1000, 2000, 3000, 4000, 5000, 6000, 7000, and 8000.
Consider the query:
SELECT * FROM stocks WHERE stock_num BETWEEN 3800 AND :h;
(where :h represents a bind variable). EXPLAIN PLAN executes this query with PLAN_TABLE as the output table. The basic execution plan, including partitioning information, is obtained with the query:
SELECT id, operation, options, object_name, partition_start, partition_stop, partition_id FROM plan_table;