Dropping a schema and all of its contents in DB2 8.x

让人想犯罪 __ 提交于 2019-12-08 03:53:15

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/614976/dropping-a-schema-and-all-of-its-contents-in-db2-8-x

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!