第三章使用系统函数、存储过程和DBCC SQLPERF命令来监控SQLS
本文为这个系列最后一篇。将是如何使用 DBCC 命令来监控 SQLServer 日志空间的使用情况。 前言: 每个数据库都必须有事务日志。事务日志记录每个 DML 操作,并应用于 SQLServer 的数据库中,如果恢复模式为 FULL 并经常有 DML 操作,日志将增长得非常快。几
本文为这个系列最后一篇。将是如何使用DBCC命令来监控SQLServer日志空间的使用情况。
前言:
每个数据库都必须有事务日志。事务日志记录每个DML操作,并应用于SQLServer的数据库中,如果恢复模式为FULL并经常有DML操作,日志将增长得非常快。几时恢复模式为simple,当数据库处于事务复制或者合并复制时,日志通常会增长。如果日志不是经常备份且日志文件的增长没有受到限制的话,将有可能耗光你所有的硬盘空间然后造成数据库宕机。作为DBA,应该经常监控日志的使用情况以避免问题的发生。
作为DBA,其中一个重要的责任就是监控日志文件的大小,以确保空间不会被耗光导致数据库服务器宕机。
SQLServer提供了不同的DBCC命令供DBA使用,其中DBCC SQLPERF是其中一个用于监控日志大小的常用命令,在本文中,将演示使用这个命令。除了获取日志的信息,还可以用于重置等待和闩锁状态。
DBCC SQLPERF用于监控日志使用情况时,只需要传入一个参数LOGSPACE。但是它也接受其他命令。
DBCC SQLPERF(‘logspace’)命令返回三个列:DatabaseName、LogSize(MB)、LogSpaceUsed(%)
步骤:
1、 打开SSMS然后新开一个查询窗口。
2、 在查询窗口中输入以下代码:
USE tempdb GO IF OBJECT_ID('dbo.#tbl_DBLogSpaceUsage') IS NOT NULL BEGIN DROP TABLE dbo.#tbl_DBLogSpaceUsage END CREATE TABLE dbo.#tbl_DBLogSpaceUsage ( DatabaseName NVARCHAR(128) , LogSize NVARCHAR(25) , LogSpaceUsed NVARCHAR(25) , [Status] TINYINT ) INSERT INTO dbo.#tbl_DBLogSpaceUsage EXEC ( 'DBCC SQLPERF(LOGSPACE)' ) --查询全部结果: SELECT DatabaseName , LogSize , LogSpaceUsed , [Status] FROM dbo.#tbl_DBLogSpaceUsage GO --查询特定数据库的结果: SELECT DatabaseName , LogSize AS LogSizeInMB , LogSpaceUsed LogspaceUsed_In_Percent , [Status] FROM dbo.#tbl_DBLogSpaceUsage WHERE Databasename = 'AdventureWorks' GO
分析:
本例中创建了一个临时表,然后调用DBCC SQLPERF来把数据插入表中。由于DBCC命令需要用EXEC来执行,所以使用动态SQL来实现。根据返回的结果可以预测是否有必要马上执行日志备份操作(完整备份不截断日志,也就不会释放日志空间)。
扩展信息:
可以改进这个语句来获取汇总值,在一段时间之后,表就存放了日志使用信息的历史记录。可以用于分析日志的增长情况。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

On July 29, at the roll-off ceremony of AITO Wenjie's 400,000th new car, Yu Chengdong, Huawei's Managing Director, Chairman of Terminal BG, and Chairman of Smart Car Solutions BU, attended and delivered a speech and announced that Wenjie series models will be launched this year In August, Huawei Qiankun ADS 3.0 version was launched, and it is planned to successively push upgrades from August to September. The Xiangjie S9, which will be released on August 6, will debut Huawei’s ADS3.0 intelligent driving system. With the assistance of lidar, Huawei Qiankun ADS3.0 version will greatly improve its intelligent driving capabilities, have end-to-end integrated capabilities, and adopt a new end-to-end architecture of GOD (general obstacle identification)/PDP (predictive decision-making and control) , providing the NCA function of smart driving from parking space to parking space, and upgrading CAS3.0

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

On April 11, Huawei officially announced the HarmonyOS 4.2 100-machine upgrade plan for the first time. This time, more than 180 devices will participate in the upgrade, covering mobile phones, tablets, watches, headphones, smart screens and other devices. In the past month, with the steady progress of the HarmonyOS4.2 100-machine upgrade plan, many popular models including Huawei Pocket2, Huawei MateX5 series, nova12 series, Huawei Pura series, etc. have also started to upgrade and adapt, which means that there will be More Huawei model users can enjoy the common and often new experience brought by HarmonyOS. Judging from user feedback, the experience of Huawei Mate60 series models has improved in all aspects after upgrading HarmonyOS4.2. Especially Huawei M

Go language provides two dynamic function creation technologies: closure and reflection. closures allow access to variables within the closure scope, and reflection can create new functions using the FuncOf function. These technologies are useful in customizing HTTP routers, implementing highly customizable systems, and building pluggable components.

In C++ function naming, it is crucial to consider parameter order to improve readability, reduce errors, and facilitate refactoring. Common parameter order conventions include: action-object, object-action, semantic meaning, and standard library compliance. The optimal order depends on the purpose of the function, parameter types, potential confusion, and language conventions.

The key to writing efficient and maintainable Java functions is: keep it simple. Use meaningful naming. Handle special situations. Use appropriate visibility.

1. The SUM function is used to sum the numbers in a column or a group of cells, for example: =SUM(A1:J10). 2. The AVERAGE function is used to calculate the average of the numbers in a column or a group of cells, for example: =AVERAGE(A1:A10). 3. COUNT function, used to count the number of numbers or text in a column or a group of cells, for example: =COUNT(A1:A10) 4. IF function, used to make logical judgments based on specified conditions and return the corresponding result.

The advantages of default parameters in C++ functions include simplifying calls, enhancing readability, and avoiding errors. The disadvantages are limited flexibility and naming restrictions. Advantages of variadic parameters include unlimited flexibility and dynamic binding. Disadvantages include greater complexity, implicit type conversions, and difficulty in debugging.
