12.30sqlite判断表、字段是否存在
2014-12-30 10:38
106 查看
1.判断表名是否存在:
select * from sqlite_master
sqlite_master 的表结构如下:
type |name |tbl_name |rootpage |sql
示范查询结果;
=============
type>>table
name>>android_metadata
tbl_name>>android_metadata
rootpage>>3
sql>>CREATE TABLE android_metadata (locale TEXT)
=============
type>>table
name>>TalkVO
tbl_name>>TalkVO
rootpage>>4
sql>>CREATE TABLE TalkVO (content text,videoPath text,img text,name text,issend BLOB,isPlaying integer,uid integer,_id integer PRIMARY KEY)
2.判断字段是否存在
PRAGMA table_info([TalkVO])
必须 大写,结构如下:
cid | name | type | notnull | dflt_value | pk
示范查询结果;
PRAGMA table_info([TalkVO])
=============
cid>>0
name>>content
type>>text
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>1
1name>>videoPath
type>>text
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>2
name>>img
type>>text
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>3
name>>name
type>>text
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>4
name>>issend
type>>BLOB
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>5
name>>isPlaying
type>>integer
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>6
name>>uid
type>>integer
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>7
name>>_id
type>>integer
notnull>>0
dflt_value>>null
pk>>1
select * from sqlite_master
sqlite_master 的表结构如下:
type |name |tbl_name |rootpage |sql
示范查询结果;
=============
type>>table
name>>android_metadata
tbl_name>>android_metadata
rootpage>>3
sql>>CREATE TABLE android_metadata (locale TEXT)
=============
type>>table
name>>TalkVO
tbl_name>>TalkVO
rootpage>>4
sql>>CREATE TABLE TalkVO (content text,videoPath text,img text,name text,issend BLOB,isPlaying integer,uid integer,_id integer PRIMARY KEY)
2.判断字段是否存在
PRAGMA table_info([TalkVO])
必须 大写,结构如下:
cid | name | type | notnull | dflt_value | pk
示范查询结果;
PRAGMA table_info([TalkVO])
=============
cid>>0
name>>content
type>>text
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>1
1name>>videoPath
type>>text
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>2
name>>img
type>>text
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>3
name>>name
type>>text
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>4
name>>issend
type>>BLOB
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>5
name>>isPlaying
type>>integer
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>6
name>>uid
type>>integer
notnull>>0
dflt_value>>null
pk>>0
=============
cid>>7
name>>_id
type>>integer
notnull>>0
dflt_value>>null
pk>>1
相关文章推荐
- SQL判断某个表、存储过程、触发器、函数、某个字段是否存在
- sql判断字段是否存在
- Oracle: DELETE前不需SELECT判断记录是否存在,INSERT前不需SELECT判断是否有若干字段值重复的记录。
- Sql Server 添加删除字段判断表或字段是否存在得到字段描述
- 调整Oracle数据库print_bill表字段BillMKID的顺序,并判断表print_bill是否存在及字段billMKID是否存在
- sql判断表、字段是否存在和增加字段示例
- 常用数据库查询判断表和字段是否存在的SQL
- 判断MSSQL数据库中是否已经存在相同的表与字段
- oracle 添加字段时判断字段是否已经存在
- sqlite判断表或者字段是否存在
- 如何判断表中某一字段是否存在?
- SQL语句判断数据库、表、字段是否存在
- 判断Oracle字段中是否存在中文《asciistr函数》
- mysql 查询字符串判断某个字符串是否存在某个字段中
- 常用数据库查询判断表和字段是否存在
- 在数据库表中插入字段,插入之前会判断该字段是否存在
- SQL删除字段及判断字段是否存在的方法
- 如何判断多个字段组成的关键字在另外一张表中是否存在
- mysql判断表中字段或者索引是否存在,如果不存在则创建
- mysql通过sql语句判断某个字段在一张表中是否存在