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
-
I've been looking into the programmable aspects of SQL Server 2005 for the past days and one of the things that interest me most is the ...
-
ARC312 - Enterprise Architecture by Gurpreet Pall Started day 2 with a dose of Enterprise Architecture. I like Gurpreet's example of ...
-
What a disappointing day! :( Started the day with a massive traffic congestion in the main road not far from my house. Stucked there for al...
-
Got curious about the Firebird database today. Heard of it for quite sometime but never tried it. One of my friends has been giving a lot o...
-
M anaging indexes in SQL Server 2005 has changed. All the index management functions are now located in a new and more standardized, ALTER I...
-
I was roped in to work on Active Directory these two days as the dudes in the MIS department had ran out of ideas. I was approached by my CI...
-
"Too many cooks spoil the broth" As the famous saying goes but will too many developers spoil the code ? It actually depends on ...
-
Have been hooked on Zuma lately (an online game provided by MSN). Never imagined that such a simple game can be so addictive. Previously, I...
-
Have you ever wished to be able to work from home? You know like, sitting on that nice comfy chair (or slumber on the bed), listening to the...
-
Day 4 of J2EE training. Today, we completed everything on Enterprise Java Beans (EJB). For the past two days, we learnt about Session Beans,...
No comments:
Post a Comment