1.最笨的一个办法 先用SQL查询,然后对结果解析
SELECT sql FROM sqlite_master WHERE tbl_name = 'table_name' AND type = 'table'
返回 类似如下结果
CREATE TABLE 'cms_user' ( 'id' INTEGER NOT NULL PRIMARY KEY, 'name' VARCHAR(30), 'nickname' VARCHAR(30) NOT NULL DEFAULT 'nickname', 'email' VARCHAR(60) NOT NULL, 'passwd' VARCHAR(32) NOT NULL, 'auth' VARCHAR(30), 'times' VARCHAR(30), 'ips' VARCHAR(60), 'hostID' INTEGER, 'status' INTEGER NOT NULL, 'remark' VARCHAR(1000) NOT NULL DEFAULT "" )
是一个字符串,然后用 程序对这个字串 解析,从而得到 想要的数据
网上查询的一个提示
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.
This Stackoverflow entry suggests doing the select
SELECT sql FROM sqlite_master WHERE tbl_name = 'table_name' AND type = 'table' and parse the result.
Is that the common way? Alternatives?
SELECT sql FROM sqlite_master WHERE tbl_name = 'table_name' AND type = 'table'
返回 类似如下结果
CREATE TABLE 'cms_user' ( 'id' INTEGER NOT NULL PRIMARY KEY, 'name' VARCHAR(30), 'nickname' VARCHAR(30) NOT NULL DEFAULT 'nickname', 'email' VARCHAR(60) NOT NULL, 'passwd' VARCHAR(32) NOT NULL, 'auth' VARCHAR(30), 'times' VARCHAR(30), 'ips' VARCHAR(60), 'hostID' INTEGER, 'status' INTEGER NOT NULL, 'remark' VARCHAR(1000) NOT NULL DEFAULT "" )
是一个字符串,然后用 程序对这个字串 解析,从而得到 想要的数据
网上查询的一个提示
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.
This Stackoverflow entry suggests doing the select
SELECT sql FROM sqlite_master WHERE tbl_name = 'table_name' AND type = 'table' and parse the result.
Is that the common way? Alternatives?
57朵
1个