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;