2004.04.29


com.jdc.rdb.sql.ddl.drop
Class Drop

java.lang.Object
  |
  +--com.jdc.lang.Object
        |
        +--com.jdc.rdb.sql.SQL
              |
              +--com.jdc.rdb.sql.ddl.DDL
                    |
                    +--com.jdc.rdb.sql.ddl.drop.Drop
All Implemented Interfaces:
Serializable, Statement

public class Drop
extends DDL

Drop represents a Data Definition Language DROP SQL statement.  The Drop statement deletes or removes an object from the Database.  Any objects that are directly or indirectly dependent on that object are either deleted or made inoperative. Whenever an object is deleted, its description is deleted from the catalog and any packages that reference the object are invalidated.  Valid database objects are SCHEMA, TABLE, VIEW, and INDEX.

If the object is of type SCHEMA, this SQL statement drops the specified Schema. A schema may only be dropped only if it contains no tables. The SYS_INFO and APP schemas may not be dropped.

If the object is of type TABLE, this SQL statement drops the specified Table from the database. The IF EXISTS clause (extension of the ANSI SQL-92 standard) will drop the table only if it exists. If this clause is not present, an error is returned if the table does not exist. Any data that exists in a dropped table is lost.

If the object is of type VIEW, this SQL statement drops the specified View from the database. A view can be changed by dropping and recreating it.

Invocation:
This statement can be embedded in an application program or issued through the the use of dynamic SQL statements. It is an executable statement that may be dynamically prepared.
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:
 
 
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.
Example:
        Drop drop = new Drop(table);
        DropStatus status = drop.execute();
 
        if (status.isSuccessful())
        {
            // Drop success
        }
        else
        {
            // Drop failed!
        }
Reference:
IBM® DB2 Universal Database™ SQL Reference Volume 2 Version 8, Pages 512 thru 541.
Notes:
Drop of a multiple tables at one time is not supported.
Drop of a View or Index is not currently supported.

Version:
2.0
Author:
Jay Damon
See Also:
Schema, Table, , Impact, Serialized Form

Field Summary
static String COMMAND
          The Drop statement command keyword.
 
Fields inherited from class com.jdc.rdb.sql.ddl.DDL
sql
 
Fields inherited from class com.jdc.lang.Object
string
 
Constructor Summary
Drop()
          Constructs a new Drop statement object.
Drop(Schema schema)
          Constructs a new Drop statement object for the specified Database Schema definition.
Drop(String statement)
          Constructs a new Drop statement object for the specified SQL String.
Drop(Table table)
          Constructs a new Drop statement object for the specified Database Table definition.
 
Method Summary
 DropStatus execute()
          Executes the Drop statement and returns a DropStatus object.
 Impact getImpact()
          Returns the Impact clause for this Drop statement.
 Drop set(DropClause clause)
          Sets a DropClause for this Drop statement.
 Drop setCascade()
          Adds the optional CASCADE keyword to the Drop statement.
 Drop setRestrict()
          Adds the optional RESTRICT keyword to the Drop statement.
 
Methods inherited from class com.jdc.rdb.sql.ddl.DDL
finalize, getConnection, getDatabase, getObject, isValid, setObject
 
Methods inherited from class com.jdc.rdb.sql.SQL
addClause, execute, getClause, getCommand, getStatement, setCommand, setConnection, setStatement, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMMAND

public static final String COMMAND
The Drop statement command keyword.

See Also:
Constant Field Values
Constructor Detail

Drop

public Drop()
Constructs a new Drop statement object.


Drop

public Drop(Schema schema)
Constructs a new Drop statement object for the specified Database Schema definition.

Throws:
SQLInvalidException - No schema definition is specified.

Drop

public Drop(Table table)
Constructs a new Drop statement object for the specified Database Table definition.

Throws:
SQLInvalidException - No table definition is specified.

Drop

public Drop(String statement)
Constructs a new Drop statement object for the specified SQL String. If you specify a custom SQL String, you must also specify a Database Connection to use.

Throws:
SQLInvalidException - No DROP statement is specified.
See Also:
SQL.setConnection(java.sql.Connection)
Method Detail

execute

public DropStatus execute()
Executes the Drop statement and returns a DropStatus object.

Returns:
The Drop statement status.

getImpact

public Impact getImpact()
Returns the Impact clause for this Drop statement. The Impact clause may be blank or CASCADE or RESTRICT.

Returns:
The Drop statement Impact clause.
See Also:
setCascade(), setRestrict()

set

public Drop set(DropClause clause)
Sets a DropClause for this Drop statement. Use this method to specify a custom Drop clause.

Returns:
This Drop statement object.
Throws:
SQLInvalidException - No DROP statement clause is specified.

setCascade

public Drop setCascade()
Adds the optional CASCADE keyword to the Drop statement. This keyword results in the statement dropping all database objects that depend upon the object to be dropped

Returns:
This Drop statement object.
See Also:
setRestrict()

setRestrict

public Drop setRestrict()
Adds the optional RESTRICT keyword to the Drop statement. This keyword results in the statement not dropping the database object if one or more dependent objects exist.

Returns:
This Drop statement object.
See Also:
setCascade()

2004.04.29



Copyright © 2004 J. Damon & Co.; All Rights Reserved WorldWide.