zoukankan      html  css  js  c++  java
  • 数据库系列二

    一、索引

    主键索引:primery key

    唯一索引:unique key

    全文索引:fulltext index

    普通索引:index

     

    二、关系:

    一对一

    一对多/多对一

    多对多

     

    三、主键冲突

    更新:insert into 表名 values (值) on duplicate key update 字段 = 值

    替换:replace into 表名 values (值)

     

    四、更新、删除操作

    限制更新:update 表名 set 字段 = 值 where 条件 limit 数量

    限制删除:delete from 表名 where 条件 limit 数量

     

    五、查询

    1.查询所有结果:

    select * from 表名

    select all * from 表名

    2.查询的结果去重:

    select distinct * from 表名

     

    3逻辑符

    ||   或

    &&   且

    !     非

    between x and y  在X,Y之间

    in  字段在列表里面

     

    4.分组:group by 字段1 [,字段2]  asc/desc

    asc/desc   正序/反序

    用于统计:count,max,min,avg,sum

    select 字段,count/max/min/avg/sum from 表名 group by 字段

    分组后的所有该字段的数据

    select 字段,group_concat(字段) from 表名 group by 字段

    回溯统计

    select 字段1 字段2 from 表名 group by 字段 with rollup

     

    5.having

    用于分组统计的结果进行条件判断

    select 字段,统计字段 from 表名 group by 字段 having 条件

    6.order by

    排序,asc/正序,desc/反序

    select 字段 from 表名 order by 字段1 [字段2] [asc/desc]

    7.limit

    限制结果的数量

    select 字段 from 表名 limit 数量

    select 字段 from 表名 limit 起始值,数量

  • 相关阅读:
    python+requests+excel 接口测试
    Pycharm配置git
    ubuntu16.04+ROS安装kinectV1
    ubuntu16.04安装有道词典
    ROS kinetic语音识别
    在Ubuntu16.04中python环境下实现tab键补全
    ros kinetic安装rbx1
    ubuntu14.04安装opencv3.1
    ubuntu16.04SSH无法连接
    VC6中函数点go to definition报告the symbol XXX is undefined
  • 原文地址:https://www.cnblogs.com/st-st/p/9937118.html
Copyright © 2011-2022 走看看