zoukankan      html  css  js  c++  java
  • SQL 还原数据库

    1. 查看 SQL Server 2000 中 Northwind 数据库文件的逻辑文件名(logical file name)和物理文件路径(operation system file name):

    use Nothwind
    go
    
    select name, filename, * from dbo.sysfiles
    
    name            filename
    --------------  ------------------------------------------------------------------
    Northwind       d:/program files/microsoft sql server/mssql$sqla/data/northwnd.mdf
    Northwind_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 master
    go
    
    restore database Northwind from disk = 'c:/Northwind.bak'


    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.mdf
    Northwind_log    d:/Program Files/Microsoft SQL Server/MSSQL$SQLA/data/northwnd.ldf


    转载:http://blog.csdn.net/fax5201314/article/details/38865151

  • 相关阅读:
    JZOJ 5947.初音未来(miku)
    JZOJ 2020.07.27【NOIP提高组】模拟
    Prufer序列 学习笔记
    JZOJ 5033. 【NOI2017模拟3.28】A
    c# Winform实现中国省份地图
    c# Custom Controls
    c#实现播放器的集中方式
    c# GDI+绘制不同字体的字符串
    比较好的博客和文章记录
    CSS设置元素居中的方法
  • 原文地址:https://www.cnblogs.com/JarviseZhou/p/4658849.html
Copyright © 2011-2022 走看看