pymysql:
- 连接、关闭(游标)
- execute() -- SQL注入 sss' or 1=1 --
- 增删改: conn.commit()
- fetchone fetchall
- 获取插入数据自增ID
- 连接、关闭(游标)
- 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
命令行:
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 * 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;