MSSQL不能shrink日志

查看数据库日志使用率

dbcc sqlperf(logspace)

查看是否有活动的事务,发现没有活动的事务

select * from sys.dm_tran_database_transactions
dbcc opentran('test')

查看日志reuse wait,依然是nothing

SELECT log_reuse_wait_desc
FROM sys.databases
WHERE name = 'test'

解决方法及原理

https://dba.stackexchange.com/questions/41215/shrinking-the-log-file-does-not-reduce-size
http://rusanu.com/2012/07/27/how-to-shrink-the-sql-server-log/

use [test]
create table a_test(id int,name nvarchar(10))
insert into a_test values(1,'ll'),(2,'l2')
drop table a_test

补充

dbcc loginfo
select * from sys.dm_db_log_info(null)
 sys.dm_db_log_stats ( null)
select * from sys.dm_db_log_space_usage


posted @ 2020-06-09 16:42  单眼皮Boy  阅读(206)  评论(0编辑  收藏  举报