如何删除SQLServer数据库的日志?

microyzy 2001-08-31 11:34:17
我的数据库日志太大了,而且已经确认不再需要,但我不知如何删除日志?请各位帮忙。
...全文
658 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zxszx 2001-09-01
  • 打赏
  • 举报
回复
关于怎样截数据据日志。
1、用dbcc checktable(syslogs)检查断点。
2、然后在enterprise manager中对数据库进行'truncate'。
3、这时如果还不能'truncate'短。则再次dbcc checktable(syslogs),后再次'truncate'.
4、如果还不能则stop database。(这种情况仅出现在非常大的事务引起log is over).
5、如果没有采用备份日志的方案的话,笔者建议选用truncate log on checkpoint选项。
6、反对采用detach database,然后delete ldf file。这种做法非常danger.
以上为一家之言,不妥之处请指正
leonfu 2001-09-01
  • 打赏
  • 举报
回复
应该先detach database,然后delete ldf file,然后再attach database
leonfu 2001-09-01
  • 打赏
  • 举报
回复
直接把ldf文件删了
leeyoong 2001-08-31
  • 打赏
  • 举报
回复
1、首先,dbcc checkdb (数据库名)
2、然后,在enterprise manager中对该数据库进行‘Truncate’!
lovesong 2001-08-31
  • 打赏
  • 举报
回复
在enterprise manager里面右键点中数据库节点,选择truncate log
swordmanli 2001-08-31
  • 打赏
  • 举报
回复

进行数据库的 log 备份

执行

backup log 数据库名 with no_log

swordmanli 2001-08-31
  • 打赏
  • 举报
回复
Truncating the Transaction Log
If log records were never deleted from the transaction log, the logical log would grow until it filled all the available space on the disks holding the physical log files. At some point in time, old log records no longer necessary for recovering or restoring a database must be deleted to make way for new log records. The process of deleting these log records to reduce the size of the logical log is called truncating the log.

The active portion of the transaction log can never be truncated. The active portion of the log is the part of the log needed to recover the database at any time, so must have the log images needed to roll back all incomplete transactions. It must always be present in the database in case the server fails because it will be required to recover the database when the server is restarted. The record at the start of the active portion of the log is identified by the minimum recovery log sequence number (MinLSN).

The recovery model chosen for a database determines how much of the transaction log in front of the active portion must be retained in the database. Although the log records in front of the MinLSN play no role in recovering active transactions, they are required to roll forward modifications when using log backups to restore a database to the point of failure. If you lose a database for some reason, you can recover the data by restoring the last database backup, and then restoring every log backup since the database backup. This means that the sequence of log backups must contain every log record that was written since the database backup. When you are maintaining a sequence of transaction log backups, no log record can be truncated until after it has been written to a log backup.

The log records before the MinLSN are only needed to maintain a sequence of transaction log backups.

In the simple recovery model, a sequence of transaction logs is not being maintained. All log records before the MinLSN can be truncated at any time, except while a BACKUP statement is being processed. NO_LOG and TRUNCATE_ONLY are the only BACKUP LOG options that are valid for a database that is using the simple recovery model.


Note The tempdb database always uses the simple recovery model, it cannot be switched to another recovery model. Log truncation always occurs on a checkpoint in tempdb.

In the full and bulk-logged recovery models, a sequence of transaction log backups is being maintained. The part of the logical log before the MinLSN cannot be truncated until those log records have been copied to a log backup.
Log truncation occurs at these points:

At the completion of any BACKUP LOG statement.


Every time a checkpoint is processed, provided the database is using the simple recovery model. This includes both explicit checkpoints resulting from a CHECKPOINT statement and implicit checkpoints generated by the system. The exception is that the log is not truncated if the checkpoint occurs when a BACKUP statement is still active. For more information about the interval between automatic checkpoints, see Checkpoints and the Active Portion of the Log..
Transaction logs are divided internally into sections called virtual log files. Virtual log files are the unit of truncation. When a transaction log is truncated, all log records before the start of the virtual log file containing the MinLSN are deleted. For more information about virtual log files, see Transaction Log Physical Architecture.

The size of a transaction log is therefore controlled in one of these ways:

When a log backup sequence is being maintained, schedule BACKUP LOG statements to occur at intervals that will keep the transaction log from growing past the desired size.


When a log backup sequence is not maintained, specify the simple recovery model.
This illustration shows a transaction log that has four virtual logs. The log has not been truncated after the database was created. The logical log starts at the beginning of the first virtual log and the part of virtual log 4 beyond the end of the logical file has never been used.



This illustration shows how the log looks after truncation. The rows before the start of the virtual log containing the MinLSN record have been truncated.



Truncation does not reduce the size of a physical log file, it reduces the size of the logical log file. For information on shrinking the size of a physical log file, see Shrinking the Transaction Log.

SQL Server 2005微软官方权威参考书.   公球公认SQL Server 2005 经典著作..   数据库“铁人”、微软MVP胡百敬先生鼎力推荐   微软SQL Server 总部Principal Group 项目经理朱凌志鼎力推荐   本书详细介绍了数据引擎的基础运作,包含了数据库的设定与数据实际在硬盘的摆放、索引结构、事务与锁定等。除了解释设计理念与运作原理外,还辅之以测试验证的方式。数据库开发者和管理员可从中获得最优的方法、务实的建议和实例代码来帮助他们掌握创建和维护企业级关系数据库所需的复杂技术。该书获得资深专家关于创建和维护健壮数据库的高屋建瓴般的视野和入木三分的剖析,十分适合有一定数据库基础的读者学习。 内容简介 本书是Inside Microsoft SQL Server 2000的作者Kalen Delaney的又一经典著作,是Inside Microsoft SQL Server 2005系列四本著作中的一本。本书对SQL Server 2005存储引擎方面的知识进行了全面而详细的阐述,包括数据库文件、日志和恢复、表、索引及其管理、锁定和并发等内容。除了解释设计理念与运作原理外,书中还辅之以大量简短而有力的实例。您将跟随一位广受欢迎的作家同时也是SQL Server资深专家一起深入探索SQL Server存储引擎的技术内幕。   本书适合于专业数据库开发者、BI开发者、DBA和以SQL Server作为后台数据库的一般应用程序开发者。本书不仅适合SQL Server 2005的初级读者,也适合SQL Server 2005的中高级读者。读者可以从中获得最优的方法、务实的建议和实例代码来帮助他们掌握创建和维护企业级关系数据库所需的复杂技术。本书是所有SQL Server 2005用户的案头必备之书。 作者简介 Kalen Delaney,她还是微软出版社inside SQL Sever丛书的编辑。她从1987年开始便一直从事SQL Server相关的工作,1995年被评为MVP(微软最有价值专家》。她同时也是Solid Quality Learning的首席顾问和创始人。除此之外,她还是SQL Server Magazine的优秀编辑和专栏作家,她还写作了大量的SQL Server类书籍,包括著名的Inside Microsoft SQL Server2000。 目录 前言 致谢 引言 第1章 SQL Server 2005 的安装与升级  1.1 SQL Server 2005安装前提   SQL Server 2005 版本   软件要求   硬件要求  1.2 安装前决策   安全性和用户上下文   字符与排序规则   排序次序   安装SQL Server的多个实例   安装SQL Server命名实例  1.3 做好安装准备   SQL Server 2005升级向导  1.4 迁移还是升级   迁移   升级   升级后的操作  1.5 选择组件   SQL Server数据库服务(数据库引擎)   Analysis Services   Reporting Services   Notification Services   Integration Services   工作站组件、联机丛书及开发工具  1.6 小结 第2章 SQL Server 2005体系结构  2.1 SQL Server引擎组件   观测数据库引擎行为   协议   表格格式数据流(TDS)端点   关系引擎   存储引擎   SQLOS  2.2 内存   缓冲池和高速数据缓冲区   访问内存中的数据页   管理数据高速缓冲区中的页面   检查点   管理其他高速缓存中的内存   调节内存大小   调节缓存池大小  2.3 小结 第3章 SQL Server 2005的配置  3.1 使用SQL Server 配置管理器   配置网络协议   默认的网络配置   管理服务  3.2 系统配置   任务管理   资源分配   系统分页文件的位置   非必需的服务   网络协议   与SQL Server 早期版本之间的兼容性   跟踪标记(Trace Flags)   SQL Server 的配置设定   内存选项   调度选项(Scheduling Options)   磁盘I/O 选项   查询处理选项   默认跟踪(Default Trace)  3.3 小结 第4章 数据库数据库文件 第5章 日志和恢复 第6章 表 第7章 索引的内部构造和管理 第8章 锁定和并发

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