|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
Merge将一定数量的MyISAM表联合而成一个整体,在超大规模数据存储时很有用serversqlserver2005中新增添的trycatch,能够很简单捕获非常了,明天也许进修看了下,归结下要点以下
基础用法BEGINTRY
{sql_statement|
statement_block}
ENDTRY
BEGINCATCH
{sql_statement|
statement_block}
ENDCATCH
,和一般言语的非常处置用法差未几,但要注重的是,SQLSERVER只捕获那些不是严峻的非常,当好比数据库不克不及毗连等这类非常时,是不克不及捕获的一个例子:BEGINTRY
DECLARE@XINT
--DividebyzerotogenerateError
SET@X=1/0
PRINTCommandaftererrorinTRYblock
ENDTRY
BEGINCATCH
PRINTErrorDetected
ENDCATCH
PRINTCommandafterTRY/CATCHblocks
别的trycatch能够嵌套BeginTRY
deletefromGrandParentwhereName=JohnSmith
printGrandParentdeletedsuccessfully
EndTry
BeginCatch
PrintErrorDeletingGrandParentRecord
BeginTry
deletefromParentwhereGrandParentID=
(selectdistinctIDfromGrandParentwhereName=JohnSmith)
PrintParentDeletedSuccessfully
EndTry
BeginCatch
printErrorDeletingParent
BeginTry
deletefromchildwhereParentId=
(selectdistinctIDfromParentwhereGrandParentID=
(selectdistinctIDfromGrandParentwhereName=JohnSmith))
printChildDeletedSuccessfully
EndTry
BeginCatch
PrintErrorDeletingChild
EndCatch
EndCatch
EndCatch
别的,SQLSERVER2005在非常机制中,供应了error类的办法便利调试,现摘抄以下,对照复杂,不予以注释ERROR_NUMBER():Returnsanumberassociatedwiththeerror.ERROR_SEVERITY():Returnstheseverityoftheerror.ERROR_STATE():Returnstheerrorstatenumberassociatedwiththeerror.ERROR_PROCEDURE():Returnsthenameofthestoredprocedureortriggerinwhichtheerroroccurred.ERROR_LINE():Returnsthelinenumberinsidethefailingroutinethatcausedtheerror.ERROR_MESSAGE():Returnsthecompletetextoftheerrormessage.Thetextincludesthevaluessuppliedforanysubstitutableparameters,suchaslengths,objectnames,ortimes.最初举例子以下,利用了error类的办法BEGINTRY
DECLARE@XINT
--DividebyzerotogenerateError
SET@X=1/0
PRINTCommandaftererrorinTRYblock
ENDTRY
BEGINCATCH
PRINTErrorDetected
SELECTERROR_NUMBER()ERNumber,
ERROR_SEVERITY()Error_Severity,
ERROR_STATE()Error_State,
ERROR_PROCEDURE()Error_Procedure,
ERROR_LINE()Error_Line,
ERROR_MESSAGE()Error_Message
ENDCATCH
PRINTCommandafterTRY/CATCHblocks
最初输入ErrorDetected
Err_NumErr_SevErr_StateErr_ProcErr_LineErr_Msg
------------------------------------------------------------------------------------
8134161NULL4Dividebyzeroerrorencountered.
这章描述如何检查和处理在MySQL数据库中的数据损坏。如果你的表损坏很多,你应该尝试找出其原因!见G.1调试一个MySQL服务器。 |
|