用 SQL 语句还原数据库(with move 选项用法)
来源:互联网 发布:json.parse 源码 编辑:程序博客网 时间:2024/05/21 11:01
1. 查看 SQL Server 2000 中 Northwind 数据库文件的逻辑文件名(logical file name)和物理文件路径(operation system file name):
use Nothwindgoselect name, filename, * from dbo.sysfiles
name filename-------------- ------------------------------------------------------------------Northwind d:/program files/microsoft sql server/mssql$sqla/data/northwnd.mdfNorthwind_log d:/program files/microsoft sql server/mssql$sqla/data/northwnd.ldf
2. 备份 SQL Server 2000.Northwind 数据库
backup database Northwind to disk = 'c:/Northwind.bak'
3. 在 SQL Server 2005 Instance 中还原 Northwind 数据库。
use mastergorestore database Northwind from disk = 'c:/Northwind.bak'
用普通方式 restore 的话,SQL Server 会报出一大堆的错误信息。
Msg 3634, Level 16, State 1, Line 1The operating system returned the error '32(error not found)'while attempting 'RestoreContainer::ValidateTargetForCreation'on 'd:/Program Files/Microsoft SQL Server/MSSQL$SQLA/data/northwnd.mdf'.Msg 3156, Level 16, State 8, Line 1File 'Northwind' cannot be restored to'd:/Program Files/Microsoft SQL Server/MSSQL$SQLA/data/northwnd.mdf'.Use WITH MOVE to identify a valid location for the file.Msg 3634, Level 16, State 1, Line 1The operating system returned the error '32(error not found)'while attempting 'RestoreContainer::ValidateTargetForCreation'on 'd:/Program Files/Microsoft SQL Server/MSSQL$SQLA/data/northwnd.ldf'.Msg 3156, Level 16, State 8, Line 1File 'Northwind_log' cannot be restored to'd:/Program Files/Microsoft SQL Server/MSSQL$SQLA/data/northwnd.ldf'.Use WITH MOVE to identify a valid location for the file.Msg 3119, Level 16, State 1, Line 1Problems were identified while planning for the RESTORE statement. Previous messages provide details.Msg 3013, Level 16, State 1, Line 1RESTORE DATABASE is terminating abnormally.
4. 在 SQL Server 2005 中还原 Northwind 数据库正确方法:restore with move。
SQL Server 2005 中数据文件所在目录为:d:/microsoft sql server/mssql.1/mssql/data/
restore database Northwind from disk = 'c:/Northwind.bak'with move 'Northwind' to 'd:/microsoft sql server/mssql.1/mssql/data/Northwind.mdf' ,move 'Northwind_log' to 'd:/microsoft sql server/mssql.1/mssql/data/Northwind.ldf'
Northwind 数据库在 SQL Server 2005 中顺利还原。
注意,在 SQL Server 2005 中还原 Northwind 的时候,并不需要首先创建一个同名的 Northwind 数据库,而是直接进行 restore。
另外的一个问题是,如果客户给你一个 Northwind.bak 备份文件,让你在自己的机器上 restore。那么如何来确定 with move 中的逻辑文件名呢?一个方法是向客户咨询获取,二是使用 SQL Server restore filelistonly 来查看。
5. 使用 SQL Server restore filelistonly 命令来查看逻辑文件名
从 SQL Server restore filelistonly 命令结果中可以获取很多信息,下面仅列出 LogicalName and PhysicalName。
restore filelistonly from disk='c:/Northwind.bak'
LogicalName PhysicalName--------------- ------------------------------------------------------------------Northwind d:/Program Files/Microsoft SQL Server/MSSQL$SQLA/data/northwnd.mdfNorthwind_log d:/Program Files/Microsoft SQL Server/MSSQL$SQLA/data/northwnd.ldf
本文由 www.sqlstudy.com 原创
0 0
- 用 SQL 语句还原数据库(with move 选项用法)
- 用 SQL 语句还原数据库(with move 选项用法)
- 用 SQL 语句还原数据库(with move 选项用法)
- 转载-用 SQL 语句还原数据库(with move 选项用法)
- SQL 语句还原SQL Server数据库(with move 选项用 )
- 数据库还原-请使用 WITH MOVE 选项来标识该文件的有效位置
- SQL Server数据库备份文件还原错误,提示设备激活错误......请使用with move选项来标识该文件的有效位置
- sql server 2005 中还原 Northwind 数据库正确方法:restor with move
- SQL数据库还原语句
- SQL语句还原数据库
- T-SQL语句还原数据库
- SQL语句附加还原数据库
- SQL语句附加还原数据库
- sql语句还原数据库备份
- SQL数据库备份还原语句
- sql语句还原db2数据库
- sql语句备份还原数据库
- SQL语句 with as 用法
- MapReduce与自然语言处理
- 高效遍历文件系统
- 为什么 Android 手机总是越用越慢?
- Tomcat6 配置cgi openlayers跨域访问
- 无法定位程序输入点RegSetKeyValueA 于动态链接库 ADVAPI32.dll上 解决方案
- 用 SQL 语句还原数据库(with move 选项用法)
- 软件知识分类法
- jsp概述
- Core Graphics 学习笔记 之 Image Drawing(二)
- UESTC889&&uvalive6623 Battle for Silver(dfs)
- Linux下无需输入密码自动登陆ssh服务器方法
- 中文截取无乱码
- javascript 学习笔记(0)
- 单例模式