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
-
V12 / 5.576 cc / 385 PS / 406 ft/lb (550 Nm) @ 4.000 / 0 - 62 mph (100 km/h): 6,6 s / Vmax: 155 mph (250 km/h) (click images for a larger ...
-
Photo: Diane Edwardson, February 18, 2012. Native California Black Walnuts are sprouting leaves on the Red Car Property. (Click on photo t...
-
Apparently, SGDOTNET did another major upgrade to their site and the incident broke all my image links on my blog :(
-
Advice for children from the Department for Transport via deep-cover agents at Manchester Cycling . The implication of all the clever games...
-
BMW did manual-gearbox fans in the U.S. a favor by adding the option on its latest 2013 M5 F10 saloon as a no-cost alternative to the standa...
-
I discovered data annotations while I was learning ASP.NET Web Forms Model Binding sometime back. From a little reading, I got to know tha...
-
H ave been chewing on SQL Books Online for the past few days. *Stress* It appears that the 071-441: PRO: Designing Database Solutions by Us...
-
"W hy are you always taking exams?!" - That's a common question from people I know. Yeah! If you notice it, I'm always tak...
-
There were lots of issues to contend with up to the end, but got through with flying colors. Consumer reports had something to say about our...
-
F inally found out who smsed me - it turns out to be one of my colleagues *HuHuHu* * paiseh * * paiseh * Sorry buddy, *sweating* didn't ...
No comments:
Post a Comment