一个SQLite数据库的数据结构是存贮在 "sqlite_master" 表中。你可以像其他数据表一样对 sqlite_master 表执行 “SELECT” 语句,例如:
$ sqlite3 ex1
SQlite vresion 3.3.10
Enter ".help" for instructions
sqlite> select * from sqlite_master;
type = table
name = tbl1
tbl_name = tbl1
rootpage = 3
sql = create table tbl1(one varchar(10), two smallint)
sqlite>
但是你不能够对sqlite_master 表执行 DROP TABLE, UPDATE, INSERT or DELETE ,当你创建或者删除表的时候,sqlite_master 表会自动更新。你不能手工改变 sqlite_master 表。临时表的结构不会存贮到 sqlite_master 表中,临时表是存贮在另一个特殊的表,叫做 "sqlite_temp_master"。"sqlite_temp_master" 不知道是不是内存中的表。
按照官方的说法,就是sqlite是属于稳定型数据库,也就是某一个时刻,数据只存在写入和没有写入两种状态,所以任何时刻掉电了了都不会丢失数据,多以特别适合单片机等嵌入式开发,因为嵌入式的设备掉电都是家常便饭。
因此可以用select count(*) from sqlite_master where table=*** 查询表的记录数量,如果为0则不存在此表。