[Reprint] SQL Server DBCC command Daquan SQL Server DBCC command Daquan

SQL Server DBCC command Daquan

 

Original Source: https://www.cnblogs.com/lyhabc/archive/2013/01/19/2867174.html

DBCC DROPCLEANBUFFERS: Delete all from the buffer pool cache, clear the buffer

During the test, use this command to clear all the test data from the data cache SQLSERVER data cache (buffer), in order to ensure the fairness of the test.

Note that this command only to remove and clean the cache, do not remove the dirty cache. For this reason, before executing this command, you should perform CheckPoint, all dirty buffers written to disk,

So when you run the DBCC RROPCLEANBUFFERS, we can guarantee that all the data cache is cleared rather than part of it.

 

DBCC CacheStats: Displays information exists in the current buffer Cache of objects, such as: hit rates, compiled object and an implementation plan

 

DBCC ErrorLog: If you rarely restart mssqlserver service, the server log (not the database transaction log) will grow quickly, but also open and view the log speed will be very slow

Using this command, you can cut off the current server logs, mainly to generate a new log. Consider setting up a scheduled task, execute this command automatically truncate the server logs weekly.

Sp_cycle_errorlog stored procedure can achieve the same purpose


 

A, DBCC command helper

DBCC HELP ( '?'): DBCC command to query all  

DBCC HELP ( 'command'): description of the syntax of the query specified DBCC command 

DBCC USEROPTIONS: return to the active (set) currently connected SET options


 

Two, DBCC check command validation class 

Consistency of disk space allocation structures inspection specified database: DBCC CHECKALLOC ( 'database name')

Consistency between tables in the system checks the specified database and system tables: DBCC CHECKCATALOG ( 'database name')

( 'Tablename') DBCC CHECKCONSTRAINTS: specify constraints on the specified table or check the integrity of all of the constraints

DBCC CHECKDB: distribution and checks the structural integrity of all objects in the database 

All database tables in the current distribution and structural integrity checks specified file group: DBCC CHECKFILEGROUP

DBCC CHECKTABLE: Check the integrity of the data in the specified table or indexed view, and the index test, ntest and image pages

DBCC CHECKIDENT: If you delete large amounts of data exist, consider after you delete, use dbcc checkident reset it from value-added

http://social.msdn.microsoft.com/Forums/zh-CN/sqlserverzhchs/thread/8fa3e3a8-2ff2-4a68-be3e-92e76c380ef9/

Check the specified value of the current identity

DBCC SQLPERF (UMSSTATS): the most critical reference data num runnable: that the current number of threads waiting to run again, if more than 2, consider the CPU bottleneck reach

Scheduler ID: current machine how many there are that many logical CPU Scheduler ID, specifically to see how I can look at this article

SQLSERVER unique task scheduling algorithm "SQLOS"


 

Three, DBCC maintenance commands of 

DBCC CLEANTABLE ( 'db_name', 'table_name'): recovering Alter table drop column delete statement variable-length columns, or text

DBCC DBREINDEX: one or more indexes rebuild the specified database with ALTER INDEX REBUILD almost

DBCC INDEXDEFRAG: the index and non-clustered index on the table or view defragment

DBCC PINTABLE (db_id, object_id): table data reside in memory

Which method table resides in memory of view is: 0: not resident 1: resident

1 USE [GPOSDB]
2 GO
3 SELECT  OBJECTPROPERTY(OBJECT_ID('dbo.SystemPara'), 'tableispinned') 

 

DBCC UNPINTABLE (db_id, object_id): Undo table resident in memory

DBCC SHRINKDATABASE (db_id, int): shrinking the size of the data files and log files specified database 

DBCC SHRINKFILE (file_name, int): shrink the specified data files and log files related to the size of the database


 

 

Four, DBCC performance adjustment command

DBCC dllname (FREE): Uninstall the specified extension process dynamic link library (dll) in memory

sp_helpextendedproc view the extended PROC loaded 

DBCC DROPCLEANBUFFERS: remove all buffers from the buffer pool

DBCC FREEPROCCACHE: Buffer delete all cached execution plan from execution plans

DBCC INPUTBUFFER: Displays the last statement sent from the client to the server

DBCC OPENTRAN (db_name): a database query execution time of the longest transaction, which is owned by the program

DBCC SHOW_STATISTICS: Displays the current distribution statistics for the specified target on the specified table

DBCC SHOWCONTIG: display fragmentation information for the data and indexes of the specified table

DBCC SQLPERF (logspace): the case of each DB View Log

(Iostats) View IO case

(Threads) View thread consumption

Return a variety of useful statistics 

DBCC CACHESTATS: SQL Server 2000 statistics show memory

DBCC CURSORSTATS: display statistics for SQL Server 2000 cursor

DBCC MEMORYSTATS: SQL Server 2000 shows how memory is broken down

