【期末复习】(免费)2021-2022南邮数据库系统原理期末复习题

南京邮电大学数据库系统原理期末复习题

官方牛牛

要ppt 的点下面链接:

http://链接:https://pan.baidu.com/s/1VoIFMQzWheCyfJbj2DpdPg?pwd=dwss 提取码:dwss

放图片了,太麻烦,需要的同学点击下方链接(free)

ppt样题请看下方:

【期末复习】2021-2022南邮数据库系统原理期末复习题ppt

封面:

实 验 报 告

实验名称

创建数据库模式与SQL查询

指导教师

朱云霞

实验类型

验证

实验学时

4

实验时间

  • 实验目的和要求

(1) 通过上机实践,熟悉PostgreSQL的操作环境及使用方法。

(2) 掌握数据表的创建以及表的操作。

(3) 熟练掌握Select-SQL命令,进行数据的查询。

二、实验环境(实验设备)

硬件:微机

软件:Windows xp/Windows 7和PostgreSQL

素材:实验数据

三、实验内容

1. 创建产品数据库products;

Create schema products authorization hr

2. 采用CREATE TABLE语句创建产品数据库数据库products的关系模式:

Product (maker, model, type)

create table product (

maker char(3),

model smallint primary key,

type char(10));

PC (model, speed, ram, hd, price)

create table pc (

model smallint primary key,

speed numeric(3,2),

ram int,

hd smallint,

price int);

Laptop (model, speed, ram, hd, screen, price)

Create table laptop(

Model smallint primary key,

Speed numeric(3,2),

ram int,

hd smallint,

Screen numeric(3,1)

price smallint);

Printer (model, color, type, price)

    Create table printer (

Model smallint primary key,

Color boolean,

Type char(10),

Price smallint);

3. 采用COPY…FROM…语句将数据装入产品数据库;

Copy proudct from ‘D:\data\product.txt’ with delimiter;

Copy pc from ‘D:\data\pc.txt’ with delimiter;

Copy laptop from ‘D:\data\laptop.txt’ with delimiter;

Copy printer from ‘D:\data\printer.txt’ with delimiter;

4. 在产品数据库中用SQL语句完成下列查询:

① 查询速度大于等于3.00的PC型号;

Select model,speed from pc where speed > 3.00;

② 查询能生产硬盘容量100GB以上的笔记本电脑的厂商;

Select distinct maker from product where model in (

select model from laptop where hd > 100)

③ 查询厂商B生产的所有产品的型号和价格;

select * from  (

(select model, price

from (select * from product where maker='B' ) P1 join PC) union

(select model, price

from (select * from product where maker='B' ) P2 join Laptop) union

(select model, price

from (select * from Product where maker='B' ) P3 join Laptop))

④ 查询所有彩色激光打印机的型号;

Select model from printer where type = ‘laser’;

⑤ 查询那些只出售笔记本电脑不出售PC的厂商;

select distinct maker from product where maker not in (

Select distinct maker from product

where model in(select model from pc) )

and maker in (Select distinct maker from product

where model in(select model from laptop) )

⑥ 查询在两种以上PC机中出现过的硬盘容量。

select hd from pc group by hd having count(*) >= 2

5. 在产品数据库中采用SQL命令完成以下操作:

① 将速度大于等于2的Laptop的价格上调10%;

Update Laptop set price = 1.1*price where speed >= 2;

② 在PC表中增加一条新记录:

1014

4.15

2048

300

800

insert into pc values(1014,4.15,2048,300,800);

③ 删除PC表中hd小于100且price小于500的记录。

Delect from pc where hd <100 and pricr <500;

四、实验小结(写出实验过程中所遇到的问题和解决的办法,解决问题的过程中得到的经验和体会)

问题:在多表查询中无法精确的select想要的属性?

解决方法:给pcproduct表分别做别名 p1 , p2,利用 “p1.”正确的找到想要的属性。

体会:还是要多看多读书本,把书上的知识融会贯通,再实际操作中找出自己的不足。

猜你喜欢

转载自blog.csdn.net/dw1360585641/article/details/125363518