• mysql基本指令2


    pymysql:
      - 连接、关闭(游标)
      - execute()   -- SQL注入    sss' or 1=1 --
      - 增删改: conn.commit()
      - fetchone fetchall
      - 获取插入数据自增ID
    转储SQL文件
     命令行:
      mysqldump
      
      数据备份: 数据表结构+数据
       mysqldump -u 用户名  已有的数据库名 > 要转成的数据库名 -p
      
      数据备份:数据表结构
       mysqldump -u root -d db1 > db1.sql -p
       
      导入数据库:
       create database XX;
       mysqldump -u root -d XX < db1.sql -p
       
    # 查询课程大于60   
    -- select * from score where num>60;
    # 查询课程
    -- select *from course;
    # 查询任课老师
    -- select * from course left join teacher no course.teacher_id = teacher.id;
    # 查询学生对应的班级
    -- select * from student left join class on student.class_id = class.id;
    # 统计学生性别人数
    -- select gender count(nid) from  sudent GROUP BY gender;

    临时表:
     select num, course_id from (select num , course_id from score where num > 60) as B
     
     
     
     
     
    查:
     in not in
     between and
     limit
     group by
     order by
     like "%a"
     left join xx on
     临时表:
      select * from (select * from tb where id < 10) as B
     
     select id,name,1,(select count(1) from tb) from tb2;
      
     select
      student_id ,
      select num from score as s2 where s2.student_id=s1.student_id and course_id= 1) as 语文,
      select num from score as s2 where s2.student_id = s1.student_id and course_id = 2) as 数学,
      select num from score as s2 where s2.student_id = s1.student_id and course_id = 3) as 英语
     from score as s1;
    此时此刻,非我莫属
  • 相关阅读:
    shell 如何避免误删目录
    Linux 禁止用户或 IP通过 SSH 登录
    gitlab不能启动了
    清空分区表里某个分区的数据
    mysql错误Table ‘./mysql/proc’ is marked as crashed and should be repaired
    MySQL Server参数优化
    linux下删除乱码文件、目录
    ERROR 1044 (42000): Access denied for user 'root'@'localhost'
    awk 打印从某一列到最后一列的内容
    连接和关闭资源工具类
  • 原文地址:https://www.cnblogs.com/taozhengquan/p/9904200.html
Copyright © 2020-2023  润新知