SQLite常用基本操作
发布时间:2020-12-12 20:04:35 所属栏目:百科 来源:网络整理
导读: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 w
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); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |