SQL Service Database BACKUP & RESTORE
USE master;
ALTER DATABASE AdventureWorks2012 SET RECOVERY FULL;
GO
-- Back up the AdventureWorks2012 database to new media set (backup set 1).
BACKUP DATABASE AdventureWorks2012
TO DISK = 'Z:\SQLServerBackups\AdventureWorks2012FullRM.bak'
WITH FORMAT;
GO
--Create a routine log backup (backup set 2).
BACKUP LOG AdventureWorks2012 TO DISK = 'Z:\SQLServerBackups\AdventureWorks2012FullRM.bak';
GO
2. 完整数据库还原(完整恢复模式)
USE master;
--Create tail-log backup.
BACKUP LOG AdventureWorks2012
TO DISK = 'Z:\SQLServerBackups\AdventureWorksFullRM.bak'
WITH NORECOVERY;
GO
--Restore the full database backup (from backup set 1).
RESTORE DATABASE AdventureWorks2012
FROM DISK = 'Z:\SQLServerBackups\AdventureWorksFullRM.bak'
WITH FILE=1,
NORECOVERY; --Restore the regular log backup (from backup set 2).
RESTORE LOG AdventureWorks2012
FROM DISK = 'Z:\SQLServerBackups\AdventureWorksFullRM.bak'
WITH FILE=2,
NORECOVERY; --Restore the tail-log backup (from backup set 3).
RESTORE LOG AdventureWorks2012
FROM DISK = 'Z:\SQLServerBackups\AdventureWorksFullRM.bak'
WITH FILE=3,
NORECOVERY;
GO
--recover the database:
RESTORE DATABASE AdventureWorks2012 WITH RECOVERY;
GO
3. 根据数据库生成相应的SQL 脚本
SELECT Name , N'ALTER DATABASE '+Name+' SET RECOVERY FULL;
GO
BACKUP DATABASE '+Name+' TO DISK = ''C:\Databases_Backup\'+Name+'_FullRM.bak'' WITH FORMAT;
GO
BACKUP LOG '+Name+' TO DISK = ''C:\Databases_Backup\'+Name+'_FullRM.bak'';
GO' as [BACKUP SQL] , N'RESTORE DATABASE '+Name+'
FROM DISK = ''C:\Databases_Backup\'+Name+'_FullRM.bak''
WITH FILE=1,
NORECOVERY; RESTORE LOG AdventureWorks2012
FROM DISK = ''C:\Databases_Backup\'+Name+'_FullRM.bak''
WITH FILE=2,
NORECOVERY; RESTORE LOG AdventureWorks2012
FROM DISK = ''C:\Databases_Backup\'+Name+'_FullRM.bak''
WITH FILE=3,
NORECOVERY;
GO
RESTORE DATABASE '+Name+' WITH RECOVERY;
GO' as [RESTORE SQL] FROM Master..SysDatabases ORDER BY Name
SQL Service Database BACKUP & RESTORE的更多相关文章
- SQL Server Database Backup and Restore in C#
SQL Server Database Backup and Restore in C# Syed Noman Ali Shah, 7 Feb 201 ...
- MySQL 5.7 Reference Manual :: 4.5.4 mysqldump & mysql — Database Backup & Restore Program
MySQL :: MySQL 5.7 Reference Manual :: 4.5.4 mysqldump — A Database Backup Programhttps://dev.mysql. ...
- 转 RMAN: RAC Backup, Restore and Recovery using RMAN
PURPOSE The purpose of this document is to give a quick guide for using RMAN on RAC databases. We wi ...
- 转载:Restore SQL Server database and overwrite existing database
转载自:https://www.mssqltips.com/sqlservertutorial/121/restore-sql-server-database-and-overwrite-existi ...
- [转]Configure Network Drive Visible for SQL Server During Backup and Restore Using SSMS
本文转自:https://mytechmantra.com/LearnSQLServer/Configure-Network-Drive-Visible-for-SQL-Server-During-B ...
- SQL Server 2014 Backup Encryption
转载自: Microsoft MVP Award Program Blog 来源:Microsoft MVP Award Program Blog 的博客:https://blogs.msdn.mic ...
- P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1
P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1 May ...
- Sql Service 的job作业新建过程
第一步:打开sql service 找到 SQL SERVER Agent 下的 jobs 如图: 注:如果没有找到,请查看你安装sql service 的版本 通过 select @@VERSI ...
- SQL UNION 和 UNION ALL 操作符\SQL SELECT INTO 语句\SQL CREATE DATABASE 语句
SQL UNION 操作符 UNION 操作符用于合并两个或多个 SELECT 语句的结果集. 请注意,UNION 内部的 SELECT 语句必须拥有相同数量的列.列也必须拥有相似的数据类型.同时,每 ...
随机推荐
- 关于VS2010中一打字,换行,拖控件便出现卡死的问题的解决方案
大家好,这是我第一篇博文. 最近一个月都是静静的观看,想发帖子很久了. 最近实习完刚换了份工作,入职之后啊先是装了一堆软件.然后,便出现问题,就是VS2010上码字和切换页面的时候会卡.开始的时候每次 ...
- Facebook 和 Google 如何激发工程师的创造力
原文链接:http://kb.cnblogs.com/page/193450/ 今天终于“朝圣”了两个伟大的公司——Facebook和Google,对创造力和驱动力的来源有了更多的理解,尤其是对于典型 ...
- O(V*n)的多重背包问题
多重背包问题: 有n件物品,第i件价值为wi,质量为vi,有c1件,问,给定容量V,求获得的最大价值. 朴素做法: 视为0,1,2,...,k种物品的分组背包 [每组只能选一个] f[i][j]=Ma ...
- Beginners Guide To Learn Dimension Reduction Techniques
Beginners Guide To Learn Dimension Reduction Techniques Introduction Brevity is the soul of wit This ...
- C语言预处理命令
1.#error Directive (C/C++) The #error directive emits a user-specified error message at compile time ...
- 【ASP.Net MVC】AspNet Mvc一些总结
AspNet Mvc一些总结 RestaurantReview.cs using System; using System.Collections.Generic; using System.Comp ...
- Gitlab 7.12 发布 SAML支持及其他更多功能
官方文章:https://about.gitlab.com/2015/06/22/gitlab-7-12-released/ CSDN翻译文章:http://geek.csdn.net/news/de ...
- KMP高质量代码实现详解
KMP算法 对于KMP算法我分为两个部分说明,第一部分是算法部分,介绍KMP算法的算法思想:第二部分是实现部分,介绍一种厉害的实现代码以及代码注释.当然了由于本文主要介绍怎么实现故而先分析实现,对KM ...
- java 分割split
1.如果用“.”作为分隔的话,必须是如下写法:String.split("\\."),这样才能正确的分隔开,不能用String.split(".");2.如果用 ...
- HDU 1142 A Walk Through the Forest(SPFA+记忆化搜索DFS)
题目链接 题意 :办公室编号为1,家编号为2,问从办公室到家有多少条路径,当然路径要短,从A走到B的条件是,A到家比B到家要远,所以可以从A走向B . 思路 : 先以终点为起点求最短路,然后记忆化搜索 ...