Android-SqliteSQL语句大全

SqliteSQL语句大全

创表语句:

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

清除表里面的所有数据:

String dropSQL = "delete from " + TABLE_NAME;

删除表,直接把表删除类,慎用 drop table

String dropSQL = "drop table if exists " + TABLE_NAME;
原文地址:https://www.cnblogs.com/android-deli/p/10084012.html