《MYSQL數(shù)據(jù)庫(kù)mssql數(shù)據(jù)庫(kù)備份與恢復(fù)實(shí)例》要點(diǎn):
本文介紹了MYSQL數(shù)據(jù)庫(kù)mssql數(shù)據(jù)庫(kù)備份與恢復(fù)實(shí)例,希望對(duì)您有用。如果有疑問,可以聯(lián)系我們。
導(dǎo)讀:環(huán)境:os:windows 2003db:mssql 2008--備份sql數(shù)據(jù)庫(kù)--------1,完整備份hxl數(shù)據(jù)庫(kù)
backup database [hxl] to disk = nd:mssql_bakhx...
MYSQL學(xué)習(xí)環(huán)境:
os:windows 2003
db:mssql 2008
?
--備份sql數(shù)據(jù)庫(kù)--------
1,完整備份hxl數(shù)據(jù)庫(kù)
?
backup database [hxl] to? disk = n'd:mssql_bakhxl_bak20121210.bak' with noformat, noinit,? name = n'hxl-完整 數(shù)據(jù)庫(kù) 備份', skip, norewind, nounload,? stats = 10
go
MYSQL學(xué)習(xí)2,差異備份hxl
?
backup database [hxl] to? disk = n'd:mssql_bakhxl_bak20121210.bak' with? differential , noformat, noinit,? name = n'hxl-差異 數(shù)據(jù)庫(kù) 備份', skip, norewind, nounload,? stats = 10
go
MYSQL學(xué)習(xí)3,腳本備份所有的數(shù)據(jù)庫(kù)
?
--sql備份所有數(shù)據(jù)庫(kù)腳本
declare @currentdatabasename nvarchar(100)
declare @currentbackfolder nvarchar(200)
declare @currentbackstring nvarchar(2000)
set @currentbackfolder='d:mssql_bak'--這里是備份的目錄,所有數(shù)據(jù)庫(kù)都備份到這個(gè)目錄
--查詢所有數(shù)據(jù)庫(kù)名稱
--select * from?? master..sysdatabases
declare tb cursor local for select name from master..sysdatabases where name <>'tempdb';
open tb
fetch next from tb into @currentdatabasename
while @@fetch_status=0
begin
?--備份當(dāng)前查詢到的數(shù)據(jù)庫(kù)到指定目錄
?set @currentbackstring='
??? use [master]
??? backup database ['+@currentdatabasename+']? to disk = '''+ @currentbackfolder+''+@currentdatabasename+convert(varchar(50),getdate(),112)+'.bak'' with noformat, noinit,name='''+@currentdatabasename+'-完整 數(shù)據(jù)庫(kù) 備份'',skip, norewind, nounload;';
?print @currentbackstring;
?exec sp_executesql @currentbackstring;
print '備份數(shù)據(jù)庫(kù)'+@currentdatabasename +'完成';
fetch next from tb into @currentdatabasename
end
close tb
deallocate tb
print '備份所有數(shù)據(jù)庫(kù)完成'
?
MYSQL學(xué)習(xí)--還原sql數(shù)據(jù)庫(kù)------
1,恢復(fù)hxl數(shù)據(jù)庫(kù)
?
MYSQL學(xué)習(xí)use master;
drop database hxl;
MYSQL學(xué)習(xí)restore database [hxl] from? disk = n'd:mssql_bakhxl20121209.bak' with? file = 1,? move n'hxl_log' to n'd:program filesmicrosoft sql servermssql10_50.mssqlservermssqldatahxl_1.ldf',? norecovery,? nounload,? stats = 10
go
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/6448.html