利用终端练习sqlite的操作

首先是创建一个文件来保存sql文件=>mkdir sqlite
进入sql文件所在的目录 =>  cd sqlite/ => sqlite3 data.db
创建一张data表
create table Students(id,name,score);
创建一张data表,如果不存在,就创建,如果存在,就不创建
create table if not exists Students(id,name,score);
查看数据库有几张表
.table 
删除表
drop table
插入一条数据
insert into Students values(0,' 令狐冲',90);
查询表格里面内容
select * from Students;
第二种添加数据的方式
insert into Students(id,name,score)values(2,'张无忌',90);
显示当前路径
.databases
修改数据
update Student set name = '东方不败' where id = 2;
删除一条数据
delete from Students where id = 3;
查询前三条数据
select * from Students limit 3;
查询表中的name字段名称的所有数据
select  name from Students;
查询表中name,score两个字段的所有数据
select name,score from Students;
顺序排序
select * from Students order by score;
逆序排序
select * from  Students order by score desc;
最前面的三名
select * from Students order by score desc limit 3;
修改主键id的值
update GongFU set id = 1 where id = 2;
建立两表之间的查询
select Students.id,Students.name,Students.score,GongFU.name from Students,GongFU where Students.id = GongFU.id;
查找某个表中有多少个元素
select * count(*)from Students;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值