天天看点

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;