实验二:数据库操作
一、实验目的
1.熟悉数据表结构及使用特点;
2.熟悉使用Management Stuio界面方式管理数据表数据;
3.熟悉使用T-SQL语句管理数据表数据;
4.掌握SELECT语句的基本语法和查询条件表示方法;
5.掌握查询条件表达式和使用方法;
6.掌握GROUP BY 子句的作用和使用方法;
7.掌握HAVING子句的作用和使用方法;
8.掌握ORDER BY子句的作用和使用方法;
9.掌握连接查询的表示及使用;
10.掌握嵌套查询的表示及使用;
11.了解集合查询的表示及使用。
二、实验环境
已安装SQL Server 2008的计算机;
具有局域网环境,有固定IP;
三、实验学时
2学时
四、实验要求
1.了解数据库查询以及其他操作;
2.了解数据库查询以及其他操作的实现方式;
3.完成实验报告;
五、实验内容及步骤
首先建立student,SC,course表并导入数据:
① 查询所有SC表数据:
② 执行语句select sno,sage from student where sdept=‘计算机系’:
③ 执行语句select sno,cno,grade from SC where grade between 70 and 80:
④ 执行语句select sname,sage from student where sdept='计算机系’and sage between 10 and 20 and ssex like ‘男%’
⑤ 执行语句select max(grade) as '最高分’from SC where cno=‘c001’
⑤ 执行语句select max(grade) as '最高分’from SC where cno=‘c001’
⑥ 执行语句select max(sage) as ‘最大年龄’,min(sage) as '最小年龄’from student where sdept=‘计算机系’
⑦ 执行语句select sdept,count() as’学生人数’from student group by sdept
⑨ 执行语句select cn