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
-
these photos are from a gallery I posted http://justacarguy.blogspot.com/2011/04/gourmet-feed-trucks-were-gathered-to.html when I accident...
-
Photo: Russell Bates, 2010. Red Car Property neighborhood beekeepers in LA Times. (Click on photo to enlarge.)
-
Honda nearing capacity at Swindon Honda's UK factory in Swindon, which builds the Civic and CR-V models , will be working at its peak o...
-
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 ...
-
Boxstr continues being absolutely useless. Seems like it's (occasionally) possible to download songs previously uploaded, but for the p...
-
Electric / 63 PS / 133 ft/lb (180 Nm) / 0 - 62 mph (100 km/h): 11,4 s / Vmax: 91 mph (146 km/h) / range: 115 miles (185 km) (click images ...
-
For the second time this summer, Kia is teasing the upcoming Carens compact MPV with a set of sketches that were released in advance of the...
-
So, yeah. There's always a simmering debate among writers about whether or not to respond to bad reviews. In one recent article titled W...
-
The all-new 2013 ATS premium compact sedan will be taking the spotlight on Cadillac’s stand at the upcoming Paris Motor Show as the automak...
-
S4 / 1.984 cc / 200 PS / 207 ft/lb (280 Nm) @ 1.700 - 5.000 / turbo / AWD (click images for a larger view)
No comments:
Post a Comment