SQL Reference

DROP

The DROP statement deletes an object. Any objects that are directly or indirectly dependent on that object are either deleted or made inoperative. (See Inoperative Trigger and Inoperative views for details.) Whenever an object is deleted, its description is deleted from the catalog and any packages that reference the object are invalidated.

Invocation

This statement can be embedded in an application program or issued through the use of dynamic SQL statements. It is an executable statement that can be dynamically prepared. However, if the bind option DYNAMICRULES BIND applies, the statement cannot be dynamically prepared (SQLSTATE 42509).

Authorization

The privileges that must be held by the authorization ID of the DROP statement when dropping objects that allow two-part names must include one of the following or an error will result (SQLSTATE 42501):

The authorization ID of the DROP statement when dropping a table or view hierarchy must hold one of the above privileges for each of the tables or views in the hierarchy.

The authorization ID of the DROP statement when dropping a schema must have SYSADM or DBADM authority or be the schema owner as recorded in the OWNER column of SYSCAT.SCHEMATA.

The authorization ID of the DROP statement when dropping a buffer pool, nodegroup, or table space must have SYSADM or SYSCTRL authority.

The authorization ID of the DROP statement when dropping an event monitor, server definition, data type mapping, function mapping or a wrapper must have SYSADM or DBADM authority.

The authorization ID of the DROP statement when dropping a user mapping must have SYSADM or DBADM authority, if this authorization ID is different from the federated database authorization name within the mapping. Otherwise, if the authorization ID and the authorization name match, no authorities or privileges are required.

The authorization ID of the DROP statement when dropping a transform must hold SYSADM or DBADM authority, or must be the DEFINER of type-name.

Syntax

>>-DROP--------------------------------------------------------->
 
              (1)
>-----+-ALIAS-------alias-name--------------------------------------------------+>
      +-BUFFERPOOL--bufferpool-name---------------------------------------------+
      +-EVENT--MONITOR--event-monitor-name--------------------------------------+
      +-FUNCTION----function-name--+-------------------------------+------------+
      |                            '-(--+-------------------+---)--'            |
      |                                 |  .-,-----------.  |                   |
      |                                 |  V             |  |                   |
      |                                 '----data-type---+--'                   |
      +-SPECIFIC FUNCTION--specific-name----------------------------------------+
      +-FUNCTION MAPPING--function-mapping-name---------------------------------+
      |                   (2)                                                   |
      +-INDEX--index-name-------------------------------------------------------+
      +-INDEX EXTENSION--index-extension-name--RESTRICT-------------------------+
      +-METHOD--method-name--+------------------------------+---FOR--type-name--+
      |                      '-(--+------------------+---)--'                   |
      |                           |  .-,----------.  |                          |
      |                           |  V            |  |                          |
      |                           '----datatype---+--'                          |
      +-SPECIFIC METHOD--specific-name------------------------------------------+
      +-NICKNAME--nickname------------------------------------------------------+
      +-NODEGROUP--nodegroup-name-----------------------------------------------+
      |         (3)                                                             |
      +-PACKAGE-------package-name----------------------------------------------+
      +-PROCEDURE--procedure-name--+-------------------------------+------------+
      |                            '-(--+-------------------+---)--'            |
      |                                 |  .-,-----------.  |                   |
      |                                 |  V             |  |                   |
      |                                 '----data-type---+--'                   |
      +-SPECIFIC PROCEDURE--specific-name---------------------------------------+
      +-SCHEMA--schema-name--RESTRICT-------------------------------------------+
      +-SERVER--server-name-----------------------------------------------------+
      +-TABLE--table-name-------------------------------------------------------+
      +-TABLE HIERARCHY--root-table-name----------------------------------------+
      |                    .-,------------------.                               |
      |                    V                    |                               |
      +--+-TABLESPACE--+------tablespace-name---+-------------------------------+
      |  '-TABLESPACES-'                                                        |
      +--+-TRANSFORM--+---+-ALL--------+---FOR--type-name-----------------------+
      |  '-TRANSFORMS-'   '-group-name-'                                        |
      +-TRIGGER--trigger-name---------------------------------------------------+
      +-+----------------+---TYPE--type-name------------------------------------+
      | |          (4)   |                                                      |
      | '-DISTINCT-------'                                                      |
      +-TYPE MAPPING--type-mapping-name-----------------------------------------+
      +-USER MAPPING FOR--+-authorization-name-+---SERVER--server-name----------+
      |                   '-USER---------------'                                |
      +-VIEW--view-name---------------------------------------------------------+
      +-VIEW HIERARCHY--root-view-name------------------------------------------+
      '-WRAPPER--wrapper-name---------------------------------------------------'
 
>--------------------------------------------------------------><
 

Notes:

  1. SYNONYM can be used as a synonym for ALIAS.

  2. Index-name can be the name of either an index or an index specification.

  3. PROGRAM can be used as a synonym for PACKAGE.

  4. DATA can also be used when dropping any user-defined type.

Description

ALIAS alias-name
Identifies the alias that is to be dropped. The alias-name must identify an alias that is described in the catalog (SQLSTATE 42704). The specified alias is deleted.

All tables, views and triggers 93 that reference the alias are made inoperative.

