开发者

DML operation with out logging - SQL Server

开发者 https://www.devze.com 2023-01-18 18:20 出处:网络
Is there any way that we can do DML operation with out logging it into log file? 开发者_开发问答

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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号