If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DROP table by Userid at once

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-04-11, 06:29
perumj1 perumj1 is offline
Registered User
 
Join Date: Oct 2010
Posts: 33
Question DROP table by Userid at once

Hi,

Is there a way to Drop all the tables created by One Mainframe ID on DB2 z/os. Please advise.
Reply With Quote
  #2 (permalink)  
Old 10-04-11, 17:35
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by perumj1 View Post
Is there a way to Drop all the tables created by One Mainframe ID on DB2 z/os. Please advise.
In two steps this is indeed possible:
(1) collect the table names from SYSIBM.SYSTABLES, thereby generating the DROP statements
(2) in a second pass, run the SQL generated in step (1) by cut/pasting it into your SQL frontend (e.g. SPUFI).

Here is a possible SQL statement for pass 1, assuming the user ID is XYZ:

SELECT 'DROP TABLE XYZ.'||rtrim(name)||';'
FROM sysibm.systables
WHERE creator = 'XYZ' AND type = 'T'

(Don't forget the "type" condition: this way only "normal" tables are dropped. Views on those tables will automatically be cascade-dropped.)
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On