zoukankan      html  css  js  c++  java
  • MySQL 增删查改

    create table ceshi1
    (
    uid varchar(50) primary key,
    pwd varchar(50),
    name varchar(50)

    )

    1.最后一列不写逗号
    2.多条语句一起执行 分号分开
    3.代码符号 英文状态


    1.主键 primary key
    2.非空 not null

    3.自增长列:auto_increment 整型才能加 仅限mysql
    4.外键关系:foreign key(列名)references 表名(列名)

    1.增加: insert into 表 values('','','','') 要求括号里面值的个数和列数相同
    insert into 表(姓名,年龄)values('','') 添加指定列


    2.修改 update

    update 表名 set name=’于超' where code=’p001‘

    3.删除语句
    delete from 表 where code=’p001‘


    查询 select

    1.普通查询
    select * from 表名 查所有数据
    select name,age from 表名 查指定列 name age

    2.条件查询
    select * from 表名 where name=’张三‘ 一个条件
    select * from 表名 where name=’张三‘ and age=’18‘ 并且关系 或者关系用or

    3.排序查询
    select *from 表名 order by age 默认升序 降序加后缀desc
    select *from 表名 order by age,NO desc 多列排序


    4.聚合函数

    select count(*) from 表名 取个数


    5.分组查询
    select age from 表名 group byage 根据年龄分组

    6.修改列名

    select age as’年龄‘ from 表名

    7.模糊查询

    select * from 表名 where like ’奥迪%‘ 查找以奥迪开头的数据

  • 相关阅读:
    Yarn的运行原理(执行流程)
    Hive 表类型简述
    hive 表类型
    Hadoop小知识点总结1
    电商交易项目案例
    乘用车辆和商用车辆销售数据分析
    搜狗搜索日志分析系统
    mysql group by 对多个字段进行分组
    group by
    输出GPLT
  • 原文地址:https://www.cnblogs.com/yuchao19950412/p/5404707.html
Copyright © 2011-2022 走看看