資料庫相關

2021-07-28 17:57:07 字數 1353 閱讀 5874

1.操作類

godb   

public goosundb open() throws sqlexception

public void close()

public cursor search(int mark) , "mark =" + mark, null, null, null, col_date

+ " desc");

if (cursor != null)

return cursor;

} public cursor searchbycode(string string) ,

"gid = " + "'" + string + "'", null, null, null, null);

if (cursor != null)

return cursor;

} public long insertentity(searchentity entity) else

} public long updateentity(searchentity entity) );

} public long deleteentity(int mark) );

} private class database extends sqliteopenhelper

@override

public void oncreate(sqlitedatabase db)

@override

public void onupgrade(sqlitedatabase db, int oldversion, int newversion)

} }

2.先顯示資料庫裡已有的最後10條資料

需求:  

sqlite 資料庫開啟後從上到下是abcde1234567890

現在要每次從表的最後拿出5條listview顯示是: 67890

重新整理操作後再拿出5條listview顯示是:1234567890

重新整理操作後再拿出5條listview顯示是:abcde1234567890

以此類推

我要實現的功能就是類似聊天一樣,下拉看以前的歷史記錄,一進來先顯示資料庫裡已有的最後10條資料,資料庫是動態增加的

第一步資料庫操作:

select *** from *** limit 10 offset (select count(*) from ***)-10;

第二步跳到的位置:

if (count < end) else

資料庫相關

資料庫的設計 分庫分表,記憶體資料庫,主從讀寫分離,資料庫中介軟體mycat 整合了主從讀寫分離,分庫分表等功能 資料庫優化 sql語句優化,資料庫配置優化,索引優化,資料庫設計優化 資料庫的鎖 1.樂觀鎖,表中增加版本字段,每次更改加1,查的時候先把版本字段查出來,更新的時候加上條件版本欄位沒變,...

資料庫相關

1 多顯示乙個字段,格式 使用者名稱 手機號 select concat name,tel from user 2 手機號顯示 132 22 select concat left tel,3 right tel,2 as 安全手機號 from user 1 多顯示乙個字段,格式 使用者名稱 手機號 ...

資料庫相關

1.更改登入的預設資料庫 比如你刪掉了乙個資料庫 然後sql賬號登陸不上去了 說 沒有預設賬號 那是因為你剛好刪掉了這個賬號的預設資料庫 執行下邊的語句就好了,也就是設定master為你sql賬號的預設資料庫 exec sp defaultdb sa master 2.cmd命令執行sql檔案 說明...