SQL Server BackupTutorialWord文档下载推荐.docx

上传人:b****6 文档编号:19846211 上传时间:2023-01-10 格式:DOCX 页数:26 大小:388KB
下载 相关 举报
SQL Server BackupTutorialWord文档下载推荐.docx_第1页
第1页 / 共26页
SQL Server BackupTutorialWord文档下载推荐.docx_第2页
第2页 / 共26页
SQL Server BackupTutorialWord文档下载推荐.docx_第3页
第3页 / 共26页
SQL Server BackupTutorialWord文档下载推荐.docx_第4页
第4页 / 共26页
SQL Server BackupTutorialWord文档下载推荐.docx_第5页
第5页 / 共26页
点击查看更多>>
下载资源
资源描述

SQL Server BackupTutorialWord文档下载推荐.docx

《SQL Server BackupTutorialWord文档下载推荐.docx》由会员分享,可在线阅读,更多相关《SQL Server BackupTutorialWord文档下载推荐.docx(26页珍藏版)》请在冰豆网上搜索。

SQL Server BackupTutorialWord文档下载推荐.docx

SQLServerManagementStudio

IfyouarenewtoSQLServeryoushouldrevieweachofthesetopics,soyouareawareoftheavailableoptionsandwhatstepsyouwillneedtotakeinordertorecoveryourdataifeverthereistheneed.

Youcaneitherusetheoutlineontheleftorclickonthearrowstotheright 

orbelowtoscrollthrougheachofthesetopics.

SQLServerRecoveryModels

(SETRECOVERY)

Oneofthefirstthingsthatneedstobesetinordertocreatethecorrectbackupsistosettheproperrecoverymodelforeachdatabase. 

TherecoverymodelbasicallytellsSQLServerwhatdatatokeepinthetransactionlogfileandforhowlong. 

Basedontherecoverymodelthatisselected,thiswillalsodeterminewhattypesofbackupsyoucanperformandalsowhattypesofdatabaserestorescanbeperformed.

Explanation

Thethreetypesofrecoverymodelsthatyoucanchoosefromare:

∙Full

∙Simple

∙Bulk-Logged

Eachdatabasecanhaveonlyonerecoverymodel,buteachofyourdatabasescanuseadifferentrecoverymodel,sodependingontheprocessingandthebackupneedsyoucanselecttheappropriaterecoverymodelperdatabase. 

TheonlyexceptiontothisistheTempDBdatabasewhichhastousethe"

Simple"

recoverymodel.

Also,thedatabaserecoverymodelcanbechangedatanytime,butthiswillimpactyourbackupchain,soitisagoodpracticetoissueafullbackupafteryouchangeyourrecoverymodel.

TherecoverymodelcanbechangedbyeitherusingT-SQLorSQLServerManagementStudio. 

Followingareexamplesonhowtodothis.

UsingT-SQLtochangetothe"

Full"

recoveryfortheAdventureWorksdatabase.

ALTERDATABASEAdventureWorksSETRECOVERYFULL

GO

UsingtheSSMStochangetherecoverymodelfortheAdventureWorksdatabase.

AdditionalInformation

∙SelectingtheSQLServerdatabaserecoverymodeltoensureproperbackups

SQLServerFullRecoveryModel

(SETRECOVERYFULL)

The"

recoverymodeltellsSQLServertokeepalltransactiondatainthetransactionloguntileitheratransactionlogbackupoccursorthetransactionlogistruncated.ThewaythisworksisthatalltransactionsthatareissuedagainstSQLServerfirstgetenteredintothetransactionlogandthenthedataiswrittentotheappropriatedatafile. 

ThisallowsSQLServertorollbackeachstepoftheprocessincasetherewasanerrororthetransactionwascancelledforsomereason. 

Sowhenthedatabaseissettothe"

recoverymodelsincealltransactionshavebeensavedyouhavetheabilitytodopointintimerecoverywhichmeansyoucanrecovertoapointrightbeforeatransactionoccurredlikeanaccidentaldeletionofalldatafromatable.

Thefullrecoverymodelisthemostcompleterecoverymodelandallowsyoutorecoverallofyourdatatoanypointintimeaslongasallbackupfilesareuseable.Withthismodelalloperationsarefullyloggedwhichmeansthatyoucanrecoveryourdatabasetoanypoint.Inaddition,ifthedatabaseissettothefullrecoverymodelyouneedtoalsoissuetransactionlogbackupsotherwiseyourdatabasetransactionlogwillcontinuetogrowforever.

Herearesomereasonswhyyoumaychoosethisrecoverymodel:

∙Dataiscriticalanddatacannotbelost.

∙Youalwaysneedtheabilitytodoapoint-in-timerecovery.

∙Youareusingdatabasemirroring

Typeofbackupsyoucanrunwhenthedataisinthe"

recoverymodel:

∙Completebackups

∙Differentialbackups

∙Fileand/orFilegroupbackups