BUFFERPOOL bufferpool-name
Identifies the buffer pool that is to be dropped. The bufferpool-name must identify a buffer pool that is described in the catalog (SQLSTATE 42704). There can be no table spaces assigned to the buffer pool (SQLSTATE 42893). The IBMDEFAULTBP buffer pool cannot be dropped (SQLSTATE 42832). The storage for the buffer pool will not be released until the database is stopped.

EVENT MONITOR event-monitor-name
Identifies the event monitor that is to be dropped. The event-monitor-name must identify an event monitor that is described in the catalog (SQLSTATE 42704).

If the identified event monitor is ON, an error (SQLSTATE 55034) is raised. Otherwise, the event monitor is deleted.

If there are event files in the target path of the event monitor when the event monitor is dropped, the event files are not deleted. However, if a new event monitor is created which specifies the same target path, then the event files are deleted.

FUNCTION
Identifies an instance of a user-defined function (either a complete function or a function template) that is to be dropped. The function instance specified must be a user-defined function described in the catalog. Functions implicitly generated by the CREATE DISTINCT TYPE statement cannot be dropped.

There are several different ways available to identify the function instance:

FUNCTION function-name
Identifies the particular function, and is valid only if there is exactly one function instance with the function-name. The function thus identified may have any number of parameters defined for it. In dynamic SQL statements, the CURRENT SCHEMA special register is used as a qualifier for an unqualified object name. In static SQL statements the QUALIFIER precompile/bind option implicitly specifies the qualifier for unqualified object names. If no function by this name exists in the named or implied schema, an error (SQLSTATE 42704) is raised. If there is more than one specific instance of the function in the named or implied schema, an error (SQLSTATE 42854) is raised.

FUNCTION function-name (data-type,...)
Provides the function signature, which uniquely identifies the function to be dropped. The function selection algorithm is not used.

function-name
Gives the function name of the function to be dropped. In dynamic SQL statements, the CURRENT SCHEMA special register is used as a qualifier for an unqualified object name. In static SQL statements the QUALIFIER precompile/bind option implicitly specifies the qualifier for unqualified object names.

(data-type,...)
Must match the data types that were specified on the CREATE FUNCTION statement in the corresponding position. The number of data types, and the logical concatenation of the data types is used to identify the specific function instance which is to be dropped.

If the data-type is unqualified, the type name is resolved by searching the schemas on the SQL path. This also applies to data type names specified for a REFERENCE type.

It is not necessary to specify the length, precision or scale for the parameterized data types. Instead, an empty set of parentheses may be coded to indicate that these attributes are to be ignored when looking for a data type match.

FLOAT() cannot be used (SQLSTATE 42601) since the parameter value indicates different data types (REAL or DOUBLE).

However, if length, precision, or scale is coded, the value must exactly match that specified in the CREATE PROCEDURE statement.

A type of FLOAT(n) does not need to match the defined value for n since 0<n<25 means REAL and 24<n<54 means DOUBLE. Matching occurs based on whether the type is REAL or DOUBLE.

If no function with the specified signature exists in named or implied schema, an error (SQLSTATE 42883) is raised.

SPECIFIC FUNCTION specific-name
Identifies the particular user-defined function that is to be dropped, using the specific name either specified or defaulted to at function creation time. In dynamic SQL statements, the CURRENT SCHEMA special register is used as a qualifier for an unqualified object name. In static SQL statements the QUALIFIER precompile/bind option implicitly specifies the qualifier for unqualified object names. The specific-name must identify a specific function instance in the named or implied schema; otherwise, an error (SQLSTATE 42704) is raised.

It is not possible to drop a function that is in either the SYSIBM schema or the SYSFUN schema (SQLSTATE 42832).

Other objects can be dependent upon a function. All such dependencies must be removed before the function can be dropped, with the exception of packages which are marked inoperative. An attempt to drop a function with such dependencies will result in an error (SQLSTATE 42893). See page *** for a list of these dependencies.

If the function can be dropped, it is dropped.

Any package dependent on the specific function being dropped is marked as inoperative. Such a package is not implicitly rebound. It must either be rebound by use of the BIND or REBIND command or it must be reprepared by use of the PREP command. See the Command Reference for information on these commands.

FUNCTION MAPPING function-mapping-name
Identifies the function mapping to be dropped. The function-mapping-name must identify a user-defined function mapping that is described in the catalog (SQLSTATE 42704). The function mapping is deleted from the database.

Default function mappings cannot be dropped. However, they can be disabled. For an example, see Example 3 in CREATE FUNCTION MAPPING.

Packages having a dependency on a dropped function mapping are invalidated.

INDEX index-name
Identifies the index or index specification that is to be dropped. The index-name must identify an index or index specification that is described in the catalog (SQLSTATE 42704). It cannot be an index required by the system for a primary key or unique constraint or for a replicated summary table (SQLSTATE 42917). The specified index or index specification is deleted.

Packages having a dependency on a dropped index or index specification are invalidated.

INDEX EXTENSION index-extension-name RESTRICT
Identifies the index extension that is to be dropped. The index-extension-name must identify an index extension that is described in the catalog (SQLSTATE 42704). The RESTRICT keyword enforces the rule that no index can be defined that depends on this index extension definition (SQLSTATE 42893).

