本文介绍了如何获取 Sqlite3 数据库上的列名列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将我的 iPhone 应用程序迁移到新的数据库版本.由于我没有保存一些版本,我需要检查某些列名是否存在.
I want to migrate my iPhone app to a new database version. Since I don't have some version saved, I need to check if certain column names exist.
此Stackoverflow 条目建议进行选择
SELECT sql FROM sqlite_master
WHERE tbl_name = 'table_name' AND type = 'table'
并解析结果.
这是常见的方式吗?替代方案?
Is that the common way? Alternatives?
推荐答案
PRAGMA table_info(table_name);
将为您提供所有列名称的列表.
will get you a list of all the column names.
这篇关于如何获取 Sqlite3 数据库上的列名列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!