【解決方法】因為 'PRIMARY' 檔案組已滿。請刪除不需要的檔案、刪除檔案組中的物件、將其他檔案新增到檔案組或為檔案組中的現有檔案啟用自動增長,以便增加可用磁碟空間
阿新 • • 發佈:2020-09-12
文章目錄
平臺
- sqlserver 2012
問題描述
正常執行的生產系統,今天下午突然發現不能使用的情況。看日誌,發現以下描述:
System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. —> System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details. —> System.Data.SqlClient.SqlException: 無法為資料庫 ‘bidagen2’ 中的物件 ‘dbo.OperationLog’.‘PK_dbo.OperationLog’ 分配空間,因為 ‘PRIMARY’ 檔案組已滿。請刪除不需要的檔案、刪除檔案組中的物件、將其他檔案新增到檔案組或為檔案組中的現有檔案啟用自動增長,以便增加可用磁碟空間。
定位問題,自增的主鍵,沒有儲存空間了。
解決問題
1、檢視資料庫資料檔案存放路徑
use master--你的資料庫名稱
go
--看看你的primary組裡的檔案
select ds.name,
df.physical_name, --主檔案組的物理檔案的路徑
--開啟我的電腦,檢視檔案所在盤,是否磁碟已滿
df.is_percent_growth, --是否自動增長
df.growth --增長多少
from sys.data_spaces ds
inner join sys.database_files df
on ds.data_space_id = df.data_space_id
where ds.name = 'primary'
執行以上程式碼會出現類似以下的結果:
2、檢視存放路徑的盤是否已滿
針對我的情況,C盤還有很多的空間,所以應該是資料庫設定的問題。
如果已經滿了,那就需要清除一些檔案了。
3、更改資料庫設定
a、使用 MSSqlserver Management Studio 連線資料庫
b、在需要更改的資料庫上點選右鍵,選擇屬性
c、依次選擇檔案->Primary組的自動增長設定->最大檔案大小設定為無限制
具體可以參考以下操作截圖。
至此,該問題已解決。