关于sqlite操作出现-shm,和-wal后缀文件
2012-04-19 10:45
281 查看
手上的Android项目把数据库放在sd卡上操作,之前一直用2.2的模拟器,昨天拿到2.3的htc真机之后开测。出现一个奇怪的问题,就是当我操作数据库后会生成两个跟数据库名一样后缀分别为-shm和-wal的文件。不知道是什么玩意就google了一下!!!
最后在sqlite官网(http://www.sqlite.org/fileformat2.html)发现了这个说明
其中-wal的文件意思是write-ahead log,顾名思义就是保存的一个日志。。。3.7的sqlite之后开始这个功能,当一个数据库采用WAL模式,所有连接数据的操作都必须使用WAL,然后在在数据库文件夹下生成一个后缀为-wal的文件保存操作日志,我打开看了之后发现里面内容更象一份数据库的备份文件,大小比数据库有时还大;
log" or "WAL". When a database is in WAL mode, all connections to that database must use the WAL. A particular database will use either a rollback journal or a WAL, but not both
at the same time. The WAL is always located in the same directory as the database file and has the same name as the database file but with the string "-wal" appended.
这个-shm说的是一个共享内存的问题,有兴趣的可以看下,基本上这两个文件不会对数据库产生任何影响!
as the database with a "-shm" suffix appended. Because the wal-index is shared memory, SQLite does not support journal_mode=WAL on a network filesystem
when clients are on different machines. All users of the database must be able to share the same memory.
The purpose of the wal-index is to answer this question quickly:
Given a page number P and a maximum WAL frame index M, return the largest WAL frame index for page P that does not exceed M, or return NULL if there are no frames for page P that do not
exceed M.
The M value in the previous paragraph is the "mxFrame" value defined in section 4.4 that is read at
the start of a transaction and which defines the maximum frame from the WAL that the reader will use.
The wal-index is transient. After a crash, the wal-index is reconstructed from the original WAL file. The VFS is required to either truncate or zero the header of the wal-index when the last connection
to it closes. Because the wal-index is transient, it can use an architecture-specific format; it does not have to be cross-platform. Hence, unlike the database and WAL file formats which store all values as big endian, the wal-index stores multi-byte values
in the native byte order of the host computer.
This document is concerned with the persistent state of the database file, and since the wal-index is a transient structure, no further information about the format of the wal-index will be provided
here. Complete details on the format of the wal-index are contained within comments in SQLite source code.
最后在sqlite官网(http://www.sqlite.org/fileformat2.html)发现了这个说明
其中-wal的文件意思是write-ahead log,顾名思义就是保存的一个日志。。。3.7的sqlite之后开始这个功能,当一个数据库采用WAL模式,所有连接数据的操作都必须使用WAL,然后在在数据库文件夹下生成一个后缀为-wal的文件保存操作日志,我打开看了之后发现里面内容更象一份数据库的备份文件,大小比数据库有时还大;
4.0 The Write-Ahead Log
Beginning with version 3.7.0, SQLite supports a new transaction control mechanism called "write-aheadlog" or "WAL". When a database is in WAL mode, all connections to that database must use the WAL. A particular database will use either a rollback journal or a WAL, but not both
at the same time. The WAL is always located in the same directory as the database file and has the same name as the database file but with the string "-wal" appended.
这个-shm说的是一个共享内存的问题,有兴趣的可以看下,基本上这两个文件不会对数据库产生任何影响!
4.5 WAL-Index Format
Conceptually, the wal-index is shared memory, though the current VFS implementations use a mmapped file for the wal-index. The mmapped file is in the same directory as the database and has the same nameas the database with a "-shm" suffix appended. Because the wal-index is shared memory, SQLite does not support journal_mode=WAL on a network filesystem
when clients are on different machines. All users of the database must be able to share the same memory.
The purpose of the wal-index is to answer this question quickly:
Given a page number P and a maximum WAL frame index M, return the largest WAL frame index for page P that does not exceed M, or return NULL if there are no frames for page P that do not
exceed M.
The M value in the previous paragraph is the "mxFrame" value defined in section 4.4 that is read at
the start of a transaction and which defines the maximum frame from the WAL that the reader will use.
The wal-index is transient. After a crash, the wal-index is reconstructed from the original WAL file. The VFS is required to either truncate or zero the header of the wal-index when the last connection
to it closes. Because the wal-index is transient, it can use an architecture-specific format; it does not have to be cross-platform. Hence, unlike the database and WAL file formats which store all values as big endian, the wal-index stores multi-byte values
in the native byte order of the host computer.
This document is concerned with the persistent state of the database file, and since the wal-index is a transient structure, no further information about the format of the wal-index will be provided
here. Complete details on the format of the wal-index are contained within comments in SQLite source code.
相关文章推荐
- 关于sqlite操作出现-shm,和-wal后缀文件
- 关于sqlite操作出现-shm,和-wal后缀文件
- 关于sqlite操作出现-shm,和-wal后缀文件
- 关于安装SQL SERVER时出现“某个程序安装已在安装计算机上创建挂起的文件操作”的解决办法
- 关于"以前的某个程序安装已在安装计算机上创建挂起的文件操作"解决办法
- 关于Cygwin中编译FFmpeg时执行sh文件出现arm-linux-androideabi-gcc is unable to create an executable file.
- 关于win10 php环境配置后运行php文件出现HTTP 错误 401.3 - Unauthorized的解决方法
- 关于Android资源文件中出现百分号的问题
- JAVA中关于文件的读取和写入操作
- 关于PHP操作文件的一些FAQ总结
- C++杂谈之关于文件操作的若干问题
- 关于IOS数据操作方式详解(三)— Sqlite数据解析
- 关于创建pch文件后,导入文件出现could not build module foundation错误提示
- 关于设置sql server 2008服务器属性时出现的无法加载xplog70.dll文件的问题
- 关于Oracle表空间数据文件的修改删除操作
- python关于文件的操作
- 关于c++中的文件操作
- python中关于文件操作
- 关于python文件操作
- 关于C语言文件操作的小结