崩溃了数据库先要备份日志(选择截断)然后变为简单模式后,收缩日志文件就可以了
--0 前提是数据库要有完整备份,如果已经有,可以不做
BACKUP DATABASE [BackUpDB] TO DISK = N'F:\DBA\BackUpDB.bak'
WITH NOFORMAT, NOINIT, NAME = N'BackUpDB-完整 数据库 备份'
, SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
BACKUP DATABASE [BackUpDB] TO DISK = N'F:\DBA\BackUpDB.bak'
WITH NOFORMAT, NOINIT, NAME = N'BackUpDB-完整 数据库 备份'
, SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
--1 日志备份截断
BACKUP LOG [BackUpDB] TO DISK = N'F:\DBA\BackUpDB.trn'
WITH NOFORMAT, NOINIT, NAME = N'BackUpDB-事务日志 备份',
SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
BACKUP LOG [BackUpDB] TO DISK = N'F:\DBA\BackUpDB.trn'
WITH NOFORMAT, NOINIT, NAME = N'BackUpDB-事务日志 备份',
SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
--2 设为简单模式
ALTER DATABASE [BackUpDB] SET RECOVERY SIMPLE
GO
--3 收缩日志文件
GO
--3 收缩日志文件
DBCC SHRINKFILE (N'BackUpDB_log' , 0, TRUNCATEONLY)
GO
--4 恢复为完整模式
ALTER DATABASE [BackUpDB] SET RECOVERY FULL
GO
GO