SQL SERVER运维命令

不定时更新

0. 库相关

0.1 查询数据库版本

select @@version;

1. 表查询相关

1.1 查询CDC相关表数据行数

select * from (
SELECT    OBJECT_NAME(ii.id) TableName  ,rows
FROM    sysindexes ii
INNER JOIN sysobjects oo
ON ( oo.id = ii.id
     AND oo.xtype = 'U ')
WHERE   ii.indid < 2 ) a
where TableName LIKE 'dbo_%_CT'
ORDER BY rows desc ;

2. 日志相关

2.1 查询日志使用率

DBCC SQLPERF(LOGSPACE)

2.2 查询日志等待状态

SELECT NAME,DATABASE_ID, LOG_Reuse_Wait, Log_Reuse_Wait_Desc
  FROM Sys.DATABASES
 WHERE Name = 'dbname'
posted @ 2021-10-12 14:25  沧浪浊兮  阅读(87)  评论(0编辑  收藏  举报