時間:2015-06-28 00:00:00 來源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評論(0)
go???
--創(chuàng)建數(shù)據(jù)庫?
create? database? test?
go?
--打開創(chuàng)建的數(shù)據(jù)?
use? test?
go???
--創(chuàng)建測試表?
create? table? t(a? int)???
--切換回master數(shù)據(jù)庫?
use? master?
go?
--插入數(shù)據(jù)1?
insert? into? test..t? select? 1?
go???
--然后進(jìn)行一次完整備份?
backup? database? test? to? disk='c:\test.bak'?
go??
--插入數(shù)據(jù)2?
insert? into? test..t? select? 2?
go?
--再進(jìn)行一次完整備份?
backup? database? test? to? disk='c:\test.bak'?
go?
--插入3,4?
insert? into? test..t? select? 3?
insert? into? test..t? select? 4?
go?
--差異備份:?
backup? database? test? to? disk='c:\test.bak'? with? differential??
--刪除數(shù)據(jù)庫?
drop? database? test??
--還原數(shù)據(jù)庫和差異數(shù)據(jù)庫備份?
--還原完整備份?
restore? database? test? from? disk='c:\test.bak'? with? file=2,norecovery?
--還原差異備份的內(nèi)容?
restore? database? test? from? disk='c:\test.bak'? with? file=3,recovery???
--顯示恢復(fù)后的數(shù)據(jù)?
select? *? from? test..t?
---------------------------------------------------------------?
都已經(jīng)說的好明白了,怎么可能會不行呢??
前段時間我就做過類似程序的!?
必須說明的是:在恢復(fù)差異備份時,必須恢復(fù)最后一次的完整備份?。。ㄇ杏洠?
而且下面的兩個語句必須同時執(zhí)行,即放在一個事務(wù)中。???
restore? database? test? from? disk='c:\test.bak'? with? file=離你要恢復(fù)的差異備份最近一次的完整備份號,norecovery???
restore? database? test? from? disk='c:\test.bak'? with? file=你要還原的差異備份號,recovery???
具體的備份號可以從下面得到:(你可以認(rèn)真研究一下backupfile,backupset,backmediaset,backupmediafamily幾個表,可以發(fā)現(xiàn)規(guī)律)?
select? backup_start_date? as? 備份時間,position? as? 備份號,?
case? type??? when? 'D'? then? '完整備份'? when? 'I'? then? '差異備份'? end? as? 備份類型???
from? msdb..backupset? where? database_name='test'???
and? media_set_id? in???
(select? distinct? media_set_id? from? msdb..backupmediafamily? where? physical_device_name='c:\test.bak')?
order? by? position?
如果還不行的話,可以給我留言~?
---------------------------------------------------------------??
---執(zhí)行下面的序列:??
create? database? test?
go?
use? test?
go?
create? table? test..t(a? int)??
insert? test..t? select? 1?
backup? database? test? to? disk='c:\test.bak'?
insert? test..t? select? 2?
backup? database? test? to? disk='c:\test.bak'?
insert? test..t? select? 3?
insert? test..t? select? 4?
backup? database? test? to? disk='c:\test.bak'? with? differential?
delete? test..t?
go??
--下面開始恢復(fù):??
restore? database? test? from? disk='c:\test.bak'? with? file=2,norecovery? --對應(yīng)你最后一次的完整備份
restore? database? test? from? disk='c:\test.bak'? with? file=3? --對應(yīng)你要還原的差異備份??
go??
select? *? from? test
關(guān)鍵詞標(biāo)簽:問題,恢復(fù),備份,差異,
相關(guān)閱讀
熱門文章 淺談JSP JDBC來連接SQL Server 2005的方法 SqlServer2005對現(xiàn)有數(shù)據(jù)進(jìn)行分區(qū)具體步驟 sql server系統(tǒng)表損壞的解決方法 MS-SQL2005服務(wù)器登錄名、角色、數(shù)據(jù)庫用戶、角色、架構(gòu)的關(guān)系
人氣排行 配置和注冊O(shè)DBC數(shù)據(jù)源-odbc數(shù)據(jù)源配置教程 如何遠(yuǎn)程備份(還原)SQL2000數(shù)據(jù)庫 SQL2000數(shù)據(jù)庫遠(yuǎn)程導(dǎo)入(導(dǎo)出)數(shù)據(jù) SQL2000和SQL2005數(shù)據(jù)庫服務(wù)端口查看或修改 修改Sql Server唯一約束教程 SQL Server 2005降級到2000的正確操作步驟 sql server系統(tǒng)表損壞的解決方法 淺談JSP JDBC來連接SQL Server 2005的方法