DBCC 收缩文件给出错误
我正在尝试使用 DBCC SHRINKFILE(db_2.ldf)
缩小我的日志文件,这是日志文件的名称,
它每次都会给我错误:
8985,16 级,州 1,第 1 线 无法在 sys.database_files 中找到数据库 db 的文件“FIelD”。该文件不存在或已被删除。
你能建议我能做什么来解决它吗?
I am trying to shrink my log file using DBCC SHRINKFILE(db_2.ldf)
, which is the name for log file
It gives me error every time:
8985, Level 16, State 1, Line 1
Could not locate file 'FIelD' for database db in sys.database_files. The file either does not exist, or was dropped.
Can you please suggest what can I do to fix it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
文件名应该是逻辑文件名而不是物理文件名。在“文件”选项卡上的“数据库属性”中查找您尝试收缩的文件的逻辑名称,并使用该名称。
The file name should be the logical file name and not the physical file name. Look in the Database properties, on the Files tab for the Logical Name of the file you are trying to shrink, and use that name.
您是否在包含您要收缩的日志的数据库上下文中运行它?在运行 DBCC 命令之前确保您有正确的
USE
语句Are you running it in the context of the database that has the log you are trying to shrink? Make sure you have the right
USE
statement before running DBCC commands这里有同样的问题,解决方案是重命名逻辑文件以匹配数据库名称。下面是一个查询逻辑文件名然后执行文件重命名的示例:
两次更改的原因是每个数据库通常有两个文件关联,即数据文件和日志文件。
Had the same problem over here, the solution was to rename the logical file to match the database name. Below is an example to query the logical file names and then perform a rename of the files:
The reason for the two alters is that there are usually two files associated with each database, the data file and the log file.
下面的命令有效。但我没有看到它减小尺寸。我在运行之后和运行之前看到相同的大小。你能告诉我我可能错过了什么吗?
谢谢
The command below worked. However I don't see it reducing the size. I see the same size after and before running it. Can you please let me know what I might have missed.
Thanks
从 SQL 管理工作室
右键单击数据库名称,任务,收缩,数据库
Ctrl+Shift+N(或新查询窗口的脚本操作)
生成以下内容:
USE [DataBaseName]
去
DBCC SHRINKDATABASE(N'DataBaseName' )
去
From SQL Management Studio
Right click the database name, Tasks, Shrink, Database
Ctrl+Shift+N (or Script Action to New Query Window)
Generates the following:
USE [DataBaseName]
GO
DBCC SHRINKDATABASE(N'DataBaseName' )
GO