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

推荐订阅源

W
WeLiveSecurity
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
Stack Overflow Blog
Stack Overflow Blog
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
Hacker News: Ask HN
Hacker News: Ask HN
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Proofpoint News Feed
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
C
Cybersecurity and Infrastructure Security Agency CISA
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
U
Unit 42
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
H
Help Net Security
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 热门话题
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
博客园 - 聂微东
S
Securelist
大猫的无限游戏
大猫的无限游戏
Cloudbric
Cloudbric
Cisco Talos Blog
Cisco Talos Blog

博客园 - 一江秋水

oracle 数据库 web 开发 正则表达式 职业生涯【3】认真对待选择 职业生涯【2】选择行业、领导 职业生涯【1】选择职业 IE8正在连接(二级页面无法打开) Win7允许/禁用 PING命令 SQL2008 安装后启用 Sa 用户的方法 - 一江秋水 项目计划管理--(摘录) IBatis—源码解析【DataAccess】 IBatis—源码解析【DataMapper】 Ibatis—源码解析【Common】 JavaScript中Eval详解 JavaScript调用WebServices sql server中的varchar和Nvarchar有什么区别 自动从起数据库服务 DataGridView显示行号 中国移动的短信息服务中心 - 一江秋水 - 博客园 Socket(同步与异步) C# 中用Socket实现判断网络是否断开的实例
如何收缩和删除SQL日志文件
一江秋水 · 2009-11-16 · via 博客园 - 一江秋水

-----------------收缩数据库的方法---------------------

DECLARE @dbname AS sysname
SET @DBNname = N'数据库名称l'

--1.清空日志
exec('DUMP TRANSACTION ['+@DBNname +'] WITH NO_LOG')

--2.截断事务日志:
exec('BACKUP (如果不压缩,数据库的文件不会减小LOG ['+@DBNname +'] WITH NO_LOG')

--3.收缩数据库文件
exec('DBCC SHRINKDATABASE(['+@DBNname +'])')

--收缩指定数据文件,1是文件号,可以通过这个语句查询到:select * from sysfiles
DBCC SHRINKFILE(1)

--4.设置自动收缩
exec('EXEC sp_dboption mailto:'''+@dbname+''',''autoshrink'',''TRUE''')

-----------------删除数据库日志文件方法---------------------

1、分离数据库:
    企业管理器--服务器--数据库--右键--分离数据库
2、在我的电脑中删除LOG文件
3、附加数据库:
    企业管理器--服务器--数据库--右键--附加数据库
    此法将生成新的LOG,大小只有500多K

或用代码:
1、分离
    EXEC sp_detach_db @DBNname = '数据库名'
2、删除日志文件
3、再附加
    EXEC sp_attach_single_file_db @DBNname = '数据库名'
    @physname = 'D:\Program Files\Microsoft SQL Server\MSSQL\Data\数据库名.mdf'

-----------------删设置数据库日志文件大小方法---------------------

如果想以后不让它日志增长得太大
企业管理器--服务器--右键数据库--属性--事务日志
--将文件增长限制为xM(x是你允许的最大数据文件大小)

--SQL语句的设置方式:
Alter database 数据库名 modify file(name=逻辑文件名,maxsize=20)