DB2刪除schema

like052629發表於2015-05-15
刪除schema
  DROP SCHEMA ERRORSCHEMA1 RESTRICT    --schema中不能含有任何物件
  --RESTRICT 關鍵字強制實施以下規則:不能在指定的模式中為要從資料庫中刪除的模式定義物件。RESTRICT 關鍵字並非可選關鍵字



IBM網址:
DB2 10.5 for Linux, UNIX, and Windows

ADMIN_DROP_SCHEMA procedure - Drop a specific schema and its objects

The ADMIN_DROP_SCHEMA procedure is used to drop a specific schema and all objects contained in it.

Syntax

Read syntax diagram >>-ADMIN_DROP_SCHEMA--(--schema--,--dropmode--,-----------------&gt

>--errortabschema--,--errortab--)------------------------------&gt<

The schema is SYSPROC.

Procedure parameters

schema An input argument of type VARCHAR(128) that specifies the name of the schema being dropped. The name must be specified in uppercase characters. dropmode Reserved for future use and should be set to NULL. errortabschema An input and output argument of type VARCHAR(128) that specifies the schema name of a table containing error information for objects that could not be dropped. The name is case-sensitive. This table is created for the user by the ADMIN_DROP_SCHEMA procedure in the SYSTOOLSPACE table space. If no errors occurred, then this parameter is NULL on output. errortab An input and output argument of type VARCHAR(128) that specifies the name of a table containing error information for objects that could not be dropped. The name is case-sensitive. This table is created for the user by the ADMIN_DROP_SCHEMA procedure in the SYSTOOLSPACE table space. This table is owned by the user ID that invoked the procedure. If no errors occurred, then this parameter is NULL on output. If the table cannot be created or already exists, the procedure operation fails and an error message is returned. The table must be cleaned up by the user following any call to ADMIN_DROP_SCHEMA; that is, the table must be dropped in order to reclaim the space it is consuming in SYSTOOLSPACE.
Table 1. ADMIN_DROP_SCHEMA errortab format
Column name Data type Description
OBJECT_SCHEMA VARCHAR(128)
OBJECT_NAME VARCHAR(128)
OBJECT_TYPE VARCHAR(30)
SQLCODE INTEGER The error SQLCODE.
SQLSTATE CHAR(5) The error SQLSTATE.
ERROR_TIMESTAMP TIMESTAMP Time that the drop command failed.
STATEMENT CLOB(2 M) DDL for the failing object.
DIAGTEXT CLOB(2 K) Error message text for the failed drop command.

Authorization

One of the following authorizations is required:
  • EXECUTE privilege on the ADMIN_DROP_SCHEMA procedure
  • DATAACCESS authority
  • DBADM authority
  • SQLADM authority
In addition, drop authority is needed on all objects being removed for the user calling this procedure.

Default PUBLIC privilege

In a non-restrictive database, EXECUTE privilege is granted to PUBLIC when the procedure is automatically created.

Example

CALL SYSPROC.ADMIN_DROP_SCHEMA('SCHNAME', NULL, 'ERRORSCHEMA', 'ERRORTABLE')
The following is an example of output for this procedure.
Value of output parameters
--------------------------
Parameter Name : ERRORTABSCHEMA
Parameter Value : ERRORSCHEMA 
The return status is not zero only when an internal error has been detected (for example, if SYSTOOLSPACE does not exist).
		
Errors can be checked by querying the error table:
SELECT * FROM ERRORSCHEMA.ERRORTABLE

Usage notes

  • If objects in another schema depend on an object being dropped, the default DROP statement semantics apply.
  • This procedure does not support dropping the following objects:
    • Index extensions
    • Nicknames
    • Packages
    • Typed tables
    • Array types
    • User-defined structured types (and their transform functions)
    • Typed views
    • Jars (Java? routine archives)
    • Staging tables
    • XSR objects
  • If one of these objects exists in the schema being dropped, neither the object nor the schema is dropped, and an entry is added to the error table indicating that the object was not dropped.
  • The operation of this procedure requires the existence of the SYSTOOLSPACE table space. This table space is used to hold metadata used by the ADMIN_DROP_SCHEMA procedure as well as error tables returned by this procedure. If the table space does not exist, an error is returned.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28258625/viewspace-1656139/,如需轉載,請註明出處,否則將追究法律責任。

相關文章