METHOD
Identifies a method body that is to be dropped. The method body specified must be a method described in the catalog (SQLSTATE 42704). Method bodies that are implicitly generated by the CREATE TYPE statement cannot be dropped.

DROP METHOD deletes the body of a method, but the method specification (signature) remains as a part of the definition of the subject type. After dropping the body of a method, the method specification can be removed from the subject type definition by ALTER TYPE DROP METHOD.

There are several ways available to identify the method body to be dropped:

METHOD method-name
Identifies the particular method dropped, and is valid only if there is exactly one method instance with name method-name and subject type type-name. Thus, the method identified may have any number of parameters. If no method by this name exists for the type type-name, an error is raised (SQLSTATE 42704). If there is more than one specific instance of the method for the named data type, an error is raised (SQLSTATE 42854).

METHOD method-name (data-type ,...)
Provides the method signature, which uniquely identifies the method to be dropped. The method selection algorithm is not used.

method-name
The method name of the method to be dropped for the specified type. The name must be an unqualified identifier.

(data-type, ...)
Must match the data types that were specified in the corresponding positions of the method-specification of the CREATE TYPE or ALTER TYPE statement. The number of data types and the logical concatenation of the data types are used to identify the specific method instance which is to be dropped.

If the data-type is unqualified, the type name is resolved by searching the schemas on the SQL path.

It is not necessary to specify the length, precision or scale for the parameterized data types. Instead, an empty set of parentheses may be coded to indicate that these attributes are to be ignored when looking for a data type match.

FLOAT() cannot be used (SQLSTATE 42601) since the parameter value indicates different data types (REAL or DOUBLE).

However, if length, precision, or scale is coded, the value must exactly match that specified in the CREATE TYPE statement.

A type of FLOAT(n) does not need to match the defined value for n since 0<n<25 means REAL and 24<n<54 means DOUBLE. Matching occurs based on whether the type is REAL or DOUBLE.

If no method with the specified signature exists for the named data type, an error is raised (SQLSTATE 42883).

FOR type-name
Names the type for which the specified method is to be dropped. The name must identify a type already described in the catalog (SQLSTATE 42704). In dynamic SQL statements, the CURRENT SCHEMA special register is used as a qualifier for an unqualified type name. In static SQL statements, the QUALIFIER precompile/bind option implicitly specifies the qualifier for unqualified type names.

SPECIFIC METHOD specific-name
Identifies the particular method that is to be dropped, using a name either specified or defaulted to at CREATE TYPE or ALTER TYPE time. If the specific name is unqualified, the CURRENT SCHEMA special register is used as a qualifier for an unqualified specific name in dynamic SQL. In static SQL statements the QUALIFIER precompile/bind option implicitly specifies the qualifier for an unqualified specific name. The specific-name must identify a method; otherwise, an error is raised (SQLSTATE 42704).

Other objects can be dependent upon a method. All such dependencies must be removed before the method can be dropped, with the exception of packages which will be marked inoperative if the drop is successful. An attempt to drop a method with such dependencies will result in an error (SQLSTATE 42893).

If the method can be dropped, it will be dropped.

Any package dependent on the specific method being dropped is marked as inoperative. Such a package is not implicitly re-bound. Either it must be re-bound by use of the BIND or REBIND command, or it must be re-prepared by use of the PREP command. See Command Reference for information on these commands.

NICKNAME nickname
Identifies the nickname to be dropped. The nickname must be listed in the catalog (SQLSTATE 42704). The nickname is deleted from the database.

All information about the columns and indexes associated with the nickname is deleted from the catalog. Any index specifications that are dependent on the nickname are dropped. Any views dependent on the nickname are marked inoperative. Any packages depending on the dropped index specifications or inoperative views are invalidated. The data source table that the nickname references is not affected.

NODEGROUP nodegroup-name
Identifies the nodegroup that is to be dropped. nodegroup-name must identify a nodegroup that is described in the catalog (SQLSTATE 42704). This is a one-part name.

Dropping a nodegroup drops all table spaces defined in the nodegroup. All existing database objects with dependencies on the tables in the table spaces (such as packages, referential constraints, etc.) are dropped or invalidated (as appropriate), and dependent views and triggers are made inoperative.

System defined nodegroups cannot be dropped (SQLSTATE 42832).

If a DROP NODEGROUP is issued against a nodegroup that is currently undergoing a data redistribution, the DROP NODEGROUP operation fails an error is returned (SQLSTATE 55038). However, a partially redistributed nodegroup can be dropped. A nodegroup can become partially redistributed if a REDISTRIBUTE NODEGROUP command does not execute to completion. This can happen if it gets interrupted by either an error or a force application all command. 94

PACKAGE package-name
Identifies the package that is to be dropped. The package-name must identify a package that is described in the catalog (SQLSTATE 42704). The specified package is deleted. All privileges on the package are also deleted.

PROCEDURE
Identifies an instance of a stored procedure that is to be dropped. The procedure instance specified must be a stored procedure described in the catalog.

There are several different ways available to identify the procedure instance:

