我们有两个文件组 PRIMARY 和 SECONDARY。目标是将 SECONDARY 分区与 PRIMARY 合并。
在运行以下命令时,出现以下错误:
DBCC SHRINKFILE (N'ABC_Secondary', EMPTYFILE);
GO
DBCC SHRINKFILE: Heap page 3:54888929 could not be moved.
Msg 2555, Level 16, State 1, Line 7
Cannot move all contents of file "ABC_Secondary" to other places to complete the emptyfile operation.
The statement has been terminated.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Msg 1105, Level 17, State 2, Line 7
Could not allocate space for object 'dbo.Contact' in database 'ABC' because the 'SECONDARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.
完成时间:2021-01-23T10:51:18.9766221-07:00
请参阅下面的数据库使用情况:
DbName FileName type_desc CurrentSizeMB FreeSpaceMB
ABC ABC ROWS 1791360.000000 357524.062500
ABC ABC_log LOG 904.000000 858.640625
ABC ABC_Secondary ROWS 483274.000000 437450.437500
读取数据库文件和文件组。
要将文件中的所有数据移至同一文件组中的其他文件,请使用
DBCC SHRINKFILE (N'SomeFile', EMPTYFILE);
要将数据从文件组移动到其他文件组,请针对新文件组重建它,使用 ALTER TABLE REBUILD 堆,或删除聚集索引并在新文件组上重新创建它。