SQLite如果列存在 [英] SQLite If Column Exists
本文介绍了SQLite如果列存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有一个很好的IF NOT EXISTS检查SQLite列和索引,或者我需要带回整个数据库模式并验证?
I was wondering if there is a nice IF NOT EXISTS for checking columns and indexes in SQLite, or do I need to bring back the entire database schema and validate against that?
推荐答案
是的,sqlite支持以下语法: CREATE INDEX IF NOT EXISTS ...
Yes the following syntax is supported in sqlite: CREATE INDEX IF NOT EXISTS ...
要检查列的存在,你可以简单地尝试做一些 SELECT col from TABLE
。如果它不返回错误,您的表包含 col
。
To check existence of a column you could simply try to do something like SELECT col from TABLE
. If it does not return an error your table contains col
.
这篇关于SQLite如果列存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文