PROCEDURE procedure-name
Identifies the particular procedure, and is valid only if there is exactly one procedure instance with the procedure-name in the schema. The procedure thus identified may have any number of parameters defined for it. If no procedure by this name exists in the named or implied schema, an error (SQLSTATE 42704) is raised. In dynamic SQL statements, the CURRENT SCHEMA special register is used as a qualifier for an unqualified object name. In static SQL statements the QUALIFIER precompile/bind option implicitly specifies the qualifier for unqualified object names. If there is more than one specific instance of the procedure in the named or implied schema, an error (SQLSTATE 42854) is raised.

PROCEDURE procedure-name (data-type,...)
Provides the procedure signature, which uniquely identifies the procedure to be dropped. The procedure selection algorithm is not used.

procedure-name
Gives the procedure name of the procedure to be dropped. In dynamic SQL statements, the CURRENT SCHEMA special register is used as a qualifier for an unqualified object name. In static SQL statements the QUALIFIER precompile/bind option implicitly specifies the qualifier for unqualified object names.

(data-type,...)
Must match the data types that were specified on the CREATE PROCEDURE statement in the corresponding position. The number of data types, and the logical concatenation of the data types is used to identify the specific procedure instance which is to be dropped.

If the data-type is unqualified, the type name is resolved by searching the schemas on the SQL path. This also applies to data type names specified for a REFERENCE type.

It is not necessary to specify the length, precision or scale for the parameterized data types. Instead, an empty set of parentheses may be coded to indicate that these attributes are to be ignored when looking for a data type match.

FLOAT() cannot be used (SQLSTATE 42601) since the parameter value indicates different data types (REAL or DOUBLE).

However, if length, precision, or scale is coded, the value must exactly match that specified in the CREATE FUNCTION statement.

A type of FLOAT(n) does not need to match the defined value for n since 0<n<25 means REAL and 24<n<54 means DOUBLE. Matching occurs based on whether the type is REAL or DOUBLE.

If no procedure with the specified signature exists in named or implied schema, an error (SQLSTATE 42883) is raised.

SPECIFIC PROCEDURE specific-name
Identifies the particular stored procedure that is to be dropped, using the specific name either specified or defaulted to at procedure creation time. In dynamic SQL statements, the CURRENT SCHEMA special register is used as a qualifier for an unqualified object name. In static SQL statements the QUALIFIER precompile/bind option implicitly specifies the qualifier for unqualified object names. The specific-name must identify a specific procedure instance in the named or implied schema; otherwise, an error (SQLSTATE 42704) is raised.

SCHEMA schema-name RESTRICT
Identifies the schema that is to be dropped. The schema-name must identify a schema that is described in the catalog (SQLSTATE 42704). The RESTRICT keyword enforces the rule that no objects can be defined in the specified schema for the schema to be deleted from the database (SQLSTATE 42893).

SERVER server-name
Identifies the data source whose definition is to be dropped from the catalog. The server-name must identify a data source that is described in the catalog (SQLSTATE 42704). The definition of the data source is deleted.

All nicknames for tables and views residing at the data source are dropped. Any index specifications dependent on these nicknames are dropped. Any user-defined function mappings, user-defined type mappings, and user mappings that are dependent on the dropped server definition are also dropped. All packages dependent on the dropped server definition, function mappings, nicknames, and index specifications are invalidated.

TABLE table-name
Identifies the base table, declared temporary table, or summary table that is to be dropped. The table-name must identify a table that is described in the catalog or, if it is a declared temporary table, then the table-name must be qualified by the schema name SESSION and exist in the application (SQLSTATE 42704). The subtables of a typed table are dependent on their supertables. All subtables must be dropped before a supertable can be dropped (SQLSTATE 42893). The specified table is deleted from the database.

All indexes, primary keys, foreign keys, check constraints, and summary tables referencing the table are dropped. All views and triggers 95 that reference the table are made inoperative. All packages depending on any object dropped or marked inoperative will be invalidated. This includes packages dependent on any supertables above the subtable in the hierarchy. Any reference columns for which the dropped table is defined as the scope of the reference become unscoped.

Packages are not dependent on declared temporary tables, and therefore are not invalidated when such a table is dropped.

All files that are linked through any DATALINK columns are unlinked. The unlink operation is performed asynchronously so the files may not be immediately available for other operations.

When a subtable is dropped from a table hierarchy, the columns associated with the subtable are no longer accessible although they continue to be considered with respect to limits on the number of columns and size of the row. Dropping a subtable has the effect of deleting all the rows of the subtable from the supertables. This may result in activation of triggers or referential integrity constraints defined on the supertables.

When a declared temporary table is dropped, and its creation preceded the active unit of work or savepoint, then the table will be functionally dropped and the application will not be able to access the table. However, the table will still reserve some space in its table space and will prevent that USER TEMPORARY table space from being dropped or the nodegroup of the USER TEMPORARY table space from being redistributed until the unit of work is committed or savepoint is ended. Dropping a declared temporary table causes the data in the table to be destroyed, regardless of whether DROP is committed or rolled back.

TABLE HIERARCHY root-table-name
Identifies the typed table hierarchy that is to be dropped. The root-table-name must identify a typed table that is the root table in the typed table hierarchy (SQLSTATE 428DR). The typed table identified by root-table-name and all of its subtables are deleted from the database.

