Hi, I'm a former Sybase instructor/course developer. (Currently unemployed if you can believe it!) Here are some selected links and a crude way to get the information you need to create a script from the system catalogs -without getting too caught up in writing your own).
Ed Barlow's Site:
David Midomer's Site:
(Home of dbschema.pl -- This will do everything for you. Generates a huge script of your entire server if you need it)
Other good resources:
Michael Peppler's Site (SybPerl):
ISUG Sybase FAQ listing:
The hack:
If you're really in a hurry, and you are great with a text editor that can do bulk search and replace on columns, you can use the outputs of sp_help (to get a list of tables) and sp_helpindex (to get text description of the index names and keys) to generate the information you need, then edit the outputs into a script.
Once you have this script, rebuilding is 'easy'. Remember to put the drop index <indexname> command before each create index command as a separate statement, followed by 'go' on a line by itself in the isql script.
The big lesson here is always keep scripts to do a logical rebuild. And keep track of how long each operation is taking.
Tips:
FYI - something to beware of: do not stop and restart your server in the middle of running one of these index build scripts - The rollforward of drop index has to rebuild the original index.
And - of course - beware of the time it takes to drop and rebuild indexes.
If you just rebuild the clustered indexes, the non-clustered index are automatically rebuilt. This is another consideration to take in making your script.
Another tip: Do it when there are no other users on your system. When you drop and rebuild clustered indexes, there will be potential for lock wait scenario's, deadlocking etc. This leads people to do irrational things like trying to restart the server.
Good Luck,
Doug dougsmith94703@yahoo.com