将表移动到不包含任何索引的文件组

时间:2017-10-25 13:00:24

标签: sql-server

我在sql server数据库中创建了5个临时表和5个文件组。如何将5个临时表移动到创建的5个文件组。请注意,表没有任何聚簇索引或任何东西。它只有数据。目前,所有5个临时表都在PRIMARY文件组中。我需要

Staging1  to filegroup1
Staging2  to filegroup2
Staging3  to filegroup3
Staging4  to filegroup4
Staging5  to filegroup5

我尝试了以下但是给了我一个编译错误

USE XYZ
GO
ALTER TABLE [dbo].[staging1 ]  WITH MOVE TO filegroup1 ;
GO

1 个答案:

答案 0 :(得分:1)

只有两种方法可以做到这一点:

在表上创建聚簇索引,并将聚簇索引放在新文件组上,如下所示:

CREATE CLUSTERED INDEX CIX_staging1 ON staging1 (column1, column2, column3)

删除并重新创建新文件组

上的表

我建议创建聚簇索引,每个表都应该有一个。