All indexes, summary tables, primary keys, foreign keys, and check constraints referencing the dropped tables are dropped. All views and triggers that reference the dropped tables are made inoperative. All packages depending on any object dropped or marked inoperative will be invalidated. Any reference columns for which one of the dropped tables is defined as the scope of the reference become unscoped.

All files that are linked through any DATALINK columns are unlinked. The unlink operation is performed asynchronously so the files may not be immediately available for other operations.

Unlike dropping a single subtable, dropping the table hierarchy does not result in the activation of delete triggers of any tables in the hierarchy nor does it log the deleted rows.

TABLESPACE  or  TABLESPACES tablespace-name
Identifies the table spaces that are to be dropped. tablespace-name must identify a table space that is described in the catalog (SQLSTATE 42704). This is a one-part name.

The table spaces will not be dropped (SQLSTATE 55024) if there is any table that stores at least one of its parts in a table space being dropped and has one or more of its parts in another table space that is not being dropped (these tables would need to be dropped first). System table spaces cannot be dropped (SQLSTATE 42832). A SYSTEM TEMPORARY table space cannot be dropped (SQLSTATE 55026) if it is the only temporary table space that exists in the database. A USER TEMPORARY table space cannot be dropped if there is a declared temporary table created in it (SQLSTATE 55039). Even if a declared temporary table has been dropped, the USER TEMPORARY table space will still be considered to be in use until the unit of work containing the DROP TABLE has been committed.

Dropping a table space drops all objects defined in the table space. All existing database objects with dependencies on the table space, such as packages, referential constraints, etc. are dropped or invalidated (as appropriate), and dependent views and triggers are made inoperative.

Containers created by the user are not deleted. Any directories in the path of the container name that were created by the database manager on CREATE TABLESPACE will be deleted. All containers that are below the database directory are deleted. For SMS table spaces, the deletions occur after all connections are disconnected or the DEACTIVATE DATABASE command is issued.

TRANSFORM ALL FOR type-name
Indicates that all transforms groups defined for the user-defined data type type-name are to be dropped. The transform functions referenced in these groups are not dropped. In dynamic SQL statements, the CURRENT SCHEMA special register is used as a qualifier for an unqualified object name. In static SQL statements, the QUALIFIER precompile/bind option implicitly specifies the qualifier for unqualified object names. The type-name must identify a user-defined type described in the catalog (SQLSTATE 42704).

If there are not transforms defined for type-name, an error is raised (SQLSTATE 42740).

DROP TRANSFORM is the inverse of CREATE TRANSFORM. It causes the transform functions associated with certain groups, for a given datatype, to become undefined. The functions formerly associated with these groups still exist and can still be called explicitly, but they no longer have the transform property, and are no longer invoked implicitly for exchanging values with the host language environment.

The transform group is not dropped if there is a user-defined function (or method) written in a language other than SQL that has a dependency on one of the group's transform functions defined for the user-defined type type-name (SQLSTATE 42893). Such a function has a dependency on the transform function associated with the referenced transform group defined for type type-name. Packages that depend on a transform function associated with the named transform group are marked inoperative.

TRANSFORMS group-name FOR type-name
Indicates that the specified transform group for the user-defined data type type-name is to be dropped. The transform functions referenced in this group are not dropped. In dynamic SQL statements, the CURRENT SCHEMA special register is used as a qualifier for an unqualified object name. In static SQL statements, the QUALIFIER precompile/bind option implicitly specifies the qualifier for unqualified object names. The type-name must identify a user-defined type described in the catalog (SQLSTATE 42704), and the group-name must identify an existing transform group for type-name.

TRIGGER trigger-name
Identifies the trigger that is to be dropped. The trigger-name must identify a trigger that is described in the catalog (SQLSTATE 42704). The specified trigger is deleted.

Dropping triggers causes certain packages to be marked invalid. See the "Notes" section in CREATE TRIGGER concerning the creation of triggers (which follows the same rules).

TYPE type-name
Identifies the user-defined type to be dropped. In dynamic SQL statements, the CURRENT SCHEMA special register is used as a qualifier for an unqualified object name. In static SQL statements the QUALIFIER precompile/bind option implicitly specifies the qualifier for unqualified object names. For a structured type, the associated reference type is also dropped. The type-name must identify a user-defined type described in the catalog. If DISTINCT is specified, then the type-name must identify a distinct type described in the catalog. The type is not dropped (SQLSTATE 42893) if any of the following are true.

Functions that use the type: If the user-defined type can be dropped, then for every function, F (with specific name SF), that has parameters or a return value of the type being dropped or a reference to the type being dropped, the following DROP FUNCTION statement is effectively executed:

   DROP SPECIFIC FUNCTION SF

It is possible that this statement also would cascade to drop dependent functions. If all of these functions are also in the list to be dropped because of a dependency on the user-defined type, the drop of the user-defined type will succeed (otherwise it fails with SQLSTATE 42893).

Methods that use the type: If the user-defined type can be dropped, then for every method, M of type T1 (with specific name SM), that has parameters or a return value of the type being dropped or a reference to the type being dropped, the following statements are effectively executed:

   DROP SPECIFIC METHOD SM
   ALTER TYPE T1 DROP SPECIFIC METHOD SM

