02 2020 档案

摘要:方式一: python:调用存储过程 mysql:编写存储过程 方式二: python:编写纯生sql mysql: 方式三: python:ORM框架 -->纯生SQL mysql: 阅读全文
posted @ 2020-02-19 15:39 南啾 阅读(325) 评论(0) 推荐(0)
摘要:一、无参存储过程 delimiter // create procedure p1() BEGIN select * from db7.teacher; # 写sql语句 END // delimiter ; # MySQL中调用 call p1(); #Python中调用 cursor.callp 阅读全文
posted @ 2020-02-18 23:12 南啾 阅读(150) 评论(0) 推荐(0)
摘要:#1:子查询是将一个查询语句嵌套在另一个查询语句中。 #2:内层查询语句的查询结果,可以为外层查询语句提供查询条件。 #3:子查询中可以包含:IN、NOT IN、ANY、ALL、EXISTS 和 NOT EXISTS等关键字 #4:还可以包含比较运算符:= 、 !=、> 、<等 一、带 in 关键字 阅读全文
posted @ 2020-02-16 14:38 南啾 阅读(173) 评论(0) 推荐(0)
摘要:一、内连接 inner join:只取两张表的共同部分 select * from employee inner join department on employee.dep_id = department.id; 二、左连接 left join:在内连接的基础上保留左表的记录 select * 阅读全文
posted @ 2020-02-15 16:02 南啾 阅读(107) 评论(0) 推荐(0)
摘要:单表查询 select distinct 字段1,字段2,字段3 from 库.表 where 条件 group by 分组条件 having 过滤条件 order by 排序 limit n; # distinct 去重 # limit 显示条数# 执行顺序:先执行from查找表,再执行where 阅读全文
posted @ 2020-02-15 00:51 南啾 阅读(196) 评论(0) 推荐(0)
摘要:一、插入数据INSERT 1. 插入完整数据(顺序插入) 语法一: INSERT INTO 表名(字段1,字段2,字段3…字段n) VALUES(值1,值2,值3…值n); 语法二: INSERT INTO 表名 VALUES (值1,值2,值3…值n); 2. 指定字段插入数据 语法: INSER 阅读全文
posted @ 2020-02-14 16:08 南啾 阅读(124) 评论(0) 推荐(0)
摘要:一、多对一 二、多对多 三、一对多 阅读全文
posted @ 2020-02-14 15:52 南啾 阅读(111) 评论(0) 推荐(0)
摘要:使用auto_increment的前提是该字段必须是一个key(unique key或primary key) create table t3( id int primary key auto_increment, name char(6) ); 因为id是自增长的,所以插入记录时只需要插入name 阅读全文
posted @ 2020-02-13 22:05 南啾 阅读(382) 评论(0) 推荐(0)
摘要:一、含义: 从约束条件来说,主键不为空且唯一:not null unique 存储引擎(innodb):对于innodb存储引擎来说,一张表骨必须有一个主键 二、单列主键 create table t1( id int primary key, name char(6) ); 三、复合主键 crea 阅读全文
posted @ 2020-02-13 16:39 南啾 阅读(425) 评论(0) 推荐(0)
摘要:一、单列唯一 方式一: create table department( id int unique, name char(10) unique ); 方式二: create table department( id int, name char(10), unique(id), unique(na 阅读全文
posted @ 2020-02-13 16:11 南啾 阅读(201) 评论(0) 推荐(0)
摘要:一、什么是存储引擎? 存储引擎就是表的类型 二、查看MySQL支持的存储引擎 show engines; 三、指定表类型(即存储引擎) create table t1(id int)engine='innodb'; create table t2(id int)engine=memory; crea 阅读全文
posted @ 2020-02-12 17:21 南啾 阅读(88) 评论(0) 推荐(0)
摘要:cmd连接本地数据库: mysqld -uroot -p123abc 一、操作文件夹(库) 增 create database `db1` charset utf8; 查 show create database `db1`; show databases; 改(改字符编码) alter datab 阅读全文
posted @ 2020-02-12 16:19 南啾 阅读(109) 评论(0) 推荐(0)
摘要:1.官网下载免安装版本: http://dev.mysql.com/downloads/mysql/ 我下载的是MySQL5.7.16 2.解压到你常用的盘(我一般都是解压到D盘) 打开mysql-5.7.17-winx64后是这个界面 上图中的两样就是需要我们自己弄的。(同时也是让我们无比难受的坑 阅读全文
posted @ 2020-02-11 22:12 南啾 阅读(475) 评论(0) 推荐(0)
摘要:1、数据库服务器:运行数据库管理软件的计算机 2、数据库管理软件:mysql、oracle、db2、sqlserver 3、库:文件夹 4、表 :文件 5、记录:事物一系列典型的特征,如 小明,男,18 6、数据:描述事物的符号 阅读全文
posted @ 2020-02-11 16:15 南啾 阅读(117) 评论(0) 推荐(0)