如何将数据从一个ndf移动到另一个ndf文件。 。 。 。 。 。 [英] How to move the data from one ndf to another ndf file . . . . . .

查看:113
本文介绍了如何将数据从一个ndf移动到另一个ndf文件。 。 。 。 。 。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



两天前我参加了一次面试,他们问了一个问题,即



Q)我的数据库有两个ndf文件(SQL Server 2005数据库),现在我要删除

一个ndf文件。在此之前,显然我们需要将数据从一个ndf移动到

另一个ndf文件。



如何移动???



请建议我们。 。







Regard's,

Thrilok。

Dear All,

Two days back i have attended one interview, They asked one question that is,

Q) My database having two ndf files (SQL Server 2005 Database), now i want to delete
one ndf file. Before that obviously we need to move the data from one ndf to
another ndf file.

How to move???

Please suggest me guys . .



Regard's,
Thrilok.

推荐答案

正如您所说,您需要在删除之前将所有数据移动到另一个文件中。但是,在SQL Server中,您实际上不使用文件而是使用文件组。创建对象时,您可以定义数据所在的文件组,而不是文件。如果文件组中有多个文件,SQL Server会决定使用哪个文件。



话虽如此,在文件组之间移动数据的最简单方法是创建或者为要置空的文件组中的对象重新创建索引。很明显,在另一个文件组中重新创建索引会移动该索引,但诀窍是重新创建聚簇索引实际上会移动表数据。



这是记录在案的如何在将现有索引移动到不同的文件组 [ ^ ]



希望它有所帮助。
As you said, you need to move all the data into another file before deleting one. However, in SQL Server you don't actually play with files but filegroups. When an object is created you define the filegroup where the data goes, not the file. SQL Server makes the decision what file to use if there are multiple files within the file group.

Having that said, the easiest way to move data between filegroups is to create or re-create the indexes for the objects that reside in the filegroup you want to make empty. It's obvious that re-creating the index in another filegroup moves that index but the trick is that re-creating a clustered index actually moves the table data.

This is documented as how-to do in Move an Existing Index to a Different Filegroup[^]

Hope it helps.


这篇关于如何将数据从一个ndf移动到另一个ndf文件。 。 。 。 。 。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