如何在sqlite3 / iPhone上获取列名列表? [英] How to get a list of column names on sqlite3 / iPhone?
本文介绍了如何在sqlite3 / iPhone上获取列名列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将我的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 / iPhone上获取列名列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文