sqlite中的journal

本文阐述了事务处理中日志的主要用途,包括保存修改前数据以实现事务回滚,确保数据一致性。详细介绍了日志文件的格式和内容,解释了其在数据库管理中的关键作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

journal 主要用途是,当事务要修改page时,先把未修改的page存入journal中,如果事务rollback时,就从journal中得到修改前的数据,覆盖已改的,达到事务的一致性。

 

journal是一个不同于数据库文件的另一个文件,它在事务开始时创建,当事务结束时就删除了

 

The format for the journal header is as follows:
- 8 bytes: Magic identifying journal format.
- 4 bytes: Number of records in journal, or -1 no-sync mode is on.
- 4 bytes: Random number used for page hash.
- 4 bytes: Initial database page count.
- 4 bytes: Sector size used by the process that wrote this journal.
- 4 bytes: Database page size.

 

 

** The journal file format is as follows:
**
**  (1)  8 byte prefix.  A copy of aJournalMagic[].
**  (2)  4 byte big-endian integer which is the number of valid page records
**       in the journal.  If this value is 0xffffffff, then compute the
**       number of page records from the journal size.
**  (3)  4 byte big-endian integer which is the initial value for the
**       sanity checksum.
**  (4)  4 byte integer which is the number of pages to truncate the
**       database to during a rollback.
**  (5)  4 byte big-endian integer which is the sector size.  The header
**       is this many bytes in size.
**  (6)  4 byte big-endian integer which is the page size.
**  (7)  zero padding out to the next sector size.
**  (8)  Zero or more pages instances, each as follows:
**        +  4 byte page number.
**        +  pPager->pageSize bytes of data.
**        +  4 byte checksum
**
** When we speak of the journal header, we mean the first 7 items above.
** Each entry in the journal is an instance of the 8th item.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值