C# 数据库“DBName”的日志尾部尚未备份
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12370944/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The tail of the log for the database "DBName" has not been backed up
提问by tere?ko
I tried to restore a database using the following query:
我尝试使用以下查询恢复数据库:
ALTER DATABASE [DatabaseName] SET Single_User WITH Rollback Immediate GO
RESTORE DATABASE DatabaseName FROM DISK = 'C:\DBName-Full Database Backup'
ALTER DATABASE [DatabaseName] SET Multi_User GO
but instead of restoring the database, I am getting this error:
但我没有恢复数据库,而是收到此错误:
Msg 3159, Level 16, State 1, Line 2
The tail of the log for the database "DatabaseName" has not been backed up. Use
BACKUP LOG WITH NORECOVERYto backup the log if it contains work you do not want to lose. Use theWITH REPLACEorWITH STOPATclause of theRESTOREstatement to just overwrite the contents of the log. Msg 3013, Level 16, State 1, Line 2RESTORE DATABASEis terminating abnormally.
消息 3159,级别 16,状态 1,第 2 行
数据库“DatabaseName”的日志尾部尚未备份。使用
BACKUP LOG WITH NORECOVERY它是否包含你不想失去工作,备份日志。使用 语句的WITH REPLACEorWITH STOPAT子句RESTORE来覆盖日志的内容。消息 3013,级别 16,状态 1,线路 2RESTORE DATABASE异常终止。
采纳答案by tomfanning
The error message you are getting tells you exactly what you need to do if you don't care about the existing database or log.
如果您不关心现有数据库或日志,您收到的错误消息会准确地告诉您需要做什么。
RESTORE DATABASE DAtabaseName FROM DISK = 'C:\DBName-Full Database Backup'
WITH REPLACE
In SQL Server Management Studio (Tasks > Restore), you can add the WITH REPLACEoption by opening the page "Options" on the left side and ticking "Overwrite the existing database".
在 SQL Server Management Studio(任务 > 还原)中,您可以WITH REPLACE通过打开左侧的“选项”页面并勾选“覆盖现有数据库”来添加选项。
回答by Remus Rusanu
Use BACKUP LOG WITH NORECOVERY to backup the log if it contains work you do not want to lose.
Use the WITH REPLACE or WITH STOPAT clause of the RESTORE statement to just overwrite the contents of the log.
如果日志包含您不想丢失的工作,请使用 BACKUP LOG WITH NORECOVERY 来备份日志。
使用 RESTORE 语句的 WITH REPLACE 或 WITH STOPAT 子句来覆盖日志的内容。
Really, that's the answer. Right there, in the message. What do you want to do? Backup the tail so is no lost? Replace the log that was not backed up? Your call.
真的,这就是答案。就在那里,在消息中。你想让我做什么?备份尾部这样是不是丢了?替换未备份的日志?您的来电。
回答by saeed khalafinejad
Alternatively, you can change the database recovery model to "Simple" instead of "Full".
或者,您可以将数据库恢复模型更改为“简单”而不是“完整”。
Right click on the database, choose 'properties', 'option', change "recovery model" to "simple".
右键单击数据库,选择“属性”、“选项”,将“恢复模型”更改为“简单”。
Then what you have written should work without producing errors.
那么你写的东西应该可以工作而不会产生错误。
回答by Adil Malik
For those who are using Management Studiothis should work:
对于那些使用Management Studio它的人应该工作:


回答by catcher
Alternatively, you can change the database recovery model to Simpleinstead of Full.
或者,您可以将数据库恢复模型更改为Simple而不是Full。
- Right click on the database
- Choose
properties->option - Change
recovery modeltosimple
- 右键单击数据库
- 选择
properties->option - 更改
recovery model为simple
Then what you have written should work without producing errors.
那么你写的东西应该可以工作而不会产生错误。
It worked good with me.
它对我很好。

