Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop all tables

Status
Not open for further replies.

oana12

Programmer
Jan 6, 2005
21
CA
Hi,
I want to create a script to drop every table which exist in my database. I know that in SQL Server, for example, you can create like this

if exists (SELECT * FROM sysobjects WHERE id = object_id('dbo.x') AND sysstat & 0xf = 3)
drop table dbo.x
GO

How can I do something like this in DB2 using sysstat.tables?

Thanks.
 
Something like:

select 'drop table '||rtrim(creator)||'.'||rtrim(name)||';'
from sysibm.systables
where creator not in ('SYSIBM', 'SYSCAT')
 
If you drop all the tables, there won't be much left. Why not just
Code:
DROP DATABASE my_db;
and re-create it afterwards?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top