Discuz!NT|BBS|论坛

注册

 

发新话题 回复该主题

清理数据库日志 [复制链接]

1#
DUMP TRANSACTION TOPPower_NET WITH NO_LOG
go
BACKUP LOG TOPPower_NET WITH NO_LOG
go
DBCC SHRINKDATABASE(TOPPower_NET)
go




USE [master]
GO
ALTER DATABASE TOPPower_NET SET RECOVERY SIMPLE WITH NO_WAIT
GO
ALTER DATABASE TOPPower_NET SET RECOVERY SIMPLE   --简单模式
GO
USE TOPPower_NET
GO
DBCC SHRINKFILE (N'TOPPower_NET_Log' , 1, TRUNCATEONLY)
GO
USE [master]
GO
ALTER DATABASE TOPPower_NET SET RECOVERY FULL WITH NO_WAIT
GO
ALTER DATABASE TOPPower_NET SET RECOVERY FULL  --还原为完全模式
GO





创建清理日志的存储过程的方法
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

CREATE   PROCEDURE [dbo].[clearlog]
  AS
    SET  NOCOUNT  ON
ALTER DATABASE TOPPower_NET SET RECOVERY SIMPLE WITH NO_WAIT
ALTER DATABASE TOPPower_NET SET RECOVERY SIMPLE   --简单模式
DBCC SHRINKFILE (N'TOPPower_NET_Log' , 1, TRUNCATEONLY)
ALTER DATABASE TOPPower_NET SET RECOVERY FULL WITH NO_WAIT
ALTER DATABASE TOPPower_NET SET RECOVERY FULL  --还原为完全模式
本主题由 管理员 admin 于 2020/4/23 16:19:37 执行 主题置顶/取消 操作
分享 转发
TOP
发新话题 回复该主题