![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据库技术
料理码王
什么都不会!
展开
-
SQL语句高级(六)
一、all查询选修编号为3-105且成绩高于选修编号为3-245课程的同学的cno、sno和degree字段mysql> select * from score where cno='3-105';+-----+-------+--------+| sno | cno | degree |+-----+-------+--------+| 100 | 3-105 | ...原创 2019-02-14 16:00:03 · 179 阅读 · 0 评论 -
SQL语句高级(四)
一、多层嵌套子查询查询ccc老师任课的学生成绩!mysql> select * from teacher;+-----+-------+-------+---------------------+------------+--------+| tno | tname | tsex | tbirthday | prof | depart |+----...原创 2019-02-14 01:54:31 · 186 阅读 · 0 评论 -
SQL语句高级(三)——子查询
一、子查询(查询选秀3-245课程的成绩高于103号同学该门课程成绩的所有同学的记录)mysql> select degree from score where sno = '103' and cno = '3-245';--先找到该成绩的值!!+--------+| degree |+--------+| 89 |+--------+1 row in set (0.0...原创 2019-02-14 01:20:51 · 215 阅读 · 0 评论 -
SQL语句高级(二)
一、多表查询步骤mysql> select cno,cname from course;+--------+----------+| cno | cname |+--------+----------+| 3-105 | csdaolun || 3-245 | os || 6-1166 | math |+--------+---------...原创 2019-02-13 21:59:06 · 374 阅读 · 0 评论 -
SQL语句高级(一)
① mysql> select cno,avg(degree),count(*) //新表字段名 from score //原始表group by cno //以cno字段分组having count(cno) >= 2 //该字段的数据总数大于2and //条件与cno like '3%'; ...原创 2019-02-13 15:48:21 · 515 阅读 · 1 评论 -
SQL语句高级(大结局)——ACID和隔离性(隔离级别)
一、事务——ACID特征与使用事务的四大特征:A——原子性:事务是最小的单位,不可以再分割;C——一致性:事务要求,同一事务中的sql语句,必须保证同时成功或者同时失败;I——隔离性:事务1和事务2之间是具有隔离性的;(之前未提及!)D——持久性:事务一旦结束(commit,rollback),就不可以返回。事务开启: 1、修改默认提交: set autocommit=0; 2...原创 2019-02-17 04:58:58 · 536 阅读 · 0 评论 -
SQL语句高级(十二)——MySQL事务
一、sql事务mysql中,事务其实是一个最小的不可分割的工作单元。事务能够保证一个业务的完整性。比如我们的银行转账:a 转100 -100update user set money=money-100 where name = 'a';b 收100 +100update user set money=money+100 where name = 'b';——实际的程序中,如果只...原创 2019-02-16 02:34:24 · 348 阅读 · 0 评论 -
SQL语句高级(十一)——等级查询、连接和full join
一、按等级查询mysql> create table grade( -> low int(3), -> upp int(3), -> grade char(1) -> );Query OK, 0 rows affected (0.87 sec)mysql> insert into grade values(90,100,'...原创 2019-02-16 02:33:09 · 636 阅读 · 0 评论 -
SQL语句高级(十)——子查询
一、子查询查询和“C”同学同性别的所有同学的sname:mysql> select ssex from student where sname='C';+-------+| ssex |+-------+| woman |+-------+1 row in set (0.01 sec)mysql> select sname,ssex from student ...原创 2019-02-14 23:45:24 · 186 阅读 · 0 评论 -
SQL语句高级(九)——max和min
一、max和min函数查询student表中最大和最小的sbirthday日期值:--注意这里最大和最小的含义!!!!!!!!!mysql> select sbirthday from student order by sbirthday;+---------------------+| sbirthday |+---------------------+| ...原创 2019-02-14 23:44:26 · 1685 阅读 · 0 评论 -
SQL语句高级(八)——not like、year函数
一、not like模糊查询查询student表中不姓C的同学记录:mysql> select * from student where sname not like 'C%';+-----+--------+---------------------+-------+-------+| sno | sname | sbirthday | class | sse...原创 2019-02-14 23:43:14 · 11677 阅读 · 0 评论 -
SQL语句高级(七)——复制表a、b
一、复制表数据做条件查询mysql> select cno,avg(degree) from score group by cno;+--------+-------------+| cno | avg(degree) |+--------+-------------+| 3-105 | 71.6667 || 3-245 | 89.2000 || 6-...原创 2019-02-14 16:01:30 · 491 阅读 · 0 评论 -
SQL语句高级(五)——union、any、not in
一、子查询查询出cs系教师所教课程的成绩表!mysql> select * from teacher where depart = 'cs';+-----+-------+------+---------------------+------------+--------+| tno | tname | tsex | tbirthday | prof ...原创 2019-02-14 04:38:54 · 1961 阅读 · 0 评论