在 Sql Server 中,我发现当我将数据库标记为只读时,它现有的大型事务日志仍然存在。要解决此问题,我必须将其设置回可写状态,然后在日志文件上执行 dbcc shrinkfile,然后再次将其设置为只读。
如果数据库是只读的,事务日志有什么用?它不只是被删除/刷新的原因是什么?
最佳答案
如果您的数据库仍处于完全恢复模式,则如果没有适当的备份,日志将不会收缩。您应该将只读数据库切换为简单恢复。
此外,如果您决定分离/附加此数据库,则需要日志文件。如前所述here :
In contrast, for a read-only database, the log cannot be rebuilt because the primary file cannot be updated. Therefore, when you attach a read-only database whose log is unavailable, you must provide the log files or files in the FOR ATTACH clause.
关于sql-server - 只读数据库上的事务日志有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3566594/