数据库系统实验课实验报告 - 图文 联系客服

发布时间 : 星期四 文章数据库系统实验课实验报告 - 图文更新完毕开始阅读1f0865919f3143323968011ca300a6c30c22f1b0

《数据库系统》实验报告一

学号 姓名 实验时间 实验名称 Oracle环境及数据库创建 实验学时 2 准备材料 1. Oracle 10G 介绍资料 2. SQL Plus命令手册 3. Oracle数据字典 扩展实验 1. 使用企业 管理器登录Oracle服务器,观察系统架构及数据库 2. 使用OEM创建、删除数据库 此部分内容不要求在实验室完成,不用写入实验报告。 实验环境 Oracle 9i(及以上版本)服务器 SQL Plus/ SQL Plus work sheet客户端 实验目的 1. 了解oracle系统架构 2. 熟悉SQL Plus环境 实验内容1. 使用SQL Plus Worksheet登录数据库系统(用户名密码由教师指及步骤 定) 2. 浏览SQL Plus环境设置命令,并完成下列操作: (1) 察看SQL Plus环境参数 (2) 设置输出页面的大小,每列字符数 120,每页行数100,观察设置结构 (3) 设置显示每个sql语句花费的执行时间,并观察实验结果 (4) 在SQL Plus中执行操作系统命令,例如copy文件、显示目录等,观察结果。 (5) 设置将系统输出数据写入文件c:\\textoutput.txt,执行多个命令后观察文件内容。 3. 显示系统信息 (1) 显示用户信息 (2) 显示数据库版本信息 (3) 显示数据库中所有表的名称 显示系统中某张表的结构信息(如EMP表) (4) 显示数据库中某张表的数据,如EMP表 4. 建立磁盘文本文件testcommand.sql,文件内写入几条SQL命令,执行此文件,并观察执行结果。 出现问题 解决方案 (列出遇到的问题及其解决方法) 《数据库系统》实验报告二

学号 姓名 实验时间 实验名称 数据库模式管理 实验学时 4 准备材料 1. SQL Plus命令手册 2. Oracle数据字典 3. Oracle中的数据类型 扩展实验 1. 掌握在企业管理器(或其它图形界面的数据库操作工具)中进行表、索引的创建和管理的方法。 2. 利用企业管理器(或其它图形界面的数据库操作工具)观察数据库的物理模式。 (此部分内容不要求在实验室完成,不用写入实验报告。) 实验环境 Oracle 9i(及以上版本)服务器 SQL Plus/ SQL Plus work sheet客户端 实验目的 1. 掌握使用SQL语句进行表的创建和管理的方法 2. 加深对关系数据库结构和数据完整性等概念的理解 实验内容1. 创建书上university数据库中所有的表(student, course, 及步骤 department, takes, instructor, advisor, prereq, teaches, classroom, section, timeslot),按书上要求设置每张表的主键、外键,表中每个字段的类型、长度由学生自己确定。 2. 使用命令完成下列扣作(1)查找用户所有表的表名(2)查看每张表的结构(要求把每张表的结构截图放到实验报告中)(3)查看表takes的约束信息 3. 修改表结构 (1) 在instructor表中增加列存储教师家庭地址,其地址包括省、市、区、街道、门牌号等列,列的数据类型自己给出,列允许为空。 (2) 对student表中的姓名字段长度都改为10,设置是否成功?原因是什么?将该字段长度改为50,能否成功?说明原因。 (3) 为student表中tot_cred列设置默认值 0,插入一个Comp. Sci.系的新学生,且不给其tot_cred列赋值,观察结果。 (4) student表中tot_cred列是对总学分的统计,现在数据库中没有记录哪些学生已选修课程学分已累加,哪些课程的学分还没有累加。设计一种方案记录已累加课程,防止出现重复累加的情况。或者设计一种方案简化总学分的计算过程。 (5) 删除takes表上对student表ID的外键约束,查看此约束已删除。添加一个不存在的学生(id=?201400320101?)选修course_id 为?CS001?的课程,并给他一个成绩(成绩值为:A, B, C, D, E 或F)。再添加takes表是对student表ID 的外键约束 ,观察并解释实验结果。 (6) 设置takes表ID, course_id,sec_id三个字段非空,是否能设置成功,对插入数据有没有影响? 删除takes表主键约束,增加某同学选同一门课程(id, couese_id, sec_id, semester, year, grade都相同)的信息,能否插入成功?解释原因。 4. 参照表student建立一张空表student1。要求用两种方法实现 (create table; create table as …)。 5. 增加section表上的约束条件,要求所输入section的年号不大于当前年号+1,且不小于当前年号-2。插入一条2009年秋CS-101 开设课的信息,观察并解释实验结果。 6. 选择某个约束,分别设置其有效、失效,观察区别。 出现问题 没有问题 解决方案 (列出遇到的问题及其解决方法) 《数据库系统》实验报告三

学号 姓名 实验时间 实验名称 数据查询 实验学时 4 准备材料 1. SQL Plus命令手册 2. Oracle数据字典 扩展实验 1. 利用企业管理器的图形界面构造查询语句,并察看查询结果 2. 利用企业管理器完成视图、索引的创建与使用。 3. 利用DBMS进行对第三章习题所设计SQL语句的检查 (此部分内容不要求在实验室完成,不用写入实验报告。) 实验环境 Oracle 9i(及以上版本)服务器 SQL Plus/ SQL Plus work sheet客户端 实验目的 1.掌握使用SQL语句进行数据查询的方法 2. 掌握视图的创建与使用方法 3. 观察索引的使用效果 实验内容1. 执行文件ddl+drop.sql,创建数据库University中所有表。执行文件 及步骤 smallRelationsInsertFile.sql,插入实验数据。 2. 使用University数据库的数据库结构和数据(smallRelations即可),完成下列查询: (1) Find the names of courses in Computer science department which have 3 credits (2) For the student with ID 12345 (or any other value), show all course_id and title of all courses registered for by the student. (3) As above, but show the total number of credits for such courses (taken by that student). Don't display the tot_creds value from the student table, you should use SQL aggregation on courses taken by the student. (4) As above, but display the total credits for each of the students, along with the ID of the student; don't bother about the name of the student. (Don't bother about students who have not registered for any course, they can be omitted) (5) Find the names of all students who have taken any Comp. Sci. course ever (there should be no duplicate names) (6) Display the IDs of all instructors who have never taught a couse (Notes 1) Oracle uses the keyword minus in place of except; 2) interpret \ (7) As above, but display the names of the instructors also, not just the IDs. (8) Find the maximum and minimum enrollment across all sections, considering only sections that had some enrollment, don't worry about those that had no students taking that section (9) As in Question (8), but now also include sections with no students taking them; the enrollment for such sections should be treated as 0. Do this in two different ways (and create require data for testing) 1). Using a scalar subquery 2). Using aggregation on a left outer join (use the SQL natural left outer join syntax) (10) Find all courses whose identifier starts with the string \ (11) Find instructors who have taught all the above courses 1). Using the \covered in class (don't forget the distinct clause!) 3. The university rules allow an F grade to be overridden by any pass grade (A, B, C, D). Now, create a view that lists information about all fail grades that have not been overridden (the view should contain all attributes from the takes relation). 4. Find all students who have 2 or more non-overridden F grades as per the takes relation, and list them along with the F 出现问题 解决方案 (列出遇到的问题及其解决方法)