Results 1 to 2 of 2
  1. #1
    Join Date
    May 2006
    Posts
    18

    Unanswered: 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.

  2. #2
    Join Date
    Oct 2004
    Location
    DELHI INDIA
    Posts
    338
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •