SYS. fn_dblog

Source: Internet
Author: User

SYS. fn_dblog returns the activity content of the current database log.

Use Db1
Go
If   Exists ( Select   1   From SYS. Tables Where Name = ' T ' )
Drop   Table T
Go
Create   Table T (COL Int )
Go
DBCC Traceon ( 3505 , - 1 ) --- Disable automatic checkpoint behaviorhttp: // support.microsoft.com/kb/815436/en-us
Go
Checkpoint
Go
Select   [ Current lsn ] , [ Previous lsn ] , [ Previous Page lsn ] , Partitionid, operation, context, [ Transaction ID ] , [ Log Record Fixed Length ] , [ Log Record Length ]   From SYS. fn_dblog ( Null , Null )
Go
Insert   Into T Values ( 1 ) --
Go
Select   [ Current lsn ] , [ Previous lsn ] , [ Previous Page lsn ] , Partitionid, operation, context, [ Transaction ID ] , [ Log Record Fixed Length ] , [ Log Record Length ]   From SYS. fn_dblog ( Null , Null )- - SQL Server need To Allocate Space   For The new Table
Go
Checkpoint
Go
Insert   Into T Values ( 1 )- -
 
Go
Select   [ Current lsn ] , [ Previous lsn ] , [ Previous Page lsn ] , Partitionid, operation, context, [ Transaction ID ] , [ Log Record Fixed Length ] , [ Log Record Length ]   From SYS. fn_dblog ( Null , Null )- - Only   Insert Operation

Copy code

 

Http://support.microsoft.com/kb/815436/en-us

 

How to parse the 2008 operation log, especially the lop_modify_row operation? Different from lop_insert_rows lop_delete_rows

 

 

The insert, udpate, and delte operations of the database are recorded in the log,

For insert operations, after image is generated, that is, the result after the change,

For Delete/update operations, before image (before the change is recorded) and after image (after the change is recorded) are generated)

 

Through before image and after image, you can find the status before and after the data change, and use it for database recovery or transaction rollback.

You can perform insert, update, and deltet operations and observe

[Rowlog contents 0]

,[Rowlog Contents 1]

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.