backup/restore database
Posted neoo9901
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了backup/restore database相关的知识,希望对你有一定的参考价值。
backup database t-sql
1 BACKUP DATABASE [store] TO DISK = N‘D:sql_backstore_backup_2019_01_30_102306_4000360.bak‘ WITH NOFORMAT, NOINIT, NAME = N‘store_backup_2019_01_30_102306_4000360‘, SKIP, REWIND, NOUNLOAD, STATS = 10 2 GO 3 declare @backupSetId as int 4 select @backupSetId = position from msdb..backupset where database_name=N‘store‘ and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N‘store‘ ) 5 if @backupSetId is null begin raiserror(N‘验证失败。找不到数据库“store”的备份信息。‘, 16, 1) end 6 RESTORE VERIFYONLY FROM DISK = N‘D:sql_backstore_backup_2019_01_30_102306_4000360.bak‘ WITH FILE = @backupSetId, NOUNLOAD, NOREWIND
restore database
1 USE [master] 2 BACKUP LOG [store] TO DISK = N‘D:sql_backstore_LogBackup_2019-01-30_10-44-29.bak‘ WITH NOFORMAT, NOINIT, NAME = N‘store_LogBackup_2019-01-30_10-44-29‘, NOSKIP, NOREWIND, NOUNLOAD, NORECOVERY , STATS = 5 3 RESTORE DATABASE [store] FROM DISK = N‘E:mssqlstore.bak‘ WITH FILE = 1, MOVE N‘store‘ TO N‘D:installstore.mdf‘, MOVE N‘store_log‘ TO N‘D:sql_datastore_log.LDF‘, NOUNLOAD, STATS = 5 4 5 GO
以上是关于backup/restore database的主要内容,如果未能解决你的问题,请参考以下文章