sqlite3 语句

来源:互联网 发布:hr面试java常问的问题 编辑:程序博客网 时间:2024/05/20 23:02

表不存在则创建

create table  if not exists student( _id Integer primary key autoincrement , name Text , age Integer)


 

当表中的数据不存在则插入,存在则更新

replace into student( _id , name ,age ) VALUES ( 1,'zz7zz7zz',25) 


insert into student(name,age) select 'zz7zz7zz',25 where not exists(select * from student where name='zz7zz7zz' and age=25)