DBCC SQLMGRSTATS: display buffer in the first reading and pre-reading prepared SQL statement


 

Five, DBCC command undisclosed

DBCC ERRLOG: initializing SQL Server 2000 error log file

DBCC FLUSHPROCINDB (db_id): Clear the stored procedure in SQL Server 2005 server memory cache contents of a database 

DBCC BUFFER (db_name, object_name, int (buffer number)): the display buffer header information and page information

DBCC DBINFO (db_name): shows the structure of the information database 

DBCC DBTABLE: display table management data (data dictionary) information 

DBCC IND (db_name, table_name, index_id): View an index page information used 

DBCC REBUILDLOG: rebuild SQL Server 2000 transaction log files

DBCC LOG (db_name, 3) (-1 ~ 4): See the database transaction log information for a display format may be: -1,0,1,2,3,4 and each number represents a different format

DBCC PAGE: View a database data page information

DBCC PROCBUF: display process buffer pool buffer headers and header stored procedure

DBCC PRTIPAGE: page number for each index page to view a line pointing

DBCC PSS (user, spid, 1): Displays the current connection to SQL Server 2000 server process information

DBCC RESOURCE: display server resources currently used

DBCC TAB (db_id, object_id): shows the structure of the data page


 

Six, DBCC trace flag

Wherein tracking marks for a particular server is temporarily set on or off a particular behavior, commonly used to debug or diagnose performance problems or complex systems stored procedure

DBCC TRACEON (3604): Open the trace flag

DBCC TRACEOFF: Close tracking tag

DBCC TRACESTATS: View tracking tag status


 

 

Seven, the official use DBCC advice

1, Run CHECKDB when system usage is low.

2, make sure that no other perform disk I / O operations at the same time, for example, a backup disk.

3, the system tempdb into a separate disk or fast disk subsystem.

4, allowing sufficient room for expansion tempdb on the drive. Tempdb estimate how much space will be required to use the DBCC with ESTIMATE ONLY.

5. Avoid running CPU-intensive queries or batch jobs.

6, the DBCC command is running, reducing active transaction.

7, using NO_INFOMSGS option to reduce some of the information output.

8, consider DBCC CHECKDB with PHYSICAL_ONLY option to check the physical structure pages and recorded.

PHYSICAL_ONLY options: only checks the physical errors, error checking logic

A physical errors more serious than logical, because the physical SQLSERVER error generally can not be repaired, and logical errors can be repaired most SQLSERVER

 
Category:  SQL Server

Original Source: https://www.cnblogs.com/lyhabc/archive/2013/01/19/2867174.html

DBCC DROPCLEANBUFFERS: Delete all from the buffer pool cache, clear the buffer

During the test, use this command to clear all the test data from the data cache SQLSERVER data cache (buffer), in order to ensure the fairness of the test.

Note that this command only to remove and clean the cache, do not remove the dirty cache. For this reason, before executing this command, you should perform CheckPoint, all dirty buffers written to disk,

So when you run the DBCC RROPCLEANBUFFERS, we can guarantee that all the data cache is cleared rather than part of it.

 

DBCC CacheStats: Displays information exists in the current buffer Cache of objects, such as: hit rates, compiled object and an implementation plan

 

DBCC ErrorLog: If you rarely restart mssqlserver service, the server log (not the database transaction log) will grow quickly, but also open and view the log speed will be very slow

Using this command, you can cut off the current server logs, mainly to generate a new log. Consider setting up a scheduled task, execute this command automatically truncate the server logs weekly.

Sp_cycle_errorlog stored procedure can achieve the same purpose


 

A, DBCC command helper

DBCC HELP ( '?'): DBCC command to query all  

DBCC HELP ( 'command'): description of the syntax of the query specified DBCC command 

DBCC USEROPTIONS: return to the active (set) currently connected SET options


 

Two, DBCC check command validation class 

Consistency of disk space allocation structures inspection specified database: DBCC CHECKALLOC ( 'database name')

Consistency between tables in the system checks the specified database and system tables: DBCC CHECKCATALOG ( 'database name')

( 'Tablename') DBCC CHECKCONSTRAINTS: specify constraints on the specified table or check the integrity of all of the constraints

DBCC CHECKDB: distribution and checks the structural integrity of all objects in the database 

All database tables in the current distribution and structural integrity checks specified file group: DBCC CHECKFILEGROUP

DBCC CHECKTABLE: Check the integrity of the data in the specified table or indexed view, and the index test, ntest and image pages

DBCC CHECKIDENT: If you delete large amounts of data exist, consider after you delete, use dbcc checkident reset it from value-added

http://social.msdn.microsoft.com/Forums/zh-CN/sqlserverzhchs/thread/8fa3e3a8-2ff2-4a68-be3e-92e76c380ef9/

Check the specified value of the current identity

