Question

How would I drop a schema and all of its contents, using SQL, in DB2 8.x without knowing what the content is?

Was it helpful?

Solution

I do not have a schema to drop at hand, but the infocenter (http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/t0005230.htm) says that a DROP SCHEMA [schema name] shall work on DB2 8.x

EDIT: Ok, the Infocenter also says: "Before dropping a schema, all objects that were in that schema must be dropped themselves or moved to another schema"

So, need to drop all the objects in the schema first. The objects (tables, views, triggers, procedures, indexes...) can be listed quering the catalog views in SYSIBM schema.

E.g. to get all tables that belong to schema, run:

select table_name from sysibm.tables where table_schema = '[your schema name]'

Check the other sysibm views to get all objects that belong into a schema. the views are: sysibm.views, sysibm.triggers, sysibm.routines, sysibm.indexes, ... - consult IBM's Infocenter (the link above) for details.

OTHER TIPS

use the comand centre-GUI to drop all contents of the schema, then DROP SCHEMA

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top