为什么这个SQLite脚本会影响多行?

Rab*_*820 0 c# sql sqlite mono ado.net

我有以下简单的SQLite脚本来创建带有版本控制表的新数据库:

BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS `db_versions` (
    `version`   integer NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
    `name`  varchar ( 50 ) DEFAULT NULL UNIQUE,
    `date_defined`  datetime DEFAULT NULL,
    `comments`  text
);
INSERT INTO `db_versions` VALUES (0,'initial-create','2017-12-02 14:41:56',NULL);
COMMIT;
Run Code Online (Sandbox Code Playgroud)

在数据库浏览器中运行此脚本以便SQLite正确记录只有1行受影响(插入)的日志.但是,当我尝试使用Mono(Mono.Data.Sqlite)在代码中执行此脚本时,脚本显然会影响2行.这是代码:

using (var conn = new SqliteConnection(_connStr)) {
    await conn.OpenAsync(cancellationToken);
      using (SqliteCommand comm = conn.CreateCommand()) {
          comm.CommandType = CommandType.Text;
          comm.CommandText = @"
              BEGIN TRANSACTION;
              CREATE TABLE IF NOT EXISTS `db_versions` (
                  `version` integer NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
                  `name`    varchar ( 50 ) DEFAULT NULL UNIQUE,
                  `date_defined`    datetime DEFAULT NULL,
                  `comments`    text
              );
              INSERT INTO `db_versions` VALUES (0,'initial-create','2017-12-02 14:41:56',NULL);
              COMMIT;
          ";
          int rowsAffected = await comm.ExecuteNonQueryAsync(cancellationToken);
          if (rowsAffected > 1) {
              // Why is this code running??
          }
      }
}
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么我得到这些不同的结果?

Rab*_*820 5

嘎,我明白了.version正在定义整数字段AUTOINCREMENT,它还将最大的ROWID 添加到内部sqlite_sequence表.因此,有被加了第二排.