12.30sqlite determines whether a table or field exists. 12.30sqlite Field
1. Check whether the table name exists:
Select * from sqlite_master
The sqlite_master table structure is as follows:
Type | name | tbl_name | rootpage | SQL
Demonstrate query results;
==================
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. Determine whether a field exists
PRAGMA table_info ([TalkVO])
It must be capitalized and the structure is as follows:
Cid | name | type | notnull | dflt_value | pk
Demonstrate query results;
PRAGMA table_info ([TalkVO])
==================
Cid> 0
Name> content
Type> text
Notnull> 0
Dflt_value> null
Pk> 0
==================
Cid> 1
1 name> 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