How to apply SQL Server DBCC to avoid clogging

Source: Internet
Author: User
Tags continue window

Database consistency Detection (DBCC) may be your most important tool in times of crisis. This article gives you a brief introduction to the capabilities of DBCC, which include:

Detect the integrity of tables and related directories.

detects the entire database.

Detects the integrity of a database page.

Rebuilds any directory in the specified table.

Why do you need to learn DBCC?

If you don't even know why you are using DBCC, here are some reasons for this:

Database pages (tables and directories) need to be constantly split, which can break allocations.

The directory may be compromised or inefficient.

The SQL Server engine can sometimes misunderstand your intentions.

Things can be cumbersome when you need a lot of updates (remember that any specified update is actually deleted and inserted).

Individual pages, while still "healthy", may lose their optimal storage footprint.

How to run DBCC

You can run DBCC in two ways: through a command-line window or a Query Analyzer window. If you think it is necessary, you can also determine the time of its operation.

The DBCC command includes the following extensions:

CheckDB: Testing the consistency of the entire database, is the basic method of checking database damage.

CheckTable: Detects problems with specific tables.

Checkalloc: Detects a single page of a database, including tables and directories.

Reindex: Rebuilds a directory for a particular table.

Cachestats: Describes the objects currently stored in the memory cache.

Dropcleanbuffers: Frees all data currently stored in the buffer so that you can continue to detect without using the previous results.

Errorlog: Deletes (shortens) the current log. You can consider determining the time of the operation that contains this command, run it at about one weeks.

FLUSHPROCLNDB: Clears the stored procedure cache for a particular database (using its database ID instead of the name). Use the following code to find the ID:

SELECT dbid from master.dbo.sysdatabases

WHERE name = ' <name your poison>

Indexdefrag: Reduces directory fragmentation but does not lock files so that users can continue to apply the database.

CheckCatalog: Detects consistency between tables and tables in a particular database (which means using foreign keys, and so on). )



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.