1.安装sqlite3:
终端下:sudo apt-get install sqlite3
2.进入sqlite3:
终端下直接输入:sqlite3
.quit
.exit
3.(.schema(查看表明名)
4.sqlite3 db(创建一个db数据库的存放,db为一个文件名,可随便起。)
5.创建一个table
create table t_01(arg1,arg2,arg3,arg4,arg5);
6.创建一个索引index (索引中的值不能有相同的)
create index idx_01_on_t_01 on t_01(arg1); //means will index by argument 'arg1'
7.添加数据到table中
insert into t_01 values('0','arg2_val','200','300','arg5_val');
insert into t_01 values('1','arg2_val2',NULL,600,NULL);(可用null表示不填将为空)
8.查找数据
select arg4 from t_01 where arg4=600; (arg4为参数变量,如name)
9.添加数据
insert into t_01 values('2',201,601,NULL);
insert into t_01 values('3','arg2_val3',202,602,'arg5_val3');
10.查找
select * from t_01; 查找表格t_01中的所有数据
select * from t_01 order by arg1 limit 2;查找表格t_01中的前2个数据的arg1参数
select arg1,arg2 from t_01;查找表格中t_01的arg1,arg2两列参数的数据
select * from t_01 where arg5 like "arg%";查找参数为arg5的类似"arg%"的数据
select * from t_01 where arg4>601; 查找参数qrg4值大于601的数据
11.更改
update t_01 set arg4='302' where arg4='300' 更改参数为arg4 = '300' 的数据改为arg4 = 302
delete from t_01 where arg4='302'; //have ' ' and do not have ' ' are not the same
12.删除
drop table table_name; 删除表格t_02
drop index index_name
原文链接:https://www.f2er.com/sqlite/199466.html