The existence of objects that are dependent on these methods may cause the DROP TYPE to fail.

TYPE MAPPING type-mapping-name
Identifies the user-defined data type mapping to be dropped. The type-mapping-name must identify a data type mapping that is described in the catalog (SQLSTATE 42704). The data type mapping is deleted from the database.

No additional objects are dropped.

USER MAPPING FOR authorization-name | USER SERVER server-name
Identifies the user mapping to be dropped. This mapping associates an authorization name that is used to access the federated database with an authorization name that is used to access a data source. The first of these two authorization names is either identified by the authorization-name or referenced by the special register USER. The server-name identifies the data source that the second authorization name is used to access.

The authorization-name must be listed in the catalog (SQLSTATE 42704). The server-name must identify a data source that is described in the catalog (SQLSTATE 42704). The user mapping is deleted.

No additional objects are dropped.

VIEW view-name
Identifies the view that is to be dropped. The view-name must identify a view that is described in the catalog (SQLSTATE 42704). The subviews of a typed view are dependent on their superviews. All subviews must be dropped before a superview can be dropped (SQLSTATE 42893).

The specified view is deleted. The definition of any view or trigger that is directly or indirectly dependent on that view is marked inoperative. Any summary table that is dependent on any view that is marked inoperative is dropped. Any packages dependent on a view that is dropped or marked inoperative will be invalidated. This includes packages dependent on any superviews above the subview in the hierarchy. Any reference columns for which the dropped view is defined as the scope of the reference become unscoped.

VIEW HIERARCHY root-view-name
Identifies the typed view hierarchy that is to be dropped. The root-view-name must identify a typed view that is the root view in the typed view hierarchy (SQLSTATE 428DR). The typed view identified by root-view-name and all of its subviews are deleted from the database.

The definition of any view or trigger that is directly or indirectly dependent on any of the dropped views is marked inoperative. Any packages dependent on any view or trigger that is dropped or marked inoperative will be invalidated. Any reference columns for which a dropped view or view marked inoperative is defined as the scope of the reference become unscoped.

WRAPPER wrapper-name
Identifies the wrapper to be dropped. The wrapper-name must identify a wrapper that is described in the catalog (SQLSTATE 42704). The wrapper is deleted.

All server definitions, user-defined function mappings, and user-defined data type mappings that are dependent on the wrapper are dropped. All user-defined function mappings, nicknames, user-defined data type mappings, and user mappings that are dependent on the dropped server definitions are also dropped. Any index specifications dependent on the dropped nicknames are dropped, and any views dependent on these nicknames are marked inoperative. All packages dependent on the dropped objects and inoperative views are invalidated.

Rules

Dependencies: Table 27 shows the dependencies 96  that objects have on each other. Four different types of dependencies are shown:

R
Restrict semantics. The underlying object cannot be dropped as long as the object that depends on it exists.

C
Cascade semantics. Dropping the underlying object causes the object that depends on it (the depending object) to be dropped as well. However, if the depending object cannot be dropped because it has a Restrict dependency on some other object, the drop of the underlying object will fail.

X
Inoperative semantics. Dropping the underlying object causes the object that depends on it to become inoperative. It remains inoperative until a user takes some explicit action.

A
Automatic Invalidation/Revalidation semantics. Dropping the underlying object causes the object that depends on it to become invalid. The database manager attempts to revalidate the invalid object.

Some DROP statement parameters and objects are not shown in Table 27 because they would result in blank rows or columns:


Table 27. Dependencies

Object Type >
 
 
 
 
 
 
Statement V


C
O
N
S
T
R
A
I
N
T


F
U
N
C
T
I
O
N


F
U
N
C


M
A
P
P
I
N
G


I
N
D
E
X


I
N
D
E
X


E
X
T
E
N
S
I
O
N


M
E
T
H
O
D


N
I
C
K
N
A
M
E


N
O
D
E
G
R
O
U
P


P
A
C
K
A
G
E


S
E
R
V
E
R


T
A
B
L
E


T
A
B
L
E
S
P
A
C
E


T
R
I
G
G
E
R


T
Y
P
E


T
Y
P
E


M
A
P
P
I
N
G


U
S
E
R


M
A
P
P
I
N
G


V
I
E
W

