<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Sqlite on RenovZ&#39;s Notes</title>
    <link>/tags/sqlite/</link>
    <description>Recent content in Sqlite on RenovZ&#39;s Notes</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 30 Mar 2026 19:02:07 +0800</lastBuildDate>
    <atom:link href="/tags/sqlite/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Sqlite Wal Design</title>
      <link>/posts/sqlite-wal-design/</link>
      <pubDate>Mon, 30 Mar 2026 19:02:07 +0800</pubDate>
      <guid>/posts/sqlite-wal-design/</guid>
      <description>SQLite WAL (Write-Ahead Logging) 设计原理详解 一、源码文件位置 核心实现文件 src/wal.c - WAL 主实现 (约 4700 行代码) src/pager.c - WAL 相关的 Pager 层逻辑 配套文件 src/wal.h - WAL 接口定义 src/os_unix.c / src/os_win.c - 平台特定的 WAL 实现 源码注释位置 文件开头部分 (行 1-250) 有详细的 WAL 格式说明文档&#xA;二、WAL 核心数据结构 2.1 WAL Header (32 字节) struct { u32 magic; /* 0: 0x377f0682 (小端) 或 0x377f0683 (大端) */ u32 version; /* 4: 文件格式版本，当前 3007000 */ u32 pageSize; /* 8: 数据库页面大小，如 1024、4096 等 */ u32 ckptSeq; /* 12: Checkpoint 序列号 */ u32 salt1; /* 16: Salt-1，随机整数，每次 checkpoint 递增 */ u32 salt2; /* 20: Salt-2，随机整数，每次 checkpoint 随机化 */ u32 checksum1; /* 24: 头部校验和 - 第一部分 */ u32 checksum2; /* 28: 头部校验和 - 第二部分 */ } WalIndexHdr; 属性说明：</description>
    </item>
    <item>
      <title>How to Alter Table in Sqlite</title>
      <link>/posts/how-to-alter-table-in-sqlite/</link>
      <pubDate>Tue, 26 Nov 2024 15:49:35 +0800</pubDate>
      <guid>/posts/how-to-alter-table-in-sqlite/</guid>
      <description>Create temp table, then do migration The old table CREATE TABLE &amp;#34;users&amp;#34; ( &amp;#34;id&amp;#34;&#x9;INTEGER NOT NULL, &amp;#34;created_at&amp;#34;&#x9;INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP, &amp;#34;password&amp;#34;&#x9;TEXT NOT NULL, PRIMARY KEY(&amp;#34;id&amp;#34; AUTOINCREMENT) ); Rename table ALTER TABLE &amp;#34;users&amp;#34; RENAME TO &amp;#34;users_old&amp;#34;; The new table CREATE TABLE &amp;#34;users&amp;#34; ( &amp;#34;id&amp;#34;&#x9;INTEGER NOT NULL, &amp;#34;created_at&amp;#34;&#x9;TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, &amp;#34;password&amp;#34;&#x9;TEXT NOT NULL, PRIMARY KEY(&amp;#34;id&amp;#34; AUTOINCREMENT) ); Migrate data from old table INSERT INTO &amp;#34;users&amp;#34; (id, created_at, password) SELECT id, created_at, password FROM &amp;#34;users_old&amp;#34;; Delete old table DROP TABLE &amp;#34;users_old&amp;#34;; Confirm data Double check if the created_at type is TIMESTAMP</description>
    </item>
  </channel>
</rss>
