Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Rebuild indexes online with SQL Server 2005

Rebuild indexes online with SQL Server 2005
http://blogs.techrepublic.com.com/datacenter/?p=249
Online index rebuild
SQL Server 2005 introduces the ability to rebuild your indexes in an
online fashion so that other processes are able to access the table
while the rebuild is occurring. Because you can access the indexes
during the rebuild, you are not limited to only rebuilding indexes
during off-peak hours.
To accomplish this, the database engine takes some special actions
to rebuild the index and to allow access to the index at the same time.
The original index will remain available to users for reading data and
data modification. Row versioning is used to allow for transactional
consistency. During the rebuild, a new index is created that mimics the
old index. Any data modifications that alter the original index will
also be applied to this index by SQL Server during the rebuild. This
new index is not read from at all — it is write-only. It is essential
that you have enough available disk space to accommodate the data for
the two concurrent indexes during the online rebuild. While the rebuild
is taking place, SQL Server uses a mapping index to determine records
to modify in the new index when modifications occur in the original
index. Once the rebuild process has finished, any queries or data
modifications occur to the new index, and the original index is dropped.
Example
The process to rebuild an index online is not much different than
the typical rebuild process; however, there are a few ways to
accomplish the rebuild. One way is to simply drop the index using a
DROP INDEX statement followed by a CREATE INDEX statement. Rebuilding
indexes in this fashion leaves the table without an index until the
index is completely created. For this reason (and a number of other
reasons), dropping the index and recreating it is not recommended.
The CREATE INDEX statement can still be used to rebuild an index if
the DROP_EXISTING option is u


Ïà¹ØÎĵµ£º

sql¾«Õ¿·ÖÒ³Óï¾ä

select top Ò³´óС *
from table1
where id>
      (select max (id) from
      (select top ((Ò³Âë-1)*Ò³´óС) id from table1 order by id) as T) order by id ......

Ò»¸öÏîÄ¿Éæ¼°µ½µÄ50¸öSQLÓï¾ä

 /* 
 ±êÌ⣺һ¸öÏîÄ¿Éæ¼°µ½µÄ50¸öSQLÓï¾ä(ÕûÀí°æ) 
 ×÷Õߣº°®Ð¾õÂÞ.ع»ª
 Ê±¼ä£º2010-05-10 
 ËµÃ÷£ºÒÔÏÂÎåÊ®¸öÓï¾ä¶¼°´ÕÕ²âÊÔÊý¾Ý½øÐйý²âÊÔ£¬×îºÃÿ´ÎÖ»µ¥¶ÀÔËÐÐÒ»¸öÓï¾ä¡£ 
 ÎÊÌâ¼°ÃèÊö£º 
 --1.ѧÉú±í 
 Student(S#,Sname,Sage,Ssex) ......

SQL´¥·¢Æ÷ʵÀý

¶¨Ò壺 ºÎΪ´¥·¢Æ÷£¿ÔÚSQL ServerÀïÃæÒ²¾ÍÊǶÔijһ¸ö±íµÄÒ»¶¨µÄ²Ù×÷£¬´¥·¢Ä³ÖÖÌõ¼þ£¬´Ó¶øÖ´ÐеÄÒ»¶Î³ÌÐò¡£´¥·¢Æ÷ÊÇÒ»¸öÌØÊâµÄ´æ´¢¹ý³Ì¡£
      ³£¼ûµÄ´¥·¢Æ÷ÓÐÈýÖÖ£º·Ö±ðÓ¦ÓÃÓÚInsert , Update , Delete ʼþ¡£
      ÎÒΪʲôҪʹÓô¥·¢Æ÷£¿±ÈÈ磬ÕâôÁ½¸ö±í£º
& ......

SQLÖÐobject_idº¯ÊýµÄÓ÷¨

 ¾­³£»á¿´¼ûÔÚSQL³ÌÐòµÄ¿ªÍ·ÓÐÕâÑùÒ»¾ä»°
if OBJECT_ID('tb') is not null
drop table tb  
º¯ÊýÓï·¨ÊÇÕâÑù£º
int OBJECT_ID('objectname');
×÷ÓÃÊÇ¿´¶ÔÏóobjectnameÊÇ·ñ´æÔÚ¡£
ÆäÖвÎÊýobjectname±íʾҪʹÓõĶÔÏó£¬ÊÇchar»òÕßncharÀàÐÍ¡£
·µ»ØÖµÀàÐÍΪint£¬Èç¹û¶ÔÏó´æÔÚ£¬Ôò·µ»Ø´Ë¶ÔÏóÔÚϵͳÖеı ......

sql¸½¼ÓÊý¾Ý¿âÖ»¶ÁÎÊÌâ

ÔÚSQL Server 2005 Express Éϸ½¼Ó´ÓÁíÍâһ̨µçÄÔCopy¹ýÀ´µÄÊý¾Ý¿âºó£¬Êý¾Ý¿âΪ“Ö»¶Á”¡£ 
½â¾ö°ì·¨£º
´ò¿ª SQL Server Configuration Manager, ´ò¿ªSQL Server SQLEXPRESS µÄÊôÐÔ
ÔÚÄÚÖÃÕʺŴ¦£¬°Ñ“ÍøÂç·þÎñ”¸Ä³É“±¾µØϵͳ”£¬ÖØÐÂÆô¶¯SQL Server 2005 Express ºó£¬ÔÙ¸½¼ÓÊý¾Ý ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