数据库sql实验报告书

上传人:第*** 文档编号:57515993 上传时间:2018-10-22 格式:PDF 页数:19 大小:517.06KB
返回 下载 相关 举报
数据库sql实验报告书_第1页
第1页 / 共19页
数据库sql实验报告书_第2页
第2页 / 共19页
数据库sql实验报告书_第3页
第3页 / 共19页
数据库sql实验报告书_第4页
第4页 / 共19页
数据库sql实验报告书_第5页
第5页 / 共19页
点击查看更多>>
资源描述

《数据库sql实验报告书》由会员分享,可在线阅读,更多相关《数据库sql实验报告书(19页珍藏版)》请在金锄头文库上搜索。

1、南京理工大学紫金学院 实 验 报 告 书课程名称:数据库系统实验题目:实验 1用 SQL 语句创建数据库和表班级:计算机科学与技术 2 班学号:09061257姓名:朱书宏指导教师:叶庆生成绩:批阅教师:年月日数据库系统实验报告090601257 朱书宏- 1 -一、实验目的1. 使用 SQL2005 练习使用 SQL 语句创建数据库与表2练习 SQL 查询、修改、删除等语句语句3.掌握数据库中创建表时主键、约束条件的纂写二 .实验内容1根据下列数据库模式,用 SQL 语句创建一个适当地数据库,并创建相关的表,注意表中的主键和 外键及某些属性域的约束。 Product(marker, mode

2、l, type) PC(model, speed, ram, hd, rd, price) Laptop(model, speed, ram ,hd, screen, price) Printer(model, color, type, price) 2根据下列数据库模式,用 SQL 语句创建一个适当地数据库,并创建相关的表,注意表中的主键和 外键及某些属性域的约束。 Classes ( class , type , country , numCuns , bore , displacement ) Ships( name , class , launched ) Battles( name

3、, date ) Outcomes ( ship , battle , result ) 3将相关的数据用 SQL 语句插入到数据中。 4基于习题 5.2.4 给出的数据库模式和数据写出后面的查询语句以及查询结果。 Classes ( class , type , country , numCuns , bore , displacement ) Ships( name , class , launched ) Battles( name , date ) Outcomes ( ship , battle , result ) a)找出战舰类型的数量。 b)找出不同类型战舰拥有的平均火炮数量。

4、 !c)找出战舰的平均火炮数量。注意 c)和 b)的不同在于:在计算均值的时候,是使用战舰 的数目还是战舰的类型数目。 !d)找出每一类型( class )的第一艘船下水的年份。 !e)找出每一类型中被击沉船的数目。 !f) 找出至少有 3 艘船的类型中被击沉的船的数目。 !g)军舰火炮使用的炮弹的重量(以磅为单位)大约是火炮的口径(以英寸为单位)的一半。 找出各个国家的军舰炮弹重量的平均值。 5 根据习题 5.2.1 给出的数据库模式, 写出下面的数据库修改。 描述对该习题数据库修改够的结果。 Product(marker, model, type) PC(model, speed, ram

5、, hd, rd, price) Laptop(model, speed, ram ,hd, screen, price) Printer(model, color, type, price) a) 通过两条 INSERT 语句在数据库中添加如下信息:制造商 C 生产的型号为 1100 的 PC,速 度为 1800,RAM 为 256,硬盘大小 80,具有一个 20x 的 DVD,售价为$2499。 !b) 加入如下信息:对于数据库中每台 PC,都对应一台与其速度、RAM、硬盘相同,具有 15 英寸的屏幕,型号大于 1100、价格高于$500 的相同厂商制造的手提电脑。 c) 删除所有硬盘不超

