天天看點

sqlite常用操作

加載sqlite .db檔案

sqlite3 ch.db      

查詢所有表結構

sqlite> select * from sqlite_master where type="table";
table|user_profile_table|user_profile_table|12|CREATE TABLE user_profile_table (sid text primary key, user_name text, content_json text)      

replace into 與 insert into差別

前者 不存在則插入,存在則更新

後者 不存在則插入,存在則忽略      

表中添加列

alter table {table_name} add column {column_name} {column_type} default {0};      

表中删除列

alter table {table_name} drop column {column_name};      

将查詢結果導出到檔案

delete from scan_result_table;
vacuum;