ww的笔记之数据库基本操作

1.创建表
       (1)create table Students(id varchar(16),name varchar(16),score varchar(6));
       (2)create table if not exists Students(id varchar(16),name varchar(16),score varchar(6));
2.删除表
    drop table Students;
3.插入
    (1)insert into Students values(1,'YueBuQun',75);
      (2)自增形式插入:inser into WuGong(name) values('zixiashengong');

4.查看
    (1)查看单个表
        select * from Students;(*代表查看所有字段,可以查看单个字段)
    (2)查看多个表元素
        select Students.id,Students.name,WuGong.name from Students,WuGong where Students.id=WuGong.id;
    (3)条件查看
        select * from Students where score>75 and score<90
      (4)排序查看
         1)正序
               select * from Students order by score;
          2倒序
            select * from Students order by score desc;
    (4)只看两条
        select * from Students limit 2;
    (5)查看有多少条数据
             select count(*)from Students;
    (6)平均分,总和分
            select sum(score)from Students;
        select div(score)from Students;
5.修改
    update Students set score=90 where id=1;
6.删除
    delete from Students where id=3;
7.设置主键和唯一键
    (1)create table if not exists WuGong(id INTEGER primary key autoincrement,name TEXT unique);
    (2)自增形式插入:inser into WuGong(name) values('zixiashengong');


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值