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 > How to drop INDEX in DB2?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-29-06, 06:25
kunal kunal is offline
Registered User
 
Join Date: May 2006
Posts: 18
How to drop INDEX in DB2?

Hi,
I want to know the command which will drop the indexes on the table ..I know " drop index index_name" but i am required to drop all the index on the tables without neccesarily passing the index name..
Any help will be highly apreciated.
Reply With Quote
  #2 (permalink)  
Old 05-29-06, 06:51
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
Hi,

just write a small batch job to grep each indexes present and drop them one by one:

e.g.: Consider you want to drop all the indexes of the tables under the schema name "ts_schema1" and the index schema is "ts_schema2": then you can try the following:

body of the script: (Considering you are on Unix/Aix)
------------------
db2 "connect to db_name"

for ind_name in `db2 -x "select distinct indschema||'.'||indname from syscat.indexes where tabschema in ('ts_schema1') and indschema in ('ts_schema2')"`

do

db2 "drop index $ind_name"

done

Thanks,
Jayanta Datta
New Delhi
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