gpt4 book ai didi

sqlite - SQLite 中是否有 PRAGMA table_info ('mytable' ) 的等效 SELECT 语句?

转载 作者:IT王子 更新时间:2023-10-29 06:20:56 27 4
gpt4 key购买 nike

在 SQLite 中是否有 PRAGMA table_info('mytable') 的等效 SELECT 语句?本质上,我想获得与 PRAGMA 返回完全相同的结果集:cid、name、type、notnull、dflt_value 和 pk。虽然我知道通过 C 函数 sqlite3_table_column_metadata 获取此信息的其他替代方法,但我更愿意使用 SELECT 语句。

最佳答案

根据doc

PRAGMAs that return results and that have no side-effects can be accessed from ordinary SELECT statements as table-valued functions. For each participating PRAGMA, the corresponding table-valued function has the same name as the PRAGMA with a 7-character "pragma_" prefix. The PRAGMA argument and schema, if any, are passed as arguments to the table-valued function.

For example, information about the columns in an index can be read using the index_info pragma as follows:

PRAGMA index_info('idx52'); Or, the same content can be read using:

SELECT * FROM pragma_index_info('idx52');

这不应该解决问题吗?

关于sqlite - SQLite 中是否有 PRAGMA table_info ('mytable' ) 的等效 SELECT 语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6888581/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com