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数据库可能包含多个数据文件(一个主文件和多个辅助文件)和事务日志文件。 在开始移动数据库之前,我们应该收集有关现有文件及其位置的信息。