• Mysql常用表操作 | 单表查询



    160905
    常用表操作
    1. mysql -u root -p 回车
      输入密码
     
    2. 显示数据库列表
      show databases
     
     
    3. 进入某数据库
      use database database160904;是错的
      use database160904;才是正确的
     
    4. 显示有哪些表
      show tables;
     
    5.创建表
      create table student3(id int auto_increment primary key, user varchar(30) not null, password varchar(30) not null, createtime datetime);
     
    6. 显示表结构
      show columns from student3;
      show columns from database160904.student3;
     
    7. 插入记录
      insert into student3(user, password, createtime)values(
      'mr.hello', 'hlpass', '2016-09-05 15:59');
     
    8. 查询
      select * from student;
      select * from student where password = 'hlpass';
     
    9. 删除表
      show tables;
      drop table student4;
     160905
     160906
    Mysql入门经典王雨竹 6.2节单表查询 
     
     
     
     
    =========================== ========
    1. 查询所有字段
      
    =======================================================
    2. 查询制定字段
     
    =======================================================
    3. 查询制定数据:用where设置条件
     
    =======================================================
    4. 带 IN 关键字的查询 其实是 where + in ( )/ where + not in( )
     
     
    =======================================================
    5. 带 between and 关键字的查询
     
     
    =======================================================
    6. 带 like 关键字的查询:含有两种通配符 % _ 百分号下划线
     
     
    =======================================================
    7. 用 is null 查询空值
       insert into 一条新记录
     
    =======================================================
    8. 带 and 的多条件查询
     
    =======================================================
    9. 带 or 的多条件查询
     
    ================================================
    10. 使用 distinct 去除结果中的重复行,按查询列的序偶判定,完全一样才会去除
     
    ================================================
    11. 使用 order by 对结果排序
     
    ================================================
    12. 使用 group by 分组查询
     
     
    =======================================================
    13. limit 限制
      limit 可以设置2个参数,一个对应从编号几开始(第一条编号是0),一个对应条数
      比如 limit 0,2 从第一条开始一共3个,limit 2,4 从第三条开始,一共四条。
     
      160906

     
     
     
     
     
     
     
     
     
     
     
     
     
     
  • 相关阅读:
    mit课程ocw-business
    2016中国人工智能企业TOP100, CBinsight2016年100家人工智能公司
    excel2013做数据透视表
    Mac OS X中,有三种方式来实现启动项的配置
    macbook双网卡路由
    怎么比较两个list中相同的值个数!
    创业圈必备英语
    全球最牛的100家AI创企:有多少独角兽?
    Java中字符串为什么不以结尾
    详解PPP模式下的产业投资基金运作【基金管理】
  • 原文地址:https://www.cnblogs.com/daydayhave/p/5848974.html
Copyright © 2020-2023  润新知