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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Index based on other existing index? 1

Status
Not open for further replies.

YuriyS.

IS-IT--Management
Dec 13, 2019
1
UA
Hi all,
I'm new on DB2 so would like to ask if there is smart way for move/copy index from one table to another(set of columns are the same).

So generally we have 2 identical tables A and B, table B has no indexes, and I would like to create same set indexes on table B , as we have on table A.

Offcourse we can do DB2 stored procedure and dynamic SQL that will build string for creating new indexes based on syscat.Indexes data, but maybe there is more elegant way of achiving the goal, maytbe some copy/move index routine or like that. Flipping tables etc. is not possible in the case, so we need just "move indexes" from table A to table B.

As I can see there is also "db2look" command that looks like can output index DDL to out file, but not sure if it possible redirect output of the command to string varaible in DB2 SP dynamic SQL or open code.

Thanks in adwanced for any advices!
 
Because the index maps to the actual address of the record in the data file, there is no way to "copy" an index. Just build the index on the new file using the same parameters as the original file. So yes, use syscat.indexes.

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top