Managing indexes in SQL Server 2005 has changed. All the index management functions are now located in a new and more standardized, ALTER INDEX statement. The DBCC DBREINDEX, DBCC INDEXDEFRAG and DBCC SHOWCONTIG commands are now deprecated and will be removed in future versions.
a) To rebuild an index on a table, we now use the REBUILD keyword like this:
ALTER INDEX PK_CustomerID ON Customers
REBUILD
b) To rebuild all indexes on a table, we can use the ALL keyword like this:
ALTER INDEX ALL ON Customers
REBUILD
c) To handle index fragmentation, use the REORGANIZE keyword like this:
ALTER INDEX IX_CustomerName ON Customers
REORGANIZE
d) To disable an index, use the DISABLE keyword like this:
ALTER INDEX IX_CustomerName ON Customers
DISABLLE
Note: To re-enable the index, use the REBUILD keyword as shown earlier.
e) To view size and fragmentation information, use the sys.dm_db_index_physical_stats catalog view instead. Example:
SELECT * FROM sys.dm_db_index_physical_stats
Home »Unlabelled » SQL2005: Alter.Index
Popular Post
-
H ave been trying to download Office 2007 Beta 1 Refresh for the past few days but the line traffic condition was so bad. With just below 10...
-
Check out new Tiger Baby single Landscapes ...taken from the band's new album Open Windows Open Hills . Predictably, this is catc...
-
Is it Hunting Season again? Everyone I know seems to be looking (or have looked) for greener pastures nowadays. I was so surprised to find ...
-
S QL Server 2005 SP1 March 2006 CTP and its accompanying SQL Server 2005 Books Online (March 2006 CTP) are now available for preview. User...
-
Time to leave the bad stuff behind, so here's the wonderful new video by Acid House Kings for their absolutely wonderful single Would Y...
-
M y Streamyx was down for approximately five days. The technician told me that it is a problem with my port over in their headquarters. Acco...
-
The Uri (Namibia) Uri. From the Namibian word for "jump", this extremely able 4x4 is perfect for the real off road path. Made in N...
-
T eam Foundation Server has finally shipped! This completes the Visual Studio Team System family. Incase you are unaware, Team Foundation S...
No comments:
Post a Comment