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 > Dropping Primary keys, Index and tables at once.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-10-11, 02:35
perumj1 perumj1 is offline
Registered User
 
Join Date: Oct 2010
Posts: 33
Question Dropping Primary keys, Index and tables at once.

Hi,

Is it possible to drop all the primary keys, Index and tables created by user. Please share me the SQL query to achieve this objective.
Reply With Quote
  #2 (permalink)  
Old 01-10-11, 04:14
wilsonfv wilsonfv is offline
Registered User
 
Join Date: Apr 2009
Posts: 42
check syscat.tables, syscat.indexes and syscat.constraints, see the field "create user" then generate the sql
Reply With Quote
  #3 (permalink)  
Old 01-10-11, 06:00
perumj1 perumj1 is offline
Registered User
 
Join Date: Oct 2010
Posts: 33
Question

Hi,

I would Like to know if we can achieve this Via Batch process in mainframe to drop all the indexes, primary key and tables associated to a userid.
Reply With Quote
  #4 (permalink)  
Old 01-10-11, 06:36
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
It is sufficient to just drop tables; all dependent indexes and constraints, including PKs, will be dropped automatically.
Reply With Quote
  #5 (permalink)  
Old 01-10-11, 09:13
perumj1 perumj1 is offline
Registered User
 
Join Date: Oct 2010
Posts: 33
Talking

Thanks for the clarification
Reply With Quote
  #6 (permalink)  
Old 01-10-11, 10:12
Stealth_DBA Stealth_DBA is offline
Registered User
 
Join Date: May 2009
Posts: 472
perumj1, since you are on the mainframe (z/os I assume), it also depends on how your system is set up.

If every user has a separate table space, you can drop the table space which will get rid of all dependent objects (tables, Indexes, etc.).

If every user has a separate database, you can drop the database which will get rid of all dependent objects (table spaces, tables, Indexes, etc.).

Note: One item that will not be dropped automatically is any Aliases. These have to be dropped separately. Additionally, any Plans or Packages will have to be freed to remove them from the system (they will only be invalidated if the dependent tables / indexes are dropped).
Reply With Quote
  #7 (permalink)  
Old 01-10-11, 22:49
perumj1 perumj1 is offline
Registered User
 
Join Date: Oct 2010
Posts: 33
Wilson,

Yes I am from Z/os. Here My challenge is to just free up the tablespaces for One Database. Since No users were able to insert any tables any more and they were getting an error of Sqlcode = -497 error.
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