SQLite常用基本操作

前端之家收集整理的这篇文章主要介绍了SQLite常用基本操作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

sqlite常用操作:


创建表格:

create table staff(

_id integer primary key autoincrement,
name text,
sex text,
department text,
salary float

)

增加数据:

insert into staff values(null,'Jim','male','computer','5400');

删除数据

delete from staff where name="Jim";

更改数据

update staff set name='Jim' where name="Tom";

查询数据

public People[] select(){
		  //String table="DB_TABLE";
		  String[] columns = new String[] { KEY_ID,KEY_NUM,KEY_NAME,KEY_ADDRESS,KEY_SPECIALTY};
		  String selection = "_id>?"+"and Address=?";  //多重条件选择,需要加and
		  String[] selectionArgs = new String[]{"12","北京"};  //对应 ? 的值
		  String groupBy = null;  
		  String having = null;  
		  String orderBy = null;   		  
		Cursor results =  db.query(DB_TABLE,columns,selection,selectionArgs,groupBy,having,orderBy,null);
		return ConvertToPeople(results);
	  }
原文链接:https://www.f2er.com/sqlite/200653.html

猜你在找的Sqlite相关文章