sqlite3的基本用法

  1.安装sqlite3:

   终端下:sudo apt-get install sqlite3

  2.进入sqlite3:

   终端下直接输入:sqlite3

3.退出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','arg2_val2',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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值