mysql视图练习题
时间: 2023-10-17 10:37:58 浏览: 129
MySQL视图练习题包括以下内容:
1)创建考上Peking University的学生的视图
2)创建考上Tsinghua University的学生的视图
3)对XiaoTian的成绩进行更正,将多录的50分进行修改
4)查看更新过后视图和表的情况
5)查看视图的创建信息
6)删除创建的视图
具体步骤如下:
1)创建考上Peking University的学生的视图:
CREATE VIEW peking_students AS
SELECT * FROM students WHERE university = 'Peking University';
2)创建考上Tsinghua University的学生的视图:
CREATE VIEW tsinghua_students AS
SELECT * FROM students WHERE university = 'Tsinghua University';
3)对XiaoTian的成绩进行更正,将多录的50分进行修改:
UPDATE students SET score = score - 50 WHERE name = 'XiaoTian';
4)查看更新过后视图和表的情况:
SELECT * FROM peking_students;
SELECT * FROM students;
5)查看视图的创建信息:
SHOW CREATE VIEW peking_students;
6)删除创建的视图:
DROP VIEW peking_students;
DROP VIEW tsinghua_students;<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [MySQL视图(简介 & 练习)](https://blog.csdn.net/JohnnyG2000/article/details/124543049)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [mysql 查询练习题](https://download.csdn.net/download/qq_40717644/10857398)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文