Common SQL Server statements-Maintenance

Source: Internet
Author: User

Maintenance statement

DBCC dbreindex rebuilding one or more indexes of a table in the specified database
DBCC dbrepair remove corrupted Database
DBCC indexdefrag sorts out clustered indexes and secondary index fragments of a specified table or view.
DBCC shrinkdatabase: shrink the data file size in the specified database
DBCC shrinkfile: compresses the specified data file or log file size of the relevant database
DBCC updateusage reports and corrects incorrect content in the sysindexes table,
This content may cause the use of sp_spaceused
System stored procedures generate incorrect space usage reports

Status statement
DBCC inputbuffer displays the last statement sent from the client to ms SQL Server
DBCC opentran if the specified database contains the oldest active transactions and oldest distributed and non-distributed replication transactions,
The related information is displayed. Only when active transactions or databases contain replication Information,
To display the results. If no active transaction exists, an informative message is displayed.
DBCC outputbuffer returns the current output buffer of the specified system process ID (spid) in hexadecimal or ASCII format
DBCC proccache displays process cache information in the form of reports
DBCC showcontig displays the data and index fragmentation information of the specified table
DBCC show_statistics: displays the current distribution statistics of the specified target in the specified table
DBCC sqlperf provides statistics on the usage of transaction log space in all databases
DBCC tracestatus displays the status of the trace tag
DBCC useroptions returns the set Option of the current connection activity (setting ).

Verification statement
DBCC checkalloc check the consistency of the disk space allocation structure of the specified database
DBCC checkcatalog check the consistency between the system tables in the specified database and between the system tables
DBCC checkconstraints checks the integrity of specified or all constraints on a specified table
DBCC checkdb checks the allocation and structural integrity of all objects in the specified database
DBCC checkfilegroup checks the allocation and structural integrity of all tables in the specified file group (in the current database)
DBCC checkident checks the current ID value of the specified table. If necessary, it also corrects the id value of DBCC checktable
Checks the integrity of the data, index, and text, ntext, and image pages of the specified table or index view.
DBCC newalloc checks the distribution of data and index pages for each table in the extended structure of the database.

Other statements
DBCC dllname (free) detaches the specified dynamic link library (DLL) for the extended stored procedure from the memory)
DBCC help returns the syntax information of the specified DBCC statement.
DBCC pintable marks the table as resident, which means ms SQL Server does not refresh the table page from memory
DBCC rowlock is used in ms SQL Server 6.5 to enable the insert row lock (IRL) operation on the table.
DBCC traceoff disables the specified trace tag
DBCC traceon enables or disables the specified trace tag
DBCC unpintable marks the table as not resident in memory. After the table is marked as not resident in memory,
You can clear the table pages in the cache.

(From: http://hi.baidu.com/zbxlcm/blog/item/8c82abed2d638d2262d09fb1.html)

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.