sql数据库分离附加_使用分离和附加方法移动SQL数据库

本文详细介绍了如何使用分离和附加方法来移动SQL数据库,包括收集数据库信息、分离数据库、移动文件以及从新位置附加数据库。此外,还讨论了这种方法的局限性,如不能用于系统数据库和低版本SQL Server。
摘要由CSDN通过智能技术生成

sql数据库分离附加

This article explores the process of moving a SQL database using the detach and attach method.

本文探讨了使用detach and Attach方法移动SQL数据库的过程。

介绍 (Introduction)

Sometimes we require moving data files (primary, secondary) and log files to different drives and servers. Some of the cases where you might require moving database files are as follows:

有时我们需要将数据文件(主要,辅助)和日志文件移动到不同的驱动器和服务器。 在某些情况下,您可能需要移动数据库文件,如下所示:

  • Lack of free space: Suppose you have a disk having less free space. You might move a few files from one drive to another so that you can resolve space issues and database files can grow 可用空间不足 :假设您的磁盘上的可用空间较少。 您可以将一些文件从一个驱动器移动到另一个驱动器,以便解决空间问题,并且数据库文件可以增长
  • Database Management: Sometimes, we require segregating data files and log files into separate drives 数据库管理:有时,我们需要将数据文件和日志文件分离到单独的驱动器中
  • Database movement: We might require moving a database to separate server, and in this case, you do not require a database on the source instance 数据库移动:我们可能需要将数据库移动到单独的服务器,在这种情况下,您不需要源实例上的数据库
  • Database upgrade: We can also upgrade a database to a higher version by moving the data and log files to a higher version instance
  • 数据库升级:我们还可以通过将数据和日志文件移动到更高版本的实例来将数据库升级到更高的版本

There are multiple ways to move a database such as backup & restore, take the database offline. In this article, we will discuss the detach and attach method to move a SQL database.

有多种移动数据库的方法,例如备份和还原,使数据库脱机。 在本文中,我们将讨论移动SQL数据库的分离和附加方法。

使用分离和附加方法移动数据库 (Move a database using detach and attach method)

We can use the following steps for moving a database using detach ad attach method.

我们可以按照以下步骤使用分离广告附加方法移动数据库。

收集SQL数据库信息 (Collecting SQL Database information)

Planning is necessary before we move a database. As you know, a SQL database might contain multiple data files(one primary and multiple secondary) and transaction log files. We should collect the information about existing files, their locations before start moving a database.

在移动数据库之前,必须进行计划。 如您所知,SQL数据库可能包含多个数据文件(一个主文件和多个辅助文件)和事务日志文件。 在开始移动数据库之前,我们应该收集有关现有文件及其位置的信息。

  • Run the sp_helpfile command in current database security context and save information separately:

    在当前数据库安全上下文中运行sp_helpfile命令,并分别保存信息:

    Use SQLShack
    go
    Exec sp_helpfile
    

    SQL Database information

  • We can also us

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值