How do I drop a schema in db2 if it has got some objects in it? db2 DROP SCHEMA SCHEMA_NAME

For some reason I am not able to drop the tables in the schema, so how can I force to drop the schema itself?


If there are some objects in the schema, or depend on it.

It is not allowed to drop the schema in db2.

We must drop the objects first. and then db2 "drop schema schema_name RESTRICT"

And there is another way to drop the schema and all objects in it.

ADMIN_DROP_SCHEMA procedure - Drop a specific schema and its objects.


by the way: You need to have sufficient permission to drop object.

| improve this answer | |
  • @Nachikethas - here are the links to the documentation for what Peter Ji refered too. publib.boulder.ibm.com/infocenter/db2luw/v9/topic/… and then publib.boulder.ibm.com/infocenter/db2luw/v9/topic/… – Chris Aldrich Mar 7 '12 at 13:45
  • Well that's just asinine for developers. When I'm creating a DB schema it happens very often that some thing has changed in the design or that I need a clean DB to test something. So far I've been manually deleting all the views and tables, which is really annoying and shouldn't be an issue in the first place. Is there a tool that can do the object deletion for me? – G_V May 29 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.