加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

利用终端练习sqlite的操作

发布时间:2020-12-12 20:15:35 所属栏目:百科 来源:网络整理
导读:首先是创建一个文件来保存sql文件=mkdir sqlite 进入sql文件所在的目录 = cd sqlite/ = sqlite3 data.db 创建一张data表 create table Students(id,name,score); 创建一张data表,如果不存在,就创建,如果存在,就不创建 create table if not exists Studen
首先是创建一个文件来保存sql文件=>mkdir sqlite 进入sql文件所在的目录 => cd sqlite/ => sqlite3 data.db 创建一张data表 create table Students(id,name,score); 创建一张data表,如果不存在,就创建,如果存在,就不创建
create table if not exists Students(id,score); 查看数据库有几张表 .table 删除表 drop table 插入一条数据 insert into Students values(0,' 令狐冲',90); 查询表格里面内容
select * from Students;
第二种添加数据的方式 insert into Students(id,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;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读