zoukankan      html  css  js  c++  java
  • 数据库的增删改查

    primary key 维一键 不为空       autoinc 自动增长 在前面数自动加一

    不加*搜什么就是什么 加*是所有信息
     
    order by stuname asc  按名字升序排列   desc 降序
     
    创建数据表
    create table class
    (
       cid  integer  primary key  autoincrement    ,
       cname varchar(20)
    )
    查询语句
    select * from class
    增加语句
    insert into class (cname) values('IOS实训班')
    修改语句
    update class set cname='物联网'  where cid=2
    删除语句
    delete from class where cid=2
    查询表中的记录数
    select count(*) from class
    select count(*) from class where cname='数据库'
    select * from class where cname='数据库'
    select cid from class where cname='数据库'
    select cid,cname from class where cname='数据库'
    select cid,cname from class where cid>=5 and cid<=9
    select cid,cname from class where cid   between 5 and 9
    select cid,cname from class where cid   in(5,6,7,8,9)
    降序排列
    select * from class  order by cid  desc
    升序排列
    select * from class  order by cid   asc
    select * from class  where cname='数据库'  order by cid  desc
    select * from class  where cname like  '%库'  order by cid  desc
    select * from class  where cname like  '数_库'  order by cid  desc
    分组
    select count(*) from class group by cname
    select count(*)   count  from class group by cname  order by count desc
  • 相关阅读:
    UVA756
    SP30906
    SP32900
    CF940F
    洛谷P5030
    洛谷P5142
    洛谷P2569
    网络流 24 题做题记录
    矩阵
    二分图
  • 原文地址:https://www.cnblogs.com/wujie123/p/5308982.html
Copyright © 2011-2022 走看看