Jho*_*re- 7 database sqlite schema
我想做下一个查询:
SELECT table_name, column_name, data_type, is_nullable, ...
FROM information_schema.columns
Run Code Online (Sandbox Code Playgroud)
在sqlite数据库上.
我检查了
PRAGMA table_info(table_name);
Run Code Online (Sandbox Code Playgroud)
但不适合我的需要,只需检查一个表的字段.
我检查了
select * from sqlite_master where type = 'table';
Run Code Online (Sandbox Code Playgroud)
但这只是获取表名和创建查询.
有没有办法将这些"加入"方法?或任何其他建议或想法?TX
我知道您不想听到这个,但是您将无法从 SQL 与 SQLite 进行连接。该table_info
编译指示并未映射到标准查询,而是硬编码到 SQLite 源中的虚拟机程序。该程序仅支持单个表。句号。:)
如果您的需求只是测试,那么编写脚本来执行您想要的操作应该不会太难。否则,您必须将其写入您的应用程序中。无论哪种方式,您都将使用 sqlite_master 查询从 sqlite_master 中选择表名称,使用 从中进行 SQL 查询sqlite3_mprintf("pragma table_info(%s);",name)
,然后准备/执行该查询。