我有一个31 GB的数据库,我从一个客户的项目中获得。我编写并将数据库保存在80GB的Win7 VM中。我得到了db文件并从中导入了数据库,发现该空间主要被一个表占用,有240,000个图像。我放弃了大部分行,现在有29,000MB可用。我无法执行许多功能,因为驱动器已达到最后几GB,并且仍有很多要修改的记录(我在几个表中更改数据类型,但是继续得到active_transaction错误)。它不会通过DBCC_SHRINKDATABASE(0)
或Tasks > Shrink > Database
或文件缩小。它似乎只是在我第一次得到它时缩小到数据库的大小。如何让它释放那个空间?如果可以,我可以将仍然存在的数据导出到较小的数据库,然后从中恢复吗?
运行SQL Server 2012和Management Studio。
谢谢,
贝
答案 0 :(得分:1)
You cannot dbcc shrinkdatabase
below the initial size setting. If the initial size of your database is set to 50GB -- the MDF will always be at least 50GB, even if 29GB is free/available.
If you do in fact have free space, you can lower the initial size setting to a more reasonable value - but if the MDF will simply auto-grow again, this is not advised, as it incurs a high overhead.
To do this you would use dbcc shrinkfile
.
Please see here for more information.
答案 1 :(得分:0)
This page describes how to make SQL server backups. https://msdn.microsoft.com/en-us/library/ms186865(v=sql.110).aspx
If you haven't done so already, you will need to take a full backup before you can do a transaction log backup.