当前位置:网站首页>TYUT太原理工大学2022数据库大题之数据库操作
TYUT太原理工大学2022数据库大题之数据库操作
2022-07-06 09:19:00 【啦啦噜噜^_^】
题型三
数据库操作有2类题型:
第一种是给出几组无数据的关系模式,对其进行数据库操作。eg:例1
第二种是给出若干有数据的结构表,对其进行数据操作。eg:例2
考点都是第四章,最好自己总结一下各种SQL语句,加强记忆
必备表单:

例1、
设职工-工会数据库具有三个基本表:
职工(职工号,名称,成立时间,性别);
工会(编号,名称,负责人职工号,活动地点);
参加(职工号,编号,参加日期)。
其中职工表的主键是职工号,工会表的主键是编号,参加表的主键是职工号和编号。试用SQL语句完成下列操作:
(1)定义职工表,其中职工号、名称、性别为字符型,成立时间为整型,职工号为主键;
(2)查询负责人职工号是“001”的会员的编号和名称;
(3)查询姓张的女职工的信息;
(4)将职工表中李四的成立时间增加1。
(5)查询成立时间在20岁到30岁之间职工的职工号、名称和成立时间,并将成立时间加上1输出;
(6)查询参加工会编号为“T1”的职工号。
解:


例2、
在某仓库管理系统中,有两个表:KC表保存当前仓库库存材料的信息和CKMX表存放库存材 料的出库明细,
其结构如下:
KC(材料代码,材料名称,单位,单价,库存数量)材料代码为主键;
CKMX(出库单编号,材料代码,出库日期,出库数量)出库单为主键,材料代码为外键。
- 试写出创建KC表和CKMX表的SQL语句,要求定义实体和参照完整性。
- 用SQL命令将如下表4-3和表4-4的数据分别插入到KC表和CKMX表中。
- 查询有关计算机的编号、出库日期、材料名称、单价、出库数量和金额的出库信息。
- 从表CKMX中统计出各种材料的出库次数和出库总数量,试写出SQL语句。
表4-3、KC表结构和数据
材料代码 | 材料名称 | 单位 | 单价 | 库存数量 |
01 | 计算机 | 台 | 5000.00 | 10 |
02 | 电视机 | 台 | 2000.00 | 20 |
表4-4、CKMX表结构和数据
| 出库单编号 | 材料代码 | 出库日期 | 出库数量 |
1 | 01 | 2020-10-10 | 4 |
2 | 01 | 2020-11-20 | 3 |
3 | 02 | 2020-11-20 | 5 |
解:

补充:有个东西叫通配符:a%b表示以a开头b结尾的任意长度的字符串 eg:akdhb
用BETWEEN表示包含 eg:20<时间<50 写成SQL得写成 时间 BETWEEN 20 AND 50
老师画重点时,只说第四章会出SQL语言大题(往年也是),所以在此没有总结视图、索引的SQL语句笔记,只要把我文章开头的总结背下来,再做几道例题,考试完全够用
边栏推荐
- [algorithm] sword finger offer2 golang interview question 5: maximum product of word length
- 异常:IOException:Stream Closed
- Error: sorting and subscript out of bounds
- Devops' future: six trends in 2022 and beyond
- 初识指针笔记
- Realization of the code for calculating the mean square error of GPS Height Fitting
- Heap sort [handwritten small root heap]
- MySQL 30000 word essence summary + 100 interview questions, hanging the interviewer is more than enough (Collection Series
- [Yu Yue education] guide business reference materials of Wuxi Vocational and Technical College of Commerce
- 国企秋招经验总结
猜你喜欢

XV Function definition and call
![[算法] 剑指offer2 golang 面试题4:只出现一次的数字](/img/f7/23ffc81ec8e9161c15d863c1a67916.png)
[算法] 剑指offer2 golang 面试题4:只出现一次的数字
![[algorithm] sword finger offer2 golang interview question 8: the shortest subarray with a sum greater than or equal to K](/img/8c/1b6ba3b1830ad28176190170c98628.png)
[algorithm] sword finger offer2 golang interview question 8: the shortest subarray with a sum greater than or equal to K

String类

【无标题】

Wechat applet development experience

一文搞定 UDP 和 TCP 高频面试题!

MySQL 30000 word essence summary + 100 interview questions, hanging the interviewer is more than enough (Collection Series

2-year experience summary, tell you how to do a good job in project management

2022 National Games RE1 baby_ tree
随机推荐
4.30动态内存分配笔记
[算法] 剑指offer2 golang 面试题7:数组中和为0的3个数字
系统设计学习(二)Design a key-value cache to save the results of the most recent web server queries
Record: I accidentally wrote a recursion next time
Lean product development - Lean Software Development & lean product development
Sharing ideas of on-chip transplantation based on rtklib source code
Fairygui loop list
Excel导入,导出功能实现
几道高频的JVM面试题
继承和多态(上)
[rtklib 2.4.3 B34] version update introduction I
编辑距离(多源BFS)
2022国赛Re1 baby_tree
基本Dos命令
Iterable、Collection、List 的常见方法签名以及含义
[algorithm] sword finger offer2 golang interview question 6: sum of two numbers in the sorting array
[algorithm] sword finger offer2 golang interview question 5: maximum product of word length
Record: the solution of MySQL denial of access when CMD starts for the first time
阿里云微服务(三)Sentinel开源流控熔断降级组件
MySQL 30000 word essence summary + 100 interview questions, hanging the interviewer is more than enough (Collection Series