ALTER NICKNAME - - - - - - - - A - - - - - - - -
ALTER SERVER - - - - - - - - A - - - - - - - -
ALTER TABLE DROP CONSTRAINT C - - - - - - - A1 - - - - - - - -
ALTER TABLE DROP PARTITIONING KEY - - - - - - - R20 A1 - - - - - - - -
ALTER TYPE ADD ATTRIBUTE - - - - R - - - A23 - R24 - - - - - R14
ALTER TYPE DROP ATTRIBUTE - - - - R - - - A23 - R24 - - - - - R14
ALTER TYPE ADD METHOD - - - - - - - - - - - - - - - - -
ALTER TYPE DROP METHOD - - - - - - - - - - - - - - - - -
DROP ALIAS - R - - - - - - A3 - R3 - X3 - - - X3
DROP BUFFERPOOL - - - - - - - - - - - R - - - - -
DROP FUNCTION R R7 R - R R7 - - X - R - R - - - R
DROP FUNCTION MAPPING - - - - - - - - A - - - - - - - -
DROP INDEX R - - - - - - - A - - - - - - - R17
DROP INDEX EXTENSION - R - R - - - - - - - - - - - - -
DROP METHOD R R7 R - R R - - X - R - R - - - R
DROP NICKNAME - R - C - - - - A - - - - - - - X16
DROP NODEGROUP - - - - - - - - - - - C - - - - -
DROP SERVER - C21 C19 - - - C - A - - - - - C19 C -
DROP TABLE C R - C - - - - A9 - RC11 - X16 - - - X16
DROP TABLE HIERARCHY C R - C - - - - A9 - RC11 - X16 - - - X16
DROP TABLESPACE - - - C6 - - - - - - CR6 - - - - - -
DROP TRANSFORM - R - - - - - - X - - - - - - - -
DROP TRIGGER - - - - - - - - A1 - - - - - - - -
DROP TYPE R13 R5 - - R - - - A12 - R18 - R13 R4 - - R14
DROP VIEW - R - - - - - - A2 - - - X16 - - - X15
DROP VIEW HIERARCHY - R - - - - - - A2 - - - X16 - - - X16
DROP WRAPPER - - C - - - - - - C - - - - C - -
REVOKE a privilege10 - CR25 - - - - - - A1 - CX8 - X - - - X8

1
This dependency is implicit in depending on a table with these constraints, triggers, or a partitioning key.

2
If a package has an INSERT, UPDATE, or DELETE statement acting upon a view, then the package has an insert, update or delete usage on the underlying base table of the view. In the case of UPDATE, the package has an update usage on each column of the underlying base table that is modified by the UPDATE.

If a package has a statement acting on a typed view, creating or dropping any view in the same view hierarchy will invalidate the package.

3
If a package, summary table, view, or trigger uses an alias, it becomes dependent both on the alias and the object that the alias references. If the alias is in a chain, then a dependency is created on each alias in the chain.

Aliases themselves are not dependent on anything. It is possible for an alias to be defined on an object that does not exist.

4
A user-defined type T can depend on another user-defined type B, if T:

5
Dropping a data type cascades to drop the functions and methods that use that data type as a parameter or a result type, and methods defined on the data type. Dropping of these functions and methods will not be prevented by the fact that they depend on each other. However, for functions or methods using the datatype within their bodies, restrict semantics apply.

6
Dropping a table space or a list of table spaces causes all the tables that are completely contained within the given table space or list to be dropped. However, if a table spans table spaces (indexes or long columns in different table spaces) and those table spaces are not in the list being dropped then the table space(s) cannot be dropped as long as the table exists.

7
A function can depend on another specific function if the depending function names the base function in a SOURCE clause. A function or method can also depend on another specific function or method if the depending routine is written in SQL and uses the base routine in its body. An external method, or an external function with a structured type parameter or returns type will also depend on one or more transform functions.

8
Only loss of SELECT privilege will cause a summary table to be dropped or a view to become inoperative. If the view that is made inoperative is included in a typed view hierarchy, all of its subviews also become inoperative.

9
If a package has an INSERT, UPDATE, or DELETE statement acting on table T, then the package has an insert, update or delete usage on T. In the case of UPDATE, the package has an update usage on each column of T that is modified by the UPDATE.

If a package has a statement acting on a typed table, creating or dropping any table in the same table hierarchy will invalidate the package.

10
Dependencies do not exist at the column level because privileges on columns cannot be revoked individually.

If a package, trigger or view includes the use of OUTER(Z) in the FROM clause, there is a dependency on the SELECT privilege on every subtable or subview of Z. Similarly, if a package, trigger, or view includes the use of DEREF(Y) where Y is a reference type with a target table or view Z, there is a dependency on the SELECT privilege on every subtable or subview of Z.

11
A summary table is dependent on the underlying table or tables specified in the fullselect of the table definition.

Cascade semantics apply to dependent summary tables.

A subtable is dependent on its supertables up to the root table. A supertable cannot be dropped until all its subtables are dropped.

12
A package can depend on structured types as a result of using the TYPE predicate or the subtype-treatment expression (TREAT expression AS data-type). The package has a dependency on the subtypes of each structured type specified in the right side of the TYPE predicate, or the right side of the TREAT expression. Dropping or creating a structured type that alters the subtypes on which the package is dependent causes invalidation.

13
A check constraint or trigger is dependent on a type if the type is used anywhere in the constraint or trigger. There is no dependency on the subtypes of a structured type used in a TYPE predicate within a check constraint or trigger.

14
A view is dependent on a type if the type is used anywhere in the view definition (this includes the type of typed view). There is no dependency on the subtypes of a structured type used in a TYPE predicate within a view definition.

15
A subview is dependent on its superview up to the root view. A superview cannot be dropped until all its subviews are dropped. Refer to 16 for additional view dependencies.

16
A trigger or view is also dependent on the target table or target view of a dereference operation or DEREF function. A trigger or view with a FROM clause that includes OUTER(Z) is dependent on all the subtables or subviews of Z that existed at the time the trigger or view was created.

17
A typed view can depend on the existence of a unique index to ensure the uniqueness of the object identifier column.

