整理Sqlite資料庫部分語句

2021-08-11 06:09:39 字數 686 閱讀 7195

首先就是看看資料庫的內部表了。(sqllite_master)

select * from sqlite_master。

名字都還算通用。

補充下 type 不止 table乙個型別。

還有 檢視(view) 和 索引(index)等。

檢視所有表(包括臨時表)

select * from (select * from sqlite_master union all select * from sqlite_temp_master);

(select * from android_metadata;  存編碼?select * from sqlite_sequrnce ; 後面看看那,這邊跳過)

既然已經查詢到了表,就可以對資料表做些事情了(生成實體類什麼的)

pragma table_info(series);

增刪改查的語句和其他資料庫並沒太多區別,先忽略。

drop名字在sqlite是不支援刪除列的,刪表可以(drop table if exists a)。

刪除列的時候 可以封裝下方法,比如 a表刪列,  建個中間表b(少列),賦a錶值,刪a,改b名為 a, 

補充新增列語句:alter table student add column name varchar;

重新命名表:alter table b rename to a

資料庫 基礎語句 部分

如果有問題 請大佬指出錯誤 同時幫忙看看還有 還有要補充的 共同進步 1,增 1.1 插入單行 insert into 表名 列名 values 列植 例 insert into students id,name,age values 1,小明 20 1.2 將現有表資料新增到乙個已有表 inser...

sqlite資料庫基本語句集合

資料庫一般以二維表的形式儲存 一行算一條資料,一條中有多列,叫字段 tables,建立的表 views,組織資料 組織多個資料庫的資料,結合起來返回 indexs,索引,優化,用於大資料庫中 索引不能隨便加,加錯了影響效能 triggers,觸發器,每一次執行都會觸發,如某人刪了資料會有記錄 不區分...

資料庫相關整理語句

備份資料庫 backup database testdb to disk d data testdb20070906.bak 清空日誌 dump transaction testdb with no log 截斷事務日誌 backup log testdb with no log 收縮資料庫 dbc...