惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
Blog — PlanetScale
Blog — PlanetScale
F
Fortinet All Blogs
腾讯CDC
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
WordPress大学
WordPress大学
雷峰网
雷峰网
小众软件
小众软件
D
DataBreaches.Net
V
Visual Studio Blog
博客园 - Franky
IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
博客园 - 聂微东
T
Tailwind CSS Blog
有赞技术团队
有赞技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
云风的 BLOG
云风的 BLOG

月光博客

AI编程从零开始:环境配置到开发调试-月光博客 母亲被保健品诈骗-月光博客 向身体低头,向岁月妥协:我的高血压“还债日记” -月光博客 月光博客电子书:《信息安全指南》 谷歌发布2025年度搜索排行榜 中国2025社会热点大事记 2025年十大流行语发布 7天3次,骗子骗走我母亲95万元 “技术男”设三重安全墙,母亲95万存款还是被骗走了 电信诈骗后的复盘:母亲的95万元,是怎么从手机银行里消失的 母亲被电信诈骗95万元的全过程 阿根廷警察被谷歌街景相机拍到裸照 网信办开展“清朗·整治恶意挑动负面情绪问题”专项行动 翟欣欣敲诈勒索案一审获刑12年 《绝命毒师》影评:力工觉醒后的梭哈至死 《人工智能生成合成内容标识办法》正式施行 用AI分析你的财务信息 腾讯子公司实习HR怒怼求职者后被开除 OpenAI发布最强模型GPT-5,免费向所有用户开放 用AI解构你的日记 用AI分析你的游戏偏好 用AI分析你的观影偏好 用AI分析你的听歌偏好 《白鹿原》人物分析:乱世浮沉中的人性剖析 乌托邦的捷径:让AI治理“失败国家” 苹果AI的“路径错误”:为什么它在大模型时代掉队了? 《暗黑破坏神3》第35赛季开荒指南 我对特朗普的看法 欧·亨利十大经典小说鉴赏 HBO电视剧《最后生还者》第二季影评
清除SQLSERVER数据库日志的方法
月光 · 2005-03-22 · via 月光博客

SQLSERVER的数据库日志占用很大的空间,下面提供三种方法用于清除无用的数据库日志文件。

清除SQLSERVER数据库日志文件的方法:

1、先将这个数据库卸载:
EXEC sp_detach_db 'database_name', 'true'
然后将该数据库所对应的Log文件删掉;
最后,再将这个数据库注册到系统里面:
EXEC sp_attach_db @dbname = N'database_name',
@filename1 = N'e:\mssql7\data\database_name_data.mdf'

2、数据库上点右键-所有任务-收缩数据库-选择收缩文件为LOG 。


3、清除SQLSERVER数据库日志的方法:

*******下面是转发的邮件*****

The shrinking of log files is not immediate in SQL Server 7.0. The
shrinking of log files does not occur until the active portion of the
log moves. As updates are performed on the database, the shrink
operation occurs at checkpoints or transaction log backups. Each log
file is marked with the target_percent for the shrink operation. Each
subsequent log backup or log truncation attempts to shrink the file to
bring its size as close to the target_percent as possible. Because a log
file can be shrunk only to a virtual log file boundary, it may not be
possible to shrink a log file to a size smaller than the size of a
virtual log file even if it is not being used. Please refer to SQL Book
Online for the details.

RESOLUTION

Below script will help to shrink the log file immediately, pls keep it
running for 3~4 minutes and then stop it manually.

\* Run "select fileid, name,filename from ..sysfiles" to get
the fileid which you want to shrink *\

use
go
dbcc shrinkfile(fileid,notruncate)
dbcc shrinkfile(fileid,truncateonly)
create table t1 (char1 char(4000))
go
declare @i int
select @i = 0
while (1 = 1)
begin
 while (@i < 100)
 begin
   insert into t1 values ('a') select @i = @i +1
 end
 truncate table t1
 backup log with truncate_only
end
go

*****转发内容结束*****

清除SQLSERVER数据库日志的方法