sql 用于帮助管理SQL Server的DBCC命令列表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 用于帮助管理SQL Server的DBCC命令列表相关的知识,希望对你有一定的参考价值。

DBCC s

--Last input, 57 is the connection number (SPID)
--Displays the last statement sent from a client to an instance of Microsoft SQL Server.
DBCC INPUTBUFFER (57);

--DBCC OPENTRAN helps to identify active transactions that may be preventing log truncation
DBCC OPENTRAN

--Returns the current output buffer in hexadecimal and ASCII format for the specified session_id.
DBCC OUTPUTBUFFER(78)

--Displays information in a table format about the procedure cache
DBCC PROCCACHE

--DBCC SHOW_STATISTICS displays current query optimization statistics for a table or indexed view
DBCC SHOW_STATISTICS
DBCC SHOW_STATISTICS(t1,ix_t1) --table, index

--Provides transaction log space usage statistics for all databases.
DBCC SQLPERF
DBCC SQLPERF(logspace)

--Displays the status of trace flags.
DBCC TRACESTATUS(-1);--displays the status of all trace flags that are currently enabled globally.
DBCC TRACESTATUS (2528, 3205);--displays the status of trace flags 2528 and 3205.
DBCC TRACESTATUS (3205, -1);--displays whether trace flag 3205 is enabled globally.

--Returns the SET options active (set) for the current connection.
DBCC USEROPTIONS

--Checks the consistency of disk space allocation structures for a specified database.
DBCC CHECKALLOC

--Checks for catalog consistency within the specified database.
DBCC CHECKCATALOG (dbTest);

--Checks the integrity of a specified constraint or all constraints on a specified table in the current database.
DBCC CHECKCONSTRAINTS

--Checks the allocation and structural integrity of all tables and indexed views in the specified filegroup of the current database.
DBCC CHECKFILEGROUP

--Checks the current identity value for the specified table in SQL Serve
DBCC CHECKIDENT
DBCC CHECKIDENT(RandomData)

--Checks the integrity of all the pages and structures that make up the table or indexed view.
DBCC CHECKTABLE(RandomData)

--Checks the logical and physical integrity of all the objects in the specified database by performing the following operations
DBCC CHECKDB

--Reclaims space from dropped variable-length columns in tables or indexed views.
DBCC CLEANTABLE (dbTest,'T1', 0)

--Rebuilds one or more indexes for a table in the specified database.
DBCC DBREINDEX(T1,ix_t1)

--Removes all clean buffers from the buffer pool.test queries with a cold buffer cache without shutting down and restarting the server.
DBCC DROPCLEANBUFFERS

--Removes elements from the plan cache
DBCC FREEPROCCACHE

--Defragments indexes of the specified table or view.
DBCC INDEXDEFRAG
DBCC INDEXDEFRAG(dbTest,'T1',ix_T1)

--Shrinks the size of the data and log files in the specified database.
DBCC SHRINKDATABASE (dbTest);

--Shrinks the size of the specified data or log file for the current database
DBCC SHRINKFILE (dbTest_Log,2)

--Reports and corrects pages and row count inaccuracies in the catalog views.
DBCC UPDATEUSAGE (0); --0 is the current database

--returns syntax information for the specified DBCC command.
DBCC HELP ('SHRINKFILE')

以上是关于sql 用于帮助管理SQL Server的DBCC命令列表的主要内容,如果未能解决你的问题,请参考以下文章

(5.3.14)sql server查看当前会话参数(DBCC USEROPTIONS)

MS Sql Server 数据库或表修复(DBCC CHECKDB)

DBCC DBREINDEX重建索引提高SQL Server性能

DBCC DBREINDEX重建索引提高SQL Server性能

金蝶12.0 SQL SERVER数据库可能发生了架构损坏,请运行 DBCC CHECKCATALOG的错误修复

sql server 有很多相关版本 请问具体区别是啥呢?