Sqlite如果插入或更新数据库

来源:互联网 发布:笔记本安装linux系统 编辑:程序博客网 时间:2024/05/07 10:02

我们经常会用到如果数据库存在则更新,如果不存在则新增

sql一般写为

if exists(select * from table where tableid=1)insert into table ...elseupdate table ....

但是sqlite里没有if exists这种写法,它用的是一种更简单的语句

insert or replace into Forum(forumid, forumname, typeid, forumurl) values(1, 'db', 2, 'http://www.db.com')



1 0
原创粉丝点击