感谢您使用微软产品。希望下面的信息对您有帮助:The target size for data and log files as calculated by DBCC SHRINKDATABASE can never be smaller than the minimum size of a file. The minimum size of a file is the size specified when the file was originally created, or the last explicit size set with a file size changing operation such as ALTER DATABASE with the MODIFY FILE option or DBCC SHRINKFILE.具体您可以参考下面的网站:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_dbcc_3pd1.asp本帖子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。

解决方案 »

  1.   

    哥们,是不是下面这段话Assume a database named mydb with two data files and two log files. Both data and log files are 10 MB in size. The first data file contains 6 MB of data.For each file, SQL Server calculates a target size, which is the size to which the file is to be shrunk. When DBCC SHRINKDATABASE is specified with target_percent, SQL Server calculates target size to be the target_percent amount of space free in the file after shrinking. For example, if you specify a target_percent of 25 for shrinking mydb. SQL Server calculates the target size for this file to be 8 MB (6 MB of data plus 2 MB of free space). Therefore, SQL Server moves any data from the last 2 MB of the data file to any free space in the first 8 MB of the data file and then shrinks the file.
    注意,你看错了,msdn上的意思是
    假设原database的大小为10mb,
    压缩百分比为25,这里的25是相对压缩后的数据库大小而言的
    shrinkdatabase语句的执行效果是这样的:原来数据库大小=压缩后的数据库大小+压缩后的数据库大小*压缩百分比!!!
    并且,压缩后的数据库大小不能比
    数据库中的数据所占的空间小,确切的将不是压缩,而是将空白空间
    移去!!!并且压缩后的数据库大小也不能比数据库的初始大小更小。所以10mb的数据库,压缩百分比为25,剩下的是8mb,其中6mb的data,2mb的freespace
    而且数据库文件分为data和log,
    log文件的压缩情况略有不同,msdn上也有介绍。