SQLSERVERÐÞ¸´Ð¡ÖªÊ¶
ÔÚÓëÊý¾Ý¿â´ò½»µÀµÄ¹¤×÷ÖÐʱ³£»áÅöµ½Ò»Ð©Êý¾Ý¿âµÄ´íÎó£¬Õâ¾ÍÉæ¼°µ½ÁËÐÞ¸´µÄ¹ý³Ì£¬ÒÔÏÂ֪ʶµã¶¼ÊÇ´ÓÍøÉÏÊÕ¼¯¶øÀ´:
1¡¢dbcc checkdb
Õâ¸öÃüÁî¿ÖÅÂÊÇÎÒÃÇ×î³£ÓõÄÁË£¬´ø¼ì²éºÍÐÞ¸´¹¦ÄÜ
Óï·¨¸ñʽ£º
DBCC CHECKDB
[
[ ( database_name | database_id | 0
[ , NOINDEX
| , { REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD } ]
) ]
[ WITH
{
[ ALL_ERRORMSGS ]
[ , EXTENDED_LOGICAL_CHECKS ]
[ , NO_INFOMSGS ]
[ , TABLOCK ]
[ , ESTIMATEONLY ]
[ , { PHYSICAL_ONLY | DATA_PURITY } ]
}
]
]
REPAIR_ALLOW_DATA_LOSS ¸Ã²ÎÊý»á³¢ÊÔÐÞ¸´ËùÓдíÎ󣬵«ÔÚÐÞ¸´µÄ¹ý³ÌÖлá³öÏÖÊý¾ÝµÄ¶ªÊ§
REPAIR_FAST ¸Ã²ÎÊý½øÐÐСµÄ¡¢²»ºÄʱµÄÐÞ¸´²Ù×÷£¬ÈçÐÞ¸´·Ç¾Û¼¯Ë÷ÒýÖеĸ½¼Ó¼ü¡£ÕâЩÐÞ¸´¿ÉÒԺܿìÍê³É£¬²¢ÇÒ²»»áÓжªÊ§ Êý¾ÝµÄΣÏÕ¡£
REPAIR_REBUILD ¸Ã²ÎÊýÖ´ÐÐÓÉ REPAIR_FAST Íê³ÉµÄËùÓÐÐÞ¸´£¬°üÀ¨ÐèÒª½Ï³¤Ê±¼äµÄÐÞ¸´£¨ÈçÖؽ¨Ë÷Òý£©¡£Ö´ÐÐÕâЩÐÞ¸´Ê±²» »áÓжªÊ§Êý¾ÝµÄΣÏÕ¡£
DBCC CHECKDB ¶ÔË÷ÒýÊÓͼִÐÐÎïÀíÒ»ÖÂÐÔ¼ì²é¡£Ö»ÓÃÓÚÏòºó¼æÈÝµÄ NOINDEX Ñ¡ÏîÒ²ÊÊÓÃÓÚË÷ÒýÊÓͼÉϵÄÈκθ¨ÖúË÷Òý¡£
DBCC CHECKDB ÊÇ×ȫµÄÐÞ¸´Óï¾ä£¬ÒòΪËü¶Ô×î¶àµÄ¿ÉÄܳöÏֵĸ÷ÖÖ´íÎó½øÐбêʶºÍÐÞ¸´¡£Èç¹ûÖ»±¨¸æÊý¾Ý¿âÖÐÓзÖÅä´íÎó£¬ÇëÖ´ÐдøÐÞ¸´Ñ¡ÏîµÄ DBCC CHECKALLOC ÒÔ¶ÔÕâЩ´íÎó½øÐÐÐÞ¸´¡£È»¶ø£¬ÈôҪȷ±£ÕýÈ·ÐÞ¸´ËùÓдíÎ󣨰üÀ¨·ÖÅä´íÎ󣩣¬ÇëÖ´ÐдøÐÞ¸´Ñ¡ÏîµÄ DBCC CHECKDB£¬¶ø²»ÒªÖ´ÐдøÐÞ¸´Ñ¡ÏîµÄ DBCC CHECKALLOC¡£
DBCC CHECKDB ¶ÔÊý¾Ý¿âÖÐËùÓÐÄÚÈݵÄÍêÕûÐÔ½øÐÐÑéÖ¤¡£Èç¹ûµ±Ç°ÕýÔÚÖ´Ðлò×î½üÒÑÖ´ÐÐ DBCC CHECKDB£¬Ôò²»ÐèÒªÔËÐÐ DBCC CHECKALLOC »ò DBCC CHECKTA
Ïà¹ØÎĵµ£º
½ñÌìÒ»²»Àä¾²¾Í°ÑsqlserverÊý¾Ý¿â³õʼ»¯ÁË£¬ÔÚÍøÉÏÕÒÁË°ëÌì·¢ÏÖÁ˼¸ÆªÌû×Ó£¬ÊÜÒæ·Çdz£¬¼Ç¼ÏÂ
DB2ÖпÉÒÔʹµÃÊý¾Ý¿â»Ø¸´µ½Ö¸¶¨µÄʱ¼äµã£¬SQL ServerÊý¾Ý¿âµÄRecovery ModelΪfull »òÕßBulk copyµÄʱºò£¬ÊÇ¿ÉÒÔ´ÓÈÕÖ¾À´»Ö¸´Êý¾Ý¿âµÄ¡£Êµ¼ÊÉÏÈÕÖ¾ÖмǼµÄÒ»ÌõÒ»ÌõµÄtransact sqlÓï¾ä£¬»Ö¸´Êý¾Ý¿âµÄʱºò»áredoÕâЩsqlÓï¾ä¡£&nb ......
BULK INSERT
¡¡¡¡ÔÚSQL ServerÖУ¬BULK INSERTÊÇÓÃÀ´½«ÍⲿÎļþÒÔÒ»ÖÖÌض¨µÄ¸ñʽ¼ÓÔص½Êý¾Ý¿â±íµÄT-SQLÃüÁî¡£¸ÃÃüÁîʹ¿ª·¢ÈËÔ±Äܹ»Ö±½Ó½«Êý¾Ý¼ÓÔص½Êý¾Ý¿â±íÖУ¬¶ø²»ÐèҪʹÓÃÀàËÆÓÚIntegration ServicesÕâÑùµÄÍⲿ³ÌÐò¡£ËäÈ»BULK INSERT²»ÔÊÐí°üº¬Èκθ´ÔÓµÄÂß¼»òת»»£¬µ«Äܹ»ÌṩÓë¸ñʽ»¯Ïà¹Øµ ......
select case when c.colid=1 then object_name(c.id) else '' end as ±íÃû
,c.name as ×Ö¶ÎÃû
,t.name Êý¾ÝÀàÐÍ
,c.prec as ³¤¶È ......