首页 > 数据库技术 > 详细

BACKUP and RESTORE 备份还原数据库

时间:2014-03-26 09:44:51      阅读:480      评论:0      收藏:0      [点我收藏+]

you will want to make certain that if you take a backup of master on a server in your environment that you aren’t interfering with any existing backup plan:

BACKUP DATABASE [master] TO  DISK = N‘C:\SQL\Backups\master.bak‘

Next we will create a test login as part of our practice run:

USE [master]
 GO
 CREATE LOGIN [master_restore_test]
 WITH PASSWORD=N‘test‘,
 DEFAULT_DATABASE=[master],
 CHECK_EXPIRATION=OFF,
 CHECK_POLICY=OFF

Just for fun, we will create a new database as well:

CREATE DATABASE [restore_test]

Since the login and database were created after the backup they won’t be there after the restore is complete.

 RESTORE DATABASE master FROM DISK = ‘C:\SQL\Backups\master.bak‘ WITH REPLACE
1
2
3
4
CREATE DATABASE [restore_test] ON
( FILENAME = N‘C:\SQL\Data\restore_test.mdf‘ ),
( FILENAME = N‘C:\SQL\Logs\restore_test_log.ldf‘ )
FOR ATTACH

BACKUP and RESTORE 备份还原数据库,布布扣,bubuko.com

BACKUP and RESTORE 备份还原数据库

原文:http://www.cnblogs.com/happy-Chen/p/3622611.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!