∙Partialbackups

∙Copy-Onlybackups

∙Transactionlogbackups

HowtosetthefullrecoverymodelusingT-SQL.

ALTERDATABASEdbNameSETRECOVERYrecoveryOption

Example:

changeAdventureWorksdatabaseto"

recoverymodel

HowtosetusingSQLServerManagementStudio

∙RightclickondatabasenameandselectProperties

∙GototheOptionspage

∙UnderRecoverymodelselect"

∙Click"

OK"

tosave

SQLServerSimpleRecoveryModel

(SETRECOVERYSIMPLE)

recoverymodeldoeswhatitimplies,itgivesyouasimplebackupthatcanbeusedtoreplaceyourentiredatabaseintheeventofafailureorifyouhavetheneedtorestoreyourdatabasetoanotherserver. 

Withthisrecoverymodelyouhavetheabilitytodocompletebackups(anentirecopy)ordifferentialbackups(anychangessincethelastcompletebackup). 

Withthisrecoverymodelyouareexposedtoanyfailuressincethelastbackupcompleted. 

 

recoverymodelisthemostbasicrecoverymodelforSQLServer. 

Everytransactionisstillwrittentothetransactionlog,butoncethetransactioniscompleteandthedatahasbeenwrittentothedatafilethespacethatwasusedinthetransactionlogfileisnowre-usablebynewtransactions. 

Sincethisspaceisreusedthereisnottheabilitytodoapointintimerecovery,thereforethemostrecentrestorepointwilleitherbethecompletebackuporthelatestdifferentialbackupthatwascompleted. 

Also,sincethespaceinthetransactionlogcanbereused,thetransactionlogwillnotgrowforeveraswasmentionedinthe"

∙Yourdataisnotcriticalandcaneasilyberecreated

∙Thedatabaseisonlyusedfortestordevelopment

∙Dataisstaticanddoesnotchange

∙Losinganyoralltransactionssincethelastbackupisnotaproblem

∙Dataisderivedandcaneasilyberecreated

HowtosetthesimplerecoverymodelusingT-SQL.

ALTERDATABASEAdventureWorksSETRECOVERYSIMPLE

SQLServerBulk-LoggedRecoveryModel

(SETRECOVERYBULK_LOGGED)

Bulk-logged"

recoverymodelsortofdoeswhatitimplies. 

WiththismodeltherearecertainbulkoperationssuchasBULKINSERT,CREATEINDEX,SELECTINTO,etc...thatarenotfullyloggedinthetransactionlogandthereforedonottakeasmuchspaceinthetransactionlog. 

Theadvantageofusingthe"

recoverymodelisthatyourtransactionlogswillnotgetthatlargeifyouaredoingbulkoperationsanditstillallowsyoutodopointintimerecoveryaslongasyourlasttransactionlogbackupdoesnotincludeabulkoperationasmentionedabove. 

IfnobulkoperationsarerunthisrecoverymodelworksthesameastheFullrecoverymodel. 

Onethingtonoteisthatifyouusethisrecoverymodelyoualsoneedtoissuetransactionlogbackupsotherwiseyourdatabasetransactionlogwillcontinuetogrow.

∙Dataiscritical,butyoudonotwanttologlargebulkoperations

∙Bulkoperationsaredoneatdifferenttimesversusnormalprocessing.

∙Youstillwanttobeabletorecovertoapointintime

Howtosetthebulk-loggedrecoverymodelusingT-SQL.

ALTERDATABASEAdventureWorksSETRECOVERYBULK_LOGGED

TypesofSQLServerBackups

SQLServeroffersmanyoptionsfor 

creatingbackups. 

Inaprevioustopic,RecoveryModels,wediscussedwhattypesofbackupscanbeperformedbasedontherecoverymodelofthedatabase. 

InthissectionwewilltalkabouteachofthesebackupoptionsandhowtoperformthesebackupsusingSSMSandT-SQL.

Thedifferenttypesofbackupsthatyoucancreateareasfollows:

∙Fullbackups

∙Filebackups

∙Filegroupbackups

∙Mirrorbackups

SQLServerFullBackups

ThemostcommontypesofSQLServerbackupsarecompleteorfullbackups,alsoknownasdatabasebackups. 

Thesebackupscreateacompletebackupofyourdatabaseaswellaspartofthetransactionlog,sothedatabasecanberecovered.Thisallowsforthesimplestformofdatabaserestoration,sinceallofthecontentsarecontainedinonebackup.

AfullbackupcanbecompletedeitherusingT-SQLorbyusingSSMS. 

Thefollowingexamplesshowyouhowtocreateafullbackup.

CreateafullbackupoftheAdventureWorksdatabasetoonediskfile

T-SQL

BACKUPDATABASEAdventureWorksTODISK='

C:

\AdventureWorks.BAK'

∙Rightclickonthedatabasename

∙SelectTasks>

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 视频讲堂

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1