SQL Server 2008日志大小管理问题

发布于 2024-08-31 15:00:42 字数 643 浏览 6 评论 0原文

我试图缩小数据库的日志将恢复设置为简单,但无论我尝试什么,总是会出现错误。

USE 4_o5;
GO
ALTER DATABASE 4_o5
SET RECOVERY SIMPLE;
GO
DBCC SHRINKFILE (4_o5_log, 10);
GO

sp_helpfile 的输出表明日志文件位于(托管解决方案)下:

I:\dataroot\4_o5_log.LDF

请帮助我执行此操作,因为导入大量数据时日志文件变得很大,现在不再需要此信息,从那时起就有多个(很多)备份。

执行上述查询时,确切的错误消息是:

incorrect syntax near '4'.
RECOVERY is not a recognized SET option.
incorrect syntax near _5_log'.

我正在使用 Visual Studio 2010(还本地安装了 SQL Server Express,在提供商处正确安装了 SQL Server 2008(共享)),

非常感谢

I'm trying to shrink the log of a database AND set the recovery to simple, but always there is an error, whatever i try.

USE 4_o5;
GO
ALTER DATABASE 4_o5
SET RECOVERY SIMPLE;
GO
DBCC SHRINKFILE (4_o5_log, 10);
GO

the output of sp_helpfile says that log file is located under (hosted solution):

I:\dataroot\4_o5_log.LDF

please help me perform this operation as the log file got large when importing a lot of data and now this info is no longer needed, have multiple (lots of) backups since then.

the exact error message when performing the query above is:

incorrect syntax near '4'.
RECOVERY is not a recognized SET option.
incorrect syntax near _5_log'.

I am using Visual Studio 2010 (also have SQL Server Express installed locally, SQL Server 2008 proper installed at provider (shared))

thnx a lot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陌伤ぢ 2024-09-07 15:00:42

只需执行

USE [4_o5] --need brackets with this DB name, as marc_s commented
GO
DBCC SHRINKFILE (2, 10)

DBCC 也获取内部文件 ID 号,我就明白了在分离逻辑文件名和物理文件名时遇到问题...这让我假设您没有多个日志文件或 NDF 等,并且日志文件将始终为 2

但是,为什么 你还是想缩小吗?

要更改恢复模式:ALTER DATABASE [4_o5] SET RECOVERY SIMPLE

Just do

USE [4_o5] --need brackets with this DB name, as marc_s commented
GO
DBCC SHRINKFILE (2, 10)

DBCC also takes the internal file id number and I see you're having problems separating logical and physical file names... which leads me to assume you don't have multiple log files or NDFs etc and the log file will always be 2

However, why do you want to shrink anyway?

To change recovery model: ALTER DATABASE [4_o5] SET RECOVERY SIMPLE

影子是时光的心 2024-09-07 15:00:42

试试这个:

USE [4_o5];
GO
ALTER DATABASE [4_o5] SET RECOVERY SIMPLE;
GO
DBCC SHRINKFILE ([4_o5_log], 10);
GO

以数值开头的数据库名称有点不寻常 - 尝试将其放在方括号中。

更新:对于DBCC SHRINKFILE,您需要日志文件的逻辑名称 - 这是来自的name属性sp_helpfile 调用。您还需要将其放在方括号中:

USE [4_o5]
GO
DBCC SHRINKFILE ([4_o5_log], 10)
GO

Try this:

USE [4_o5];
GO
ALTER DATABASE [4_o5] SET RECOVERY SIMPLE;
GO
DBCC SHRINKFILE ([4_o5_log], 10);
GO

Your database name starting with a numeric value is a bit unusual - try putting it in square brackets.

UPDATE: for the DBCC SHRINKFILE, you need the logical name of the log file - that's the name property from the sp_helpfile call. And you also need to put it in square brackets:

USE [4_o5]
GO
DBCC SHRINKFILE ([4_o5_log], 10)
GO
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文