6、过 20G 的 PC。数据库系统实验报告090601257 朱书宏- 2 -d) 删除所有不制造打印机的厂商生产的手提电脑。 e) 厂商 A 收购了厂商 B,将所有 B 生产的产品改为由 A 生产。 f) 对于每台 PC,把它的内存加倍并且增加 20G 的硬盘容量。 (记住 UPDATE 语句中可以同时 更改多个属性的值) !g) 把厂商 B 生产的手提电脑的屏幕尺寸增加一英寸并且价格下调$100。三、实验步骤1创建数据库 表2. 编写 SQL 语句3,在 SQL2005 上调试语句并运行结果四、实验结果1根据下列数据库模式,用 SQL 语句创建一个适当地数据库,并创建相关的表,注意表中的 主

7、键和外键及某些属性域的约束。 Product(marker, model, type) PC(model, speed, ram, hd, rd, price) Laptop(model, speed, ram ,hd, screen, price) Printer(model, color, type, price) SQL语句: create database zuoye1create table product(marker varchar(16) primary key,model varchar(16) not null,type varchar(16) not null,)crea

8、te table PC(model varchar(16) primary key,speed varchar(16) not null,ramvarchar(16) not null,hdvarchar(16) not null,rdvarchar(16) not null,priceint not null)create table laptop(model varchar(16) primary key,speed varchar(16) not null,ram varchar(16) not null,hd varchar(16) not null,screem varchar(16

9、) not null,price int not null,)数据库系统实验报告090601257 朱书宏- 3 -create table printer(model varchar(16) primary key,color varchar(16) not null,typevarchar(16) not null,price int not null,)2根据下列数据库模式,用 SQL 语句创建一个适当地数据库,并创建相关的表,注意表中的主键和 外键及某些属性域的约束。 Classes ( class , type , country , numCuns , bore , displac

10、ement ) Ships( name , class , launched ) Battles( name , date ) Outcomes ( ship , battle , result )SQL 语句:create database zuoye2create tableClasses(class varchar(16)primary key not null,type varchar(16) not null,country varchar(16) not null,numGuns int,bore int,displacement int,)create table Ships(n

11、ame varchar(16) primary key,class varchar(16) not null,launched varchar(16) not null,)create table Battles(name varchar(16) primary key,date varchar(16) not null,)create table Outcomes(ship varchar(16) primary key,battle varchar(16) not null,result varchar(16) not null,)3将相关的数据用 SQL 语句插入到数据中。SQL 语句:

12、数据库系统实验报告090601257 朱书宏- 4 - 数据库 1:zuoye1insertinto Product (marker,model,type)values(A,1001,pc);insertinto Product (marker,model,type)values(A,1002,pc);insertinto Product (marker,model,type)values(A,1003,pc);insertinto Product (marker,model,type)values(A,2004,laptop);insertinto Product (marker,model

13、,type)values(A,2005,laptop);insertinto Product (marker,model,type)values(A,2006,laptop);insertinto Product (marker,model,type)values(B,1004,pc);insertinto Product (marker,model,type)values(B,1005,pc);insertinto Product (marker,model,type)values(B,1006,pc);insertinto Product (marker,model,type)values

14、(B,2007,laptop);insertinto Product (marker,model,type)values(C,1007,pc);insertinto Product (marker,model,type)values(D,1008,pc);insertinto Product (marker,model,type)values(D,1009,pc);insertinto Product (marker,model,type)values(D,1010,pc);insertinto Product (marker,model,type)values(D,3004,printer)

15、;数据库系统实验报告090601257 朱书宏- 5 -insertinto Product (marker,model,type)values(D,3005,printer);insertinto Product (marker,model,type)values(E,1011,pc);insertinto Product (marker,model,type)values(E,1012,pc);insertinto Product (marker,model,type)values(E,1013,pc);insertinto Product (marker,model,type)value

16、s(E,2001,laptop);insertinto Product (marker,model,type)values(E,2002,laptop);insertinto Product (marker,model,type)values(E,2003,laptop);insertinto Product (marker,model,type)values(E,3001,printer);insertinto Product (marker,model,type)values(E,3002,printer);insertinto Product (marker,model,type)values(E,3003,printer);insertinto Product (marker,model,type)values(F,20

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 教育/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号