DBCC SQLPERF (UMSSTATS): the most critical reference data num runnable: that the current number of threads waiting to run again, if more than 2, consider the CPU bottleneck reach

Scheduler ID: current machine how many there are that many logical CPU Scheduler ID, specifically to see how I can look at this article

SQLSERVER unique task scheduling algorithm "SQLOS"


 

Three, DBCC maintenance commands of 

DBCC CLEANTABLE ( 'db_name', 'table_name'): recovering Alter table drop column delete statement variable-length columns, or text

DBCC DBREINDEX: one or more indexes rebuild the specified database with ALTER INDEX REBUILD almost

DBCC INDEXDEFRAG: the index and non-clustered index on the table or view defragment

DBCC PINTABLE (db_id, object_id): table data reside in memory

Which method table resides in memory of view is: 0: not resident 1: resident

1 USE [GPOSDB]
2 GO
3 SELECT  OBJECTPROPERTY(OBJECT_ID('dbo.SystemPara'), 'tableispinned') 

 

DBCC UNPINTABLE (db_id, object_id): Undo table resident in memory

DBCC SHRINKDATABASE (db_id, int): shrinking the size of the data files and log files specified database 

DBCC SHRINKFILE (file_name, int): shrink the specified data files and log files related to the size of the database


 

 

Four, DBCC performance adjustment command

DBCC dllname (FREE): Uninstall the specified extension process dynamic link library (dll) in memory

sp_helpextendedproc view the extended PROC loaded 

DBCC DROPCLEANBUFFERS: remove all buffers from the buffer pool

DBCC FREEPROCCACHE: Buffer delete all cached execution plan from execution plans

DBCC INPUTBUFFER: Displays the last statement sent from the client to the server

DBCC OPENTRAN (db_name): a database query execution time of the longest transaction, which is owned by the program

DBCC SHOW_STATISTICS: Displays the current distribution statistics for the specified target on the specified table

DBCC SHOWCONTIG: display fragmentation information for the data and indexes of the specified table

DBCC SQLPERF (logspace): the case of each DB View Log

(Iostats) View IO case

(Threads) View thread consumption

Return a variety of useful statistics 

DBCC CACHESTATS: SQL Server 2000 statistics show memory

DBCC CURSORSTATS: display statistics for SQL Server 2000 cursor

DBCC MEMORYSTATS: SQL Server 2000 shows how memory is broken down

DBCC SQLMGRSTATS: display buffer in the first reading and pre-reading prepared SQL statement


 

Five, DBCC command undisclosed

DBCC ERRLOG: initializing SQL Server 2000 error log file

DBCC FLUSHPROCINDB (db_id): Clear the stored procedure in SQL Server 2005 server memory cache contents of a database 

DBCC BUFFER (db_name, object_name, int (buffer number)): the display buffer header information and page information

DBCC DBINFO (db_name): shows the structure of the information database 

DBCC DBTABLE: display table management data (data dictionary) information 

DBCC IND (db_name, table_name, index_id): View an index page information used 

DBCC REBUILDLOG: rebuild SQL Server 2000 transaction log files

DBCC LOG (db_name, 3) (-1 ~ 4): See the database transaction log information for a display format may be: -1,0,1,2,3,4 and each number represents a different format

DBCC PAGE: View a database data page information

DBCC PROCBUF: display process buffer pool buffer headers and header stored procedure

DBCC PRTIPAGE: page number for each index page to view a line pointing

DBCC PSS (user, spid, 1): Displays the current connection to SQL Server 2000 server process information

DBCC RESOURCE: display server resources currently used

DBCC TAB (db_id, object_id): shows the structure of the data page


 

Six, DBCC trace flag

Wherein tracking marks for a particular server is temporarily set on or off a particular behavior, commonly used to debug or diagnose performance problems or complex systems stored procedure

DBCC TRACEON (3604): Open the trace flag

DBCC TRACEOFF: Close tracking tag

DBCC TRACESTATS: View tracking tag status


 

 

Seven, the official use DBCC advice

1, Run CHECKDB when system usage is low.

2, make sure that no other perform disk I / O operations at the same time, for example, a backup disk.

3, the system tempdb into a separate disk or fast disk subsystem.

4, allowing sufficient room for expansion tempdb on the drive. Tempdb estimate how much space will be required to use the DBCC with ESTIMATE ONLY.

5. Avoid running CPU-intensive queries or batch jobs.

6, the DBCC command is running, reducing active transaction.

7, using NO_INFOMSGS option to reduce some of the information output.

8, consider DBCC CHECKDB with PHYSICAL_ONLY option to check the physical structure pages and recorded.

PHYSICAL_ONLY options: only checks the physical errors, error checking logic

A physical errors more serious than logical, because the physical SQLSERVER error generally can not be repaired, and logical errors can be repaired most SQLSERVER

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/12028739.html