SQL Server 错误:主文件组已满

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2987614/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 06:28:23  来源:igfitidea点击:

SQL Server error: Primary file group is full

sqlsql-server

提问by Aximili

I have a very large table in my database and I am starting to get this error

我的数据库中有一个非常大的表,我开始收到此错误

Could not allocate a new page for database 'mydatabase' because of insufficient disk space in filegroup 'PRIMARY'. Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.

由于文件组“PRIMARY”中的磁盘空间不足,无法为数据库“mydatabase”分配新页。通过删除文件组中的对象、向文件组添加其他文件或为文件组中的现有文件设置自动增长来创建必要的空间。

How do you fix this error? I don't understand the suggestions there.

你如何解决这个错误?我不明白那里的建议。

采纳答案by codingbadger

There isn't really much to add - it pretty much tells you what you need to do in the error message.

没有什么要添加的 - 它几乎告诉您在错误消息中需要做什么。

Each object (Table, SP, Index etc) you create in SQL is created on a filegroup. The default filegroup is PRIMARY. It is common to create multiple filegroups that span over many disks. For instance you could have a filegroup named INDEXES to store all of your Indexes. Or if you have one very large table you could move this on to a different filegroup.

您在 SQL 中创建的每个对象(表、SP、索引等)都是在文件组上创建的。默认文件组是 PRIMARY。创建跨越多个磁盘的多个文件组是很常见的。例如,您可以有一个名为 INDEXES 的文件组来存储所有索引。或者,如果您有一个非常大的表,您可以将其移至不同的文件组。

You can allocate space to a filegroup, say 2GB. If Auto Grow is not enabled once the data in the filegroup reaches 2GB SQL Server cannot create any more objects. This will also occur is the disk that the filegroup resides on runs out of space.

您可以为文件组分配空间,例如 2GB。如果在文件组中的数据达到 2GB 时未启用自动增长,则 SQL Server 将无法创建更多对象。如果文件组所在的磁盘空间不足,也会发生这种情况。

I'm not really sure what else to add - as I said previously, the error message pretty much tells you what is required.

我不确定还要添加什么 - 正如我之前所说,错误消息几乎告诉您需要什么。

回答by tomRedox

If you're using SQL Express you may be hitting the maximum database size limit (or more accurately the filegroup size limit) which is 4GB for versions up to 2005, 10GB for SQL Express 2008 onwards. That size limit excludes the log file.

如果您使用 SQL Express,您可能会达到最大数据库大小限制(或更准确地说是文件组大小限制),2005 及以下版本为 4GB,SQL Express 2008 及以上版本为 10GB。该大小限制不包括日志文件。

回答by Anoj V Nair

If you are using client tools (MSDE) then the data in the filegroup reaches 2GB, SQL Server cannot create any more objects.

如果使用客户端工具 (MSDE),则文件组中的数据达到 2GB,SQL Server 无法创建更多对象。

回答by Harendra

Use DBCC shrinkfile statement to shrink file...

使用 DBCC shrinkfile 语句来收缩文件...

USE databasename ;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE databasename 
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (databasename_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE databasename 
SET RECOVERY FULL;
GO