无日志记录的 DML 操作 - SQL Server

发布于 2024-09-25 13:42:23 字数 103 浏览 0 评论 0原文

有没有什么方法可以让我们进行DML操作而不将其记录到日志文件中?

例如,当我在数据库中插入一行时,无论是否使用事务,此操作都会记录在日志文件中。但我不想在日志文件中记录此操作。

Is there any way that we can do DML operation with out logging it into log file?

For example, when I am inserting a row in database, this operation will be logged in log file irrespective of using transaction or not. But I don't want to log this operation in the log file.

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

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

发布评论

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

评论(2

人事已非 2024-10-02 13:42:23

不,从来没有。不可能。

每个操作都会被记录下来:如果中途失败怎么办?服务器崩溃?等等

总结:ACID 中的 A、C 和 D

如果你不想要这个,然后使用我真的会考虑使用非 ACID NoSQL 替代方案。

No. Never. Not possible.

Every operation is logged for a reason: what if it fails halfways through? Server crashes? etc etc

In summary: the A, C and D in ACID

If you don't want this, then using I would really consider using non-ACID NoSQL alternatives.

秋心╮凉 2024-10-02 13:42:23

SQL Server 总是会向日志文件写入一条插入内容。当服务器重置时,它需要该信息来将数据库恢复到一致状态。

您可以通过选择恢复模式来更改影响日志记录:

alter database YourDb set recovery { FULL | BULK_LOGGED | SIMPLE } 

在简单模式下,SQL Server 仅记录正在运行的事务,并开始重用不再需要的日志部分。在简单模式下,日志文件通常很小。

如果您想在插入操作后删除日志,可以使用:

alter database YourDb set recovery simple with no_wait
dbcc shrinkfile(YourDbLog, 1)
alter database YourDb set recovery <<old model here>>

请注意,这将删除所有日志。运行此命令后只能使用恢复最后一次完整备份。

SQL Server will always write an insert to the log file. It needs that information to recover a database in a consistent state when the server resets.

You can change to impact logging has by choosing the recovery model:

alter database YourDb set recovery { FULL | BULK_LOGGED | SIMPLE } 

In simple mode, SQL Server logs just running transactions, and starts reusing parts of the log that are no longer needed. In simple mode, the log file typically remains small.

If you want to get rid of logs after an insert operation, you can use:

alter database YourDb set recovery simple with no_wait
dbcc shrinkfile(YourDbLog, 1)
alter database YourDb set recovery <<old model here>>

Note that this gets rid of all logs. You can only use the restore the last full backup after running this command.

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