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;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM