当前位置:首页 > 移动开发 > 正文

Android-sqlite-SQL语句大全

创表语句:

create table student_table(_id integer primary key autoincrement, name text, age integer);

 

在升级过程中,添加表字段:注意升级过程中新增到表子段要允许为null

alter table student_table add age integer null

 

增删改查系列之查询:

select _id,name,age from student_table;
select * from student_table;
select * from student_table where _id = 1;

 

增删改查系列之新增:

insert into student_table(name,age) values(‘刘德利‘,19);

 

增删改查系列之更新:

update student_table set name=‘德利‘ where _id = 1;

 

增删改查系列之删除:

delete from student_table where _id = 1;

 

其他语句:

// 判断不存在才执行
IF
NOT EXISTS if not exists