18
A table may depend on a user defined data type (distinct or structured) because the type is:

19
Dropping a server cascades to drop the function mappings and type mappings created for that named server.

20
If the partitioning key is defined on a table in a multiple partition nodegroup, the partitioning key is required.

21
If a dependent OLE DB table function has "R" dependent objects (see DROP FUNCTION), then the server cannot be dropped.

22
An SQL function or method can depend on the objects referenced by its body.

23
When an attribute A of type TA of type-name T is dropped, the following DROP statements are effectively executed:
Mutator method: DROP METHOD A (TA) FOR T
Observer method: DROP METHOD A () FOR T
ALTER TYPE T
   DROP METHOD A(TA)
   DROP METHOD A()

24
A table may depend on an attribute of a user-defined structured data type in the following cases:
  1. The table is a typed table that is based on type-name or any of its subtypes.
  2. The table has an existing column of a type that directly or indirectly refers to type-name.

25
A REVOKE of SELECT privilege on a table or view that is used in the body of an SQL function causes an attempt to drop the function, if the function defined no longer has the SELECT WITH GRANT OPTION privilege. If such a function is used in a view or trigger, it cannot be dropped and the REVOKE is restricted as a result. Otherwise, the REVOKE cascades and drops such functions.

Notes

Examples

Example 1:  Drop table TDEPT.

   DROP TABLE TDEPT

Example 2:  Drop the view VDEPT.

   DROP VIEW VDEPT

Example 3:  The authorization ID HEDGES attempts to drop an alias.

  DROP ALIAS A1

The alias HEDGES.A1 is removed from the catalogs.

Example 4:  Hedges attempts to drop an alias, but specifies T1 as the alias-name, where T1 is the name of an existing table (not the name of an alias).

  DROP ALIAS T1

This statement fails (SQLSTATE 42809).

Example 5: 

Drop the BUSINESS_OPS nodegroup. To drop the nodegroup, the two table spaces (ACCOUNTING and PLANS) in the nodegroup must first be dropped.

   DROP TABLESPACE ACCOUNTING
   DROP TABLESPACE PLANS
   DROP NODEGROUP BUSINESS_OPS

Example 6:  Pellow wants to drop the CENTRE function, which he created in his PELLOW schema, using the signature to identify the function instance to be dropped.

  DROP FUNCTION CENTRE (INT,FLOAT)

Example 7:  McBride wants to drop the FOCUS92 function, which she created in the PELLOW schema, using the specific name to identify the function instance to be dropped.

  DROP SPECIFIC FUNCTION PELLOW.FOCUS92

Example 8:  Drop the function ATOMIC_WEIGHT from the CHEM schema, where it is known that there is only one function with that name.

  DROP FUNCTION CHEM.ATOMIC_WEIGHT

Example 9:  Drop the trigger SALARY_BONUS, which caused employees under a specified condition to receive a bonus to their salary.

  DROP TRIGGER SALARY_BONUS

Example 10:  Drop the distinct data type named shoesize, if it is not currently in use.

   DROP DISTINCT TYPE SHOESIZE

Example 11:  Drop the SMITHPAY event monitor.

   DROP EVENT MONITOR SMITHPAY

Example 12:  Drop the schema from Example 2 under CREATE SCHEMA using RESTRICT. Notice that the table called PART must be dropped first.

  DROP TABLE PART
  DROP SCHEMA INVENTRY RESTRICT

Example 13:  Macdonald wants to drop the DESTROY procedure, which he created in the EIGLER schema, using the specific name to identify the procedure instance to be dropped.

  DROP SPECIFIC PROCEDURE  EIGLER.DESTROY

Example 14:  Drop the procedure OSMOSIS from the BIOLOGY schema, where it is known that there is only one procedure with that name.

  DROP PROCEDURE BIOLOGY.OSMOSIS

Example 15:  User SHAWN used one authorization ID to access the federated database and another to access the database at an Oracle data source called ORACLE1. A mapping was created between the two authorizations, but SHAWN no longer needs to access the data source. Drop the mapping.

   DROP USER MAPPING FOR SHAWN SERVER ORACLE1

Example 16:  An index of a data source table that a nickname references has been deleted. Drop the index specification that was created to let the optimizer know about this index.

   DROP INDEX INDEXSPEC 

Example 17:  Drop the MYSTRUCT1 transform group.

   DROP TRANSFORM MYSTRUCT1 FOR POLYGON

Example 18:  Drop the method BONUS for the EMP data type in the PERSONNEL schema.

   DROP METHOD BONUS (SALARY DECIMAL(10,2)) FOR PERSONNEL.EMP


Footnotes:

93
This includes both the table referenced in the ON clause of the CREATE TRIGGER statement and all tables referenced within the triggered SQL statements.

94
For a partially redistributed nodegroup, the REBALANCE_PMAP_ID in the SYSCAT.NODEGROUPS catalog is not -1.

95
This includes both the table referenced in the ON clause of the CREATE TRIGGER statement and all tables referenced within the triggered SQL statements.

96
Not all dependencies are explicitly recorded in the catalog. For example, there is no record of which constraints a package has a dependency on.


[ Top of Page | Previous Page | Next Page ]