【问题标题】:SQLite C interface doesn't create sqlite_master tableSQLite C 接口不创建 sqlite_master 表
【发布时间】:2016-08-19 09:09:47
【问题描述】:

似乎SQLite C接口创建的数据库不包含documentation中描述的sqlite_master表:

从 C/C++ 程序(或使用 Tcl/Ruby/Perl/Python 的脚本)中 绑定)您可以通过执行以下操作来访问表和索引名称 在名为“SQLITE_MASTER”的特殊表上选择。每个 SQLite 数据库 有一个定义数据库架构的 SQLITE_MASTER 表

以下代码创建一个不包含此类表的数据库(.tables 命令不返回任何内容):

#include <sqlite3.h>

int main()
{
  sqlite3* db;
  sqlite3_open("helper.db", &db);
  sqlite3_close(db);
}

为什么?我应该怎么做才能创建它?

【问题讨论】:

    标签: c++ sqlite


    【解决方案1】:

    .tables 命令不显示任何内部表,但它们确实存在:

    sqlite> 创建表 t(x); sqlite> .tables 吨 sqlite> 从 sqlite_master 中选择 *; 表|t|t|2|创建表 t(x)

    【讨论】:

    • select * from sqlite_master; 在我的情况下没有返回任何内容
    • 因为您没有任何其他表。但是如果没有主表,查询会导致错误消息。
    • 好的,谢谢。那我在哪里可以看到sqlite_master 表呢?
    • “看”是什么意思?它在我的示例中显示。
    • 我的意思是,命令行实用程序中是否有任何命令(如.tables.schema)可以显示sqlite_master 表?
    猜你喜欢
    • 2020-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多