Drop and Recreate all indexes
Posted on 2005-05-11
Greetings, Sybase experts!
We have about 320 indexes or so in a particular database that we need to drop and recreate to clear up some space and to make them "clean" again.
We use Embarcadero's RapidSQL, and what we normally would do is to execute the code that drops and creates each index. But with 320 or so of these, it takes some time. What I'd like to be able to do is to create a stored proc that has the code to drop and recreate all 320 indexes, so we don't have to execute each one by one.
We need to repeat this every couple months or so, so having the code all in one place will be helpful going forward.
Isn't the code stored in a table somewhere? Couldn't I do a select that will dump the index drop and creation code for each index in the database and spool the results, which I could then copy and paste in a new stored proc?
If so, what would the query be? If not, is there any way to do this other than manually copying each code and pasting it into a text file?