Does anyone have a script that will drop and rebuild indexes on Sybase 11.9 tables (using Unix AIX) ?
OR
Does anyone have a proc that will list only the index and constraints in a table ?
The easiest way to find a list of indexes on a table is
SELECT name FROM sysindexes WHERE OBJECT_ID = 'table_name'
OR
SELECT name FROM sysobjects WHERE type = 'I'
However, why do you want to drop and recreate all your indexes? Unless you are doing huge updates, wouldn't it be simpler to run a DBCC or UPDATE STATISTICS to ensure that your index and data match??
You may (probably will) find the same performance gains using UPDATE STATISTICS, and will find that it runs quicker than dropping and recreating all your indexes every month.
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).
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.
Hai,
i am senthil, rebuilding your index in Adaptive server
in 11 and above you have rebuild_index command which would match your data with the index leaf pages.. however you DBCC with consistence checker to verify the index. these options are required only for mass updates. you can also
acomplish the same by using update statistics.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.