SQLite3 命令操作大全 SQLite 库包含一个名字叫做sqlite3 的命令行,它可以让用户手工输入并执行面向SQLite 数据库的SQL 命令
本文档提供一个样使用sqlite3 的简要说明
qlite3 一些常用Sql 语句操作 创建表: create table 表名(元素名 类型,…); 删除表: drop table 表名; 插入数据: insert into 表名 values(, , ,) ; 创建索引: create [unique] index 索引名on 表名(col…
); 删除索引: drop index 索引名(索引是不可更改的,想更改必须删除重新建) 删除数据: delete from 表名; 更新数据: update 表名 set 字段=’修改后的内容’ where 条件; 增加一个列: Alter table 表名 add column 字段 数据类型; 选择查询: select 字段(以”,”隔开) from 表名 where 条件; 日期和时间: Select datetime('now') 日期: select date('now'); 时间: select time('now'); 总数:select count(*) from table1; 求和:select sum(field1) from table1; 平均:select avg(field1) from table1; 最大:select max(field1) from table1; 最小:select min(field1) from table1; 排序:select 字段 from table1 order by 字段(desc 或 asc) ;(降序或升序) 分组:select 字段 f