Ms Sql Server 基本管理脚本(2)

本文涉及的产品
云数据库 RDS SQL Server,基础系列 2核4GB
简介:

 /*

 *创建备份设备
 */
--添加备份设备
sp_addumpdevice 'disk', 'northwind_backup', 'f:\northwd.bak'
 
--删除备份设备
sp_dropdevice 'northwind_backup'
 
--查看备份设备
sp_helpdevice
 
/*
 *修改数据库还原模型
 */
--完全还原
alter database northwind 
set recovery full
 
--简单还原
alter database northwind
set recovery simple
 
--大容量日志还原
alter database northwind
set recovery bulk_logged
 
/*
 *完全备份
 */
--备份
backup database northwind to northwind_backup
--还原
restore database northwind from northwind_backup
 
/*
 *差异备份
 */
--备份
backup database northwind to northwind_backup
backup database northwind to northwind_backup
with differential
--还原
restore database northwind 
from northwind_backup with norecovery
restore database northwind from northwind_backup
with file=2, recovery
 
/*
 *事务日志备份
 */
--备份
backup database northwind to northwind_backup
backup log northwind to northwind_backup
--还原
restore database northwind from northwind_backup with norecovery
restore log northwind from northwind_backup with norecovery
--还原到某个即时点
restore log northwind from northwind_backup with recovery, stopat 'Jue 14, 2006 12:00 AM'
 
/*
 *文件和文件组备份
 */
--备份:
backup database mydb file =‘mydbfile1’filegroup = ‘primary’to mydb_backup1
backup database mydb file =‘mydbfile2’filegroup = ‘primary’to mydb_backup2
backup database mydb file =‘mydbfile3’filegroup = ‘mygroup’to mydb_backup3
backup database mydb file =‘mydbfile4’filegroup = ‘mygroup’to mydb_backup4
--还原:
restore database mydb file =‘mydbfile1’filegroup = ‘primary’to mydb_backup1
restore database mydb file =‘mydbfile2’filegroup = ‘primary’to mydb_backup2
restore database mydb file =‘mydbfile3’filegroup = ‘mygroup’to mydb_backup3
restore database mydb file =‘mydbfile4’filegroup = ‘mygroup’to mydb_backup4
 




     本文转自andylhz 51CTO博客,原文链接:http://blog.51cto.com/andylhz2009/772462 ,如需转载请自行联系原作者

相关文章
|
7月前
|
SQL Oracle 关系型数据库
【YashanDB知识库】共享利用Python脚本解决Oracle的SQL脚本@@用法
【YashanDB知识库】共享利用Python脚本解决Oracle的SQL脚本@@用法
|
7月前
|
SQL Oracle 关系型数据库
【YashanDB知识库】共享利用Python脚本解决Oracle的SQL脚本@@用法
本文来自YashanDB官网,介绍如何处理Oracle客户端sql*plus中使用@@调用同级目录SQL脚本的场景。崖山数据库23.2.x.100已支持@@用法,但旧版本可通过Python脚本批量重写SQL文件,将@@替换为绝对路径。文章通过Oracle示例展示了具体用法,并提供Python脚本实现自动化处理,最后调整批处理脚本以适配YashanDB运行环境。
|
SQL 关系型数据库 MySQL
|
关系型数据库 MySQL 网络安全
5-10Can't connect to MySQL server on 'sh-cynosl-grp-fcs50xoa.sql.tencentcdb.com' (110)")
5-10Can't connect to MySQL server on 'sh-cynosl-grp-fcs50xoa.sql.tencentcdb.com' (110)")
|
11月前
|
SQL 关系型数据库 MySQL
mysql编写sql脚本:要求表没有主键,但是想查询没有相同值的时候才进行插入
mysql编写sql脚本:要求表没有主键,但是想查询没有相同值的时候才进行插入
116 0
|
存储 SQL Go
全网最长的sql server巡检脚本分享(1000行)
全网最长的sql server巡检脚本分享(1000行)
323 1
|
SQL 存储 Go
SQL Server一键巡检脚本分享
SQL Server一键巡检脚本分享
498 0
|
SQL 监控 安全
在Linux中,如何检测和防止SQL注入和跨站脚本(XSS)攻击?
在Linux中,如何检测和防止SQL注入和跨站脚本(XSS)攻击?
|
SQL 安全 Java
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client
1203 0
|
SQL 存储 Oracle
MySQL 项目中 SQL 脚本更新、升级方式,防止多次重复执行
MySQL 项目中 SQL 脚本更新、升级方式,防止多次重复执行
222 0