随笔分类 - Mysql
摘要:1.Concat()拼接 mysql> select * from pet; + + + + + + + | name | owner | species | sex | birth | death | + + + + + + + | Puffball | Diane | hamster | f |
阅读全文
摘要:1、AND&OR操作符 筛选出sex=m且品种为猫或狗的记录: mysql> select * from pet; + + + + + + + | name | owner | species | sex | birth | death | + + + + + + + | Puffball | Di
阅读全文
摘要:1、事务的四大特征 A:原子性:事务是最小的单位,不可以在分割; C:一致性:事务要求,同一事务中的sql语句,必须保证同时成功或同时失败; I:隔离性:事务1和事务2之间是具有隔离性的; D:持久性:事务一旦结束,就不可以返回。 事务开启方式: 1.修改默认提交; 2.begin; 3.start
阅读全文
摘要:1、什么叫做事务? mysql中,事务其实是一个最小的不可分割的工作单元。事务能够保证一个业务的完整性。 eg.银行转账: a要向b转出100元:a-->-100: update user set money=money-100 where name='a'; b-->+100: update us
阅读全文
摘要:1.as取别名 查询所有教师和同学的姓名、性别、生日: 错误查询: mysql> select stu_name,tea_name,stu_sex,tea_sex,stu_birth,tea_birth from student,teacher; + + + + + + + | stu_name |
阅读全文
摘要:1、四种连接查询 内连接:inner join 或者 join 外连接: 左连接:left join 或者 left outer join 右连接:right join 或者 right outer join 完全外连接:full join 或者 full outer join 2、创建两个表:pe
阅读全文
摘要:1、查询有任课教师的姓名和department: 课程表: mysql> select * from course; + + + + | cour_num | cour_name | tea_num | + + + + | 1-245 | Math | 0438 | | 2-271 | Circui
阅读全文
摘要:1.NOT IN: mysql> select * from teacher; + + + + + + + | tea_num | tea_name | tea_sex | tea_birth | tea_prof | department | + + + + + + + | 0435 | LiMe
阅读全文
摘要:1.查询和学号11328、11427同学同年出生的所有学生的stu_num、stu_name、stu_birth; 查询11328与11427: mysql> select * from student where stu_num in (11328,11427); + + + + + + | st
阅读全文
摘要:1.查询所有学生的stu_name,cour_num,degree列: 其中stu_name字段来自于student表;cour_num和degree字段来自于score表; mysql> select * from student; + + + + + + | stu_num | stu_name
阅读全文
摘要:1.查询每门课的平均成绩: mysql> select * from course; + + + + | cour_num | cour_name | tea_num | + + + + | 1-245 | Math | 0438 | | 2-271 | Circuit | 0435 | | 3-1
阅读全文
摘要:1.查询student表中所有字段: mysql> select * from student; 2.查询student表中指定某些字段: mysql> select stu_name,stu_sex,class from student; 3.去重:DISTINCT mysql> select c
阅读全文
摘要:一、建数据表 学生表Student:学号、姓名、性别、出生年月日、班级 mysql> create database selectTest; mysql> show databases; mysql> use selectTest; Database changed mysql> create ta
阅读全文
摘要:一、第一范式 1NF 数据表中的所有字段都是不可分割的原子项。 mysql> create table student2( -> id int, -> name varchar(20), -> address varchar(30) -> ); 向表中插入数据: mysql> INSERT INTO
阅读全文
摘要:一、Mysql的建表约束 1.主键约束:primary key 目的:唯一确定一条记录。通过给某个字段添加约束,使得该字段不能重复且不能为空。 mysql> create table user( -> id int primary key, -> name varchar(20) -> ); mys
阅读全文
摘要:一、引言 生活中处处是数据,各种各样的数据,怎样存储且利用这些巨额数据? 你看,你工作中那么多的文件,那么长的表格,那么多的数据,你处理起来都快要疯了! 如何持久化存储数据?如何让读/写更便捷?如何让数据更有效? 所以才要来学习嘛! 数据库:存储数据的仓库,并且具有一定的规则,这样也好存好拿好取,方
阅读全文

浙公网安备 33010602011771号