简体   繁体   English

SQL Server 2005-如何分离和附加数据库而不创建T日志文件?

[英]SQL Server 2005— How can I detach & attach a DB and not create a T-Log File?

I have a database that is a container for data that is exported nightly from another database. 我有一个数据库,该数据库是每晚从另一个数据库导出的数据的容器。 Each night all of the data is deleted and refreshed. 每天晚上,所有数据都将被删除和刷新。 We previously migrated this process from SQL 2000 to 2005. The process is causing the associated Tran Log to get out of hand in size. 我们以前曾将此过程从SQL 2000迁移到2005。该过程使相关的“传输日志”的大小失控。

To fix this problem I've decided to remove the tran log file from the database since the data is re-exported each night. 为了解决此问题,我决定从数据库中删除tran日志文件,因为每晚都会重新导出数据。

I found this article and I've been trying to follow step II. 我找到了这篇文章,我一直在尝试遵循步骤II。

SQL SERVER – Shrinking Truncate Log File – Log Full – Part 2 SQL SERVER –缩小截断日志文件–日志已满–第2部分

The problem that I am having is that once I re-attach the database, a new transaction log is being created. 我遇到的问题是,一旦我重新连接数据库,就会创建一个新的事务日志。 To be sure, when I go to attach the mdb file, I see a list of two database files on the attach screen, at which point I remove the log file from the list. 可以肯定的是,当我附加mdb文件时,在附加屏幕上看到了两个数据库文件的列表,这时我从列表中删除了日志文件。 Regardless, a new tran log file is created. 无论如何,都会创建一个新的tran日志文件。

The log file is getting out of control. 日志文件已失控。 Is there another way that I can remove if from my database or stop it from growing beyond an unreasonable size? 如果从数据库中删除它,或者阻止它增长到不合理的大小,还有其他方法吗?

I know that I can set a max tran log file size, but I wasn't sure once that limit was reached if it would automatically shrink the log file or start logging errors? 我知道我可以设置最大tran日志文件的大小,但是我不确定一旦达到该限制是否会自动缩小日志文件或开始记录错误? Any tips or pointers would be helpful. 任何提示或指示都会有所帮助。 I don't mind the existence of the tran log, I just want it to maintain a manageable size. 我不在乎tran日志的存在,我只是希望它保持可管理的大小。

If you don't need a transaction history and point-in-time recovery, set the database recovery model to 'Simple'. 如果不需要事务历史记录和时间点恢复,则将数据库恢复模型设置为“简单”。

The transaction log will then only store enough information to roll back pending transactions, rather than be a complete log of all (most) DB changes.. 然后,事务日志将仅存储足够的信息以回滚未决的事务,而不是所有(大多数)数据库更改的完整日志。

See also: http://msdn.microsoft.com/en-us/library/ms175987.aspx 另请参阅: http : //msdn.microsoft.com/en-us/library/ms175987.aspx

That said, if like me you've pressed F5 mid-query, just before you started typing 'WHERE' by mistake: 就是说,如果像我一样,您在错误开始输入“ WHERE”之前按了F5中间查询:

DELETE FROM OrderLine

....then being able to undo the last 5 minutes' worth of damage is very handy. ....然后能够消除最近5分钟的损坏非常方便。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM