SQL Server 2005删除日志文件的几种方法小结
SQL Server数据库都有log文件,log文件记录用户对数据库修改的操作。可以通过直接删除log文件和清空日志在清除数据库日志 使用MS数据库的朋友就会知道一个问题,C盘的空间很容易被占满了。因为本来系统盘就分区比较小,这是由于数据库在使用过程中会使日志文
SQL Server数据库都有log文件,log文件记录用户对数据库修改的操作。可以通过直接删除log文件和清空日志在清除数据库日志
使用MS数据库的朋友就会知道一个问题,C盘的空间很容易被占满了。因为本来系统盘就分区比较小,这是由于数据库在使用过程中会使日志文件不断增 加,使得数据库的性能下降,并且占用大量的磁盘空间。SQL Server数据库都有log文件,log文件记录用户对数据库修改的操作。可以通过直接删 除log文件和清空日志在清除数据库日志。
一、删除LOG
1、分离数据库。分离数据库之前一定要做好数据库的全备份,选择数据库——右键——任务——分离。
勾选删除连接
分离后在数据库列表将看不到已分离的数据库。
2、删除LOG文件
3、附加数据库,附加的时候会提醒找不到log文件。
删除数据库信息信息的ldf文件:
附加数据库之后将生成新的日志文件log,新的日志文件的大小事504K。
也可以通过命令才完成以上的操作:
use master; exec sp_detach_db @dbname='TestDB'; exec sp_attach_single_file_db @dbname='TestDB',@physname='D:Program FilesMicrosoft SQL ServerM SSQL10.SQL2008MSSQLDATATestDB.mdf'二、清空日志
该命令在SQL Server 2005和2000支持,SQL Server 2008不支持该命令。
DUMP TRANSACTION TestDB WITH NO_LOG三、收缩数据库文件
DBCC SHRINKFILE ('TestDB_log',1)四、截断事务日志
BACKUP LOG TestDB WITH NO_LOG该命令在SQL Server 2008也是不支持,在SQL Server 2005和2000可以使用。
清除SQLServer2005的LOG文件
--最好备份日志,以后可通过日志恢复数据。。。以下为日志处理方法一般不建议做第4,6两步第4步不安全,有可能损坏数 据库或丢失数据第6步如果日志达到上限,则以后的数据库处理会失败,在清理日志后才能恢复.--*/--下面的所有库名都指你要 处理的数据库的库名1.清空日志DUMP TRANSACTION 库名 WITH NO_LOG2.截断事务日志:BACKUP LOG 库名 WITH NO_LOG3.收缩数据库文件(如果不压缩,数据库的文件不会减小企业管理器--右键你要压缩的数据库--所有任务--收缩数据 库--收缩文件--选择日志文件--在收缩方式里选择收缩至XXM,这里会给出一个允许收缩到的最小M数,直接输入这个数,确 定就可以了--选择数据文件--在收缩方式里选择收缩至XXM,这里会给出一个允许收缩到的最小M数,直接输入这个数,确定就 可以了也可以用SQL语句来完成 --收缩数据库DBCC SHRINKDATABASE(库名)--收缩指定数据文件,1是文件号,可以通过这 个语句查询到:select * from sysfilesDBCC SHRINKFILE(1)4.为了最大化的缩小日志文件(如果是sql 7.0,这步只能在查询分 析器中进行)a.分离数据库:企业管理器--服务器--数据库--右键--分离数据库b.在我的电脑中删除LOG文件c.附加数据库:企业 管理器--服务器--数据库--右键--附加数据库此法将生成新的LOG,大小只有500多K或用代码: 下面的示例分离 pubs,然 后将 pubs 中的一个文件附加到当前服务器。a.分离EXEC sp_detach_db @dbname = '库名'b.删除日志文件c.再 附加EXEC sp_attach_single_file_db @dbname = '库名', @physname = 'c:Program FilesMicrosoft SQL Server MSSQLData库名.mdf'5.为了以后能自动收缩,做如下设置:企业管理器--服务器--右键数据库--属性--选项--选择"自动收 缩"--SQL语句设置方式:EXEC sp_dboption '库名', 'autoshrink', 'TRUE'6.如果想以后不让它日志增长得太大企业管理器--服 务器--右键数据库--属性--事务日志--将文件增长限制为xM(x是你允许的最大数据文件大小)--SQL语句的设置方式:alter data base 库名 modify file(name=逻辑文件名,maxsize=20)SQL Server 数据库使用时间一长就会导致Log文件逐渐变的庞大, 想备份一下数据库, 想发给谁都很困难
运行下面的语句就可以 清到Log文件只剩下1M左右的空间.
DUMP TRANSACTION 数据库名 WITH NO_LOG
DBCC SHRINKDATABASE('数据库名',TRUNCATEONLY)
不重启SQL服务,删除SQLServer系统日志
SQLServer的系统日志过大,就会引起SQLServer服务器无法启动等一系列问题。今天我遇到了这个问题,,在网上搜索了一下,解
决方法 是删除就 可以了,可是当前的ErrorLog正在被SQL使用无法删除啊,要删除只能停止SQL服务器,难道就没有别得办法了吗?
回答是肯定的:使用以下存储过程:EXEC sp_cycle_errorlog
注释
每次启动 SQL Server 时,当前错误日志重新命名为 errorlog.1;errorlog.1 成为 errorlog.2,errorlog.2 成为 errorlog.3,依次类推。sp_cycle_errorlog 使您得以循环错误日志文件,而不必停止而后再启动服务器。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Tomato Novel is a very popular novel reading software. We often have new novels and comics to read in Tomato Novel. Every novel and comic is very interesting. Many friends also want to write novels. Earn pocket money and edit the content of the novel you want to write into text. So how do we write the novel in it? My friends don’t know, so let’s go to this site together. Let’s take some time to look at an introduction to how to write a novel. Share the Tomato novel tutorial on how to write a novel. 1. First open the Tomato free novel app on your mobile phone and click on Personal Center - Writer Center. 2. Jump to the Tomato Writer Assistant page - click on Create a new book at the end of the novel.

Unfortunately, people often delete certain contacts accidentally for some reasons. WeChat is a widely used social software. To help users solve this problem, this article will introduce how to retrieve deleted contacts in a simple way. 1. Understand the WeChat contact deletion mechanism. This provides us with the possibility to retrieve deleted contacts. The contact deletion mechanism in WeChat removes them from the address book, but does not delete them completely. 2. Use WeChat’s built-in “Contact Book Recovery” function. WeChat provides “Contact Book Recovery” to save time and energy. Users can quickly retrieve previously deleted contacts through this function. 3. Enter the WeChat settings page and click the lower right corner, open the WeChat application "Me" and click the settings icon in the upper right corner to enter the settings page.

1. First of all, it is false to block and delete someone permanently and not add them permanently. If you want to add the other party after you have blocked them and deleted them, you only need the other party's consent. 2. If a user blocks someone, the other party will not be able to send messages to the user, view the user's circle of friends, or make calls with the user. 3. Blocking does not mean deleting the other party from the user's WeChat contact list. 4. If the user deletes the other party from the user's WeChat contact list after blocking them, there is no way to recover after deletion. 5. If the user wants to add the other party as a friend again, the other party needs to agree and add the user again.

1. Open the Douyin app, click [Message] at the bottom of the interface, and click the chat conversation entry that needs to be deleted. 2. Long press any chat record, click [Multiple Select], and check the chat records you want to delete. 3. Click the [Delete] button in the lower right corner and select [Confirm deletion] in the pop-up window to permanently delete these records.

Mobile games have become an integral part of people's lives with the development of technology. It has attracted the attention of many players with its cute dragon egg image and interesting hatching process, and one of the games that has attracted much attention is the mobile version of Dragon Egg. To help players better cultivate and grow their own dragons in the game, this article will introduce to you how to hatch dragon eggs in the mobile version. 1. Choose the appropriate type of dragon egg. Players need to carefully choose the type of dragon egg that they like and suit themselves, based on the different types of dragon egg attributes and abilities provided in the game. 2. Upgrade the level of the incubation machine. Players need to improve the level of the incubation machine by completing tasks and collecting props. The level of the incubation machine determines the hatching speed and hatching success rate. 3. Collect the resources required for hatching. Players need to be in the game

Setting font size has become an important personalization requirement as mobile phones become an important tool in people's daily lives. In order to meet the needs of different users, this article will introduce how to improve the mobile phone use experience and adjust the font size of the mobile phone through simple operations. Why do you need to adjust the font size of your mobile phone - Adjusting the font size can make the text clearer and easier to read - Suitable for the reading needs of users of different ages - Convenient for users with poor vision to use the font size setting function of the mobile phone system - How to enter the system settings interface - In Find and enter the "Display" option in the settings interface - find the "Font Size" option and adjust it. Adjust the font size with a third-party application - download and install an application that supports font size adjustment - open the application and enter the relevant settings interface - according to the individual

Practical PHP Tips: Delete the Last Semicolon in the Code When writing PHP code, you often encounter situations where you need to delete the last semicolon in the code. This may be because copy-pasting introduces extra semicolons, or to optimize code style and structure. In this article, we will introduce some methods to remove the last semicolon in PHP code and provide specific code examples. Method 1: Use the substr function The substr function can return a substring of a specified length from a string. we can

The difference between Go language methods and functions lies in their association with structures: methods are associated with structures and are used to operate structure data or methods; functions are independent of types and are used to perform general operations.
