SQLite查询表是否存在

SQLite - 判断表是否存在

SELECT count(*) FROM sqlite_master WHERE type="table" AND name = "表名";

 

查询的结果

qlite> 
sqlite> SELECT count(*) FROM sqlite_master WHERE type="table" AND name = "t_food";
+----------+
| count(*) |
+----------+
| 1        |
+----------+
1 row in set

sqlite> 
sqlite> 
sqlite> 
sqlite> 
sqlite> 
sqlite> 
sqlite> 
sqlite> SELECT count(*) FROM sqlite_master WHERE type="table" AND name = "t_food2";
+----------+
| count(*) |
+----------+
| 0        |
+----------+
1 row in set

sqlite> 
sqlite> 

 

####################3

 

posted @ 2021-09-05 20:39  西北逍遥  阅读(4336)  评论(0编辑  收藏  举报