当前位置: 代码迷 >> Sql Server >> SQL2005中查看事务日志方法,该如何处理
  详细解决方案

SQL2005中查看事务日志方法,该如何处理

热度:276   发布时间:2016-04-27 14:04:42.0
SQL2005中查看事务日志方法
RT

------解决方案--------------------
DBCC log ( {dbid |dbname}, [, type={0 |1 |2 |3 |4}] )

参数: Dbid or dbname - 任一数据库的ID或名字
type - 输出结果的类型:
0 - 最少信息(operation, context, transaction id)
1 - 更多信息(plus flags, tags, row length)
2 - 非常详细的信息(plus object name, index name,page id, slot id)
3 - 每种操作的全部信息
4 - 每种操作的全部信息加上该事务的16进制信息
默认 type = 0
例:DBCC DBCC log (haoin,4)

要查看MSATER数据库的事务日志可以用以下命令:
DBCC log (master) 
但DBCC log命令作用实在有限
------解决方案--------------------
引用楼主 HaoGeOOO 的帖子:
RT

------解决方案--------------------
参照:
DBCC TRACEON (3604)
is issued before each of the following DBCC examples in order to better demonstrate the effects of the command by displaying a trace of the output of the DBCC command. 
It is not actually required to run the DBCC commands examined below. 
If you run any of the DBCC commands below without the above option, the command runs, but you don not see what it is doing.


DBCC BUFFER 
This command can be used to display buffer headers and pages from the buffer cache.
Syntax:
dbcc buffer ([dbid|dbname] [,objid|objname] [,nbufs], [printopt])

where:
dbid|dbname - database id|database name
objid|objname - object id|object name
nbufs - number of buffers to examine
printopt - print option, which includes:
0 - print out only the buffer header and page header (default) 
1 - print out each row separately and the offset table 
2 - print out each row as a whole and the offset table

--This is an example:
DBCC TRACEON (3604)
DBCC buffer(master,'sysobjects')


DBCC BYTES 
This command can be used to dump out bytes from a specific address.
Syntax:
dbcc bytes (startaddress, length)

where:
startaddress - starting address to dump
length - number of bytes to dump

--This is an example:
DBCC TRACEON (3604)
DBCC bytes (10000000, 100)


DBCC DBINFO 
Displays DBINFO structure for the specified database.
Syntax:
DBCC DBINFO [(dbname)]

where:
dbname - is the database name

--This is an example:
DBCC TRACEON (3604)
DBCC DBINFO (master)


DBCC DBTABLE 
This command displays the contents of the DBTABLE structure.
Syntax:
DBCC DBTABLE ({dbid|dbname})

where:
dbid|dbname - database name or database ID

--This is an example:
DBCC TRACEON (3604)
DBCC DBTABLE (master)

The DBTABLE structure has an output parameter called dbt_open. This parameter keeps track of how many users are in the database.

DBCC DES
Prints the contents of the specified DES (descriptor).
Syntax:
dbcc des [([dbid|dbname] [,objid|objname])]
where:
dbid|dbname - database id or the database name
objid|objname - object id or the object name

--This is an example:
DBCC TRACEON (3604)
DBCC DES


DBCC HELP 
DBCC HELP returns syntax information for the specified DBCC statement. In comparison with DBCC HELP command in version 6.5, it returns syntax information only for the documented DBCC commands.
Syntax:
DBCC HELP ('dbcc_statement' | @dbcc_statement_var | '?')

--This is an example:
DBCC TRACEON (3604)
DECLARE @dbcc_stmt sysname
SELECT @dbcc_stmt = 'CHECKTABLE'
DBCC HELP (@dbcc_stmt)


DBCC IND 
Shows all pages in use by indexes of the specified table.
Syntax:
dbcc ind(dbid|dbname, objid|objname, printopt = {-2|-1|0|1|2|3})
where:
dbid|dbname - database id or the database name
  相关解决方案