資料庫SQLiteOpenHelper自創

2021-07-11 18:24:47 字數 1392 閱讀 8214

增:insert into 表名 (欄位名,欄位名) values (?,?,?)

刪:delete from 表名 where 字段=?

改:update 表名 set 字段=?,字段=? where 條件=?

查:select * form 表名 where 字段=?

(*可以更改為想要查詢的內容)

建立資料庫

package com.bawei.zsgcactivity;

import android.content.context;

import android.database.sqlite.sqlitedatabase;

import android.database.sqlite.sqlitedatabase.curso***ctory;

import android.database.sqlite.sqliteopenhelper;

public

class

mysqlisthelper extends sqliteopenhelper

@override

public

void

oncreate(sqlitedatabase db)

@override

public

void onupgrade(sqlitedatabase db, int oldversion, int

newversion)

}

主方法呼叫

mysqlisthelper helper=new mysqlisthelper(this, "07a", null, 1);

sqlitedatabase   dp = helper.getreadabledatabase();

查詢

cursor  c = dp.rawquery("

select * from good

", null

);

while

(c.movetonext())

修改

mysqlisthelper  helper=new mysqlisthelper(xiougai.this, "

07a", null, 1

); dp =helper.getreadabledatabase();

dp.execsql(

"update good set name=?,price=?,producter=?,color=? where id=?

", new object);

增加

dp.execsql("insert into good values(null,?,?,?,?)", new object);

刪除

資料庫 資料庫索引

索引是儲存引擎用於快速找到記錄的一種資料結構。索引以檔案的形式儲存在磁碟中。索引可以包含乙個或多個列的值。儲存引擎查詢資料的時候,先在索引中找對應值,然後根據匹配的索引記錄找到對應的資料行。1.b tree索引 2.雜湊索引 myisam和innodb儲存引擎 只支援btree索引,也就是說預設使用...

資料庫 資料庫正規化

關聯式資料庫的設計規範。不同的規範要求被稱為不同的正規化,越高的正規化資料庫冗餘越小。減少資料庫中資料冗餘的過程 1 第一正規化 1nf 在關係模式r中,當且僅當所有屬性只包含原子值,即每個分量都是不可再分的資料項,則稱r滿足1nf。例如表所示的教師職稱情況關係就不滿足1nf。原因在於,該關係模式中...

資料庫 資料庫基礎

什麼是sql 結構化查詢語言 structtured query language sql的作用 啟動mysql.exe,連線伺服器後,就可以使用sql來操作伺服器了。類似php中操作mysql的語句就是sql語句 sql標準 由國際標準化組織 iso 制定的,對dbms 資料庫管理系統 的統一操作...