1. 程式人生 > >使用SQL語句操作資料庫

使用SQL語句操作資料庫

                              用SQL語句來實現CRUD操作:

1、新增資料:

db.execSQL("insert into Book(name,author,pages,price) values(?,?,?,?)",new String[] {"The Dan","dan","454","16.99"});

2、更新資料:

db.execSQL("update Book set price = ? where name = ?",new String[] {"10.99","The Dan"});

3、刪除資料:

db.execSQL("delete from Book where pages > ?", new String[] {"500"});

4、查詢資料:

db.rawQuery("select * from Book",null);