数据库实验答案

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

数据库实验答案
1)找出 MGM studios 的地址。

select 地址
from 制片公司
where 公司名称='MGM studios'
2)找出 Sandra Bullock 的出生日期。

select 生日
from 电影明星
where 姓名='Sandra Bullock'
3)找出在2003年拍摄过电影的所有影星,或者拍摄过电影中含有"天空"的电影的所有明星。

select 演员姓名
from 演员参演电影
where 拍摄年份=2003 or 电影名称 like'%天空%'
4)找出净资产至少1000万美元的所有行政长官。

select 姓名
from 制片人与行政总裁
where 资产>=10000000
5)找出所有的男影星或者是住址中含有 Malibu 的影星。

select 姓名
from 电影明星
where 地址 like 'Malibu' or 性别 like '男'
1)电影"加勒比海盗4"中的男影星都有谁。

select 姓名
from 电影明星
where 性别 ='男' and 姓名 in
(
select 演员姓名
from 演员参演电影
where 电影名称='加勒比海盗4'
)
2)谁是米高梅制片公司的总裁。

select 姓名
from 制片人与行政总裁
where 身份证号 =
( select 行政总裁
from 制片公司
where 公司名称 ='MGM studios'
)
4)那些电影比《乱世佳人》更长。

select 电影名称
from 电影
where 长度 >
(
select 长度
from 电影
where 电影名称 = '乱世佳人'
)
5)那些行政长官比 T om 更富有。

select 姓名
from 制片人与行政总裁
where 资产>
(
select 资产
from 制片人与行政总裁
where 姓名='T om'
)
1、找出价格低于6000元的PC计算机型号、速度、以及硬盘容量。

select 型号,速度,硬盘容量
from PC电脑
where 价钱 < 6000
2、同上要求,另外将 "速度" 改名为 "兆赫",将 "硬盘" 改名为 "G 字节"。

select 型号,速度兆赫,硬盘容量 G字节
from PC电脑
where 价钱 < 6000
3、找出打印机的制造商。

select 制造商
from 产品
where 产品类型 = '打印机'
4、找出价格高于2000元的"便携式电脑"的型号、内存容量及屏幕大小。

select 型号,内存,屏幕大小
from 便携式电脑
where 价钱 > 6000
5、从"打印机"关系中找出所有彩色打印机的元组。

select *
from 打印机
where 是否彩色 = '是'
6、找出具有300GB以上的硬盘容量而价格低于2000元的所有个人计算机的型号、速度及硬盘。

select 型号,速度,硬盘容量
from PC电脑
where 硬盘容量>300 and 价钱 <6000
1、找出配置了容量至少为300GB硬盘的便携式电脑的制造商及其速度。

select 制造商,速度
from 产品,便携式电脑
where 产品型号=便携式电脑.型号 and 硬盘>300
2、找出由生产厂商"苹果"生产的所有产品的型号和价格。

select 型号,价钱
from PC电脑
where 型号 in
(
select 产品型号
from 产品
where 制造商='苹果'
)
union
select 型号,价钱
from 便携式电脑
where 型号 in
(
select 产品型号
from 产品
where 制造商='苹果'
)
union
select 型号,价钱
from 打印机
where 型号 in
(
select 产品型号
from 产品
where 制造商='苹果'
)
3、找出所有出售"便携式电脑"(而不出售PC)的生产厂商。

select 制造商
from 产品
where 产品类型 LIKE '便携式电脑' and 制造商 not in
(
select 制造商
from 产品
where 产品类型 LIKE 'PC电脑' or 产品类型 LIKE '打印机' )
4、找出在两种或两种以上PC上出现的硬盘容量。

select 硬盘容量
from PC电脑
group by 硬盘容量
having count(*)>=2
5、找出拥有相同速度和内存的PC的成对的型号。

select distinct Q.型号,P.型号
from PC电脑 Q, PC电脑 P
where Q.速度=P.速度 and Q.内存=P.内存 and Q.型号<p.型号< p="">
1、找出速度至少为1500MHz的"PC电脑"制造商。

("=any"和"in") select distinct 制造商
from 产品
where 产品类型='PC电脑' and 产品型号 in
(
select 型号
from PC电脑
where 速度>=1500
)
2、找出价格最高的打印机。

(注意">all" 和">any" 的区别) (">=all"和"=max()") select 型号
from 打印机
where 价钱 >=all
(
select 价钱
from 打印机
)
3、找出速度低于任何PC的便携式电脑。

(注意"<all"和"<any"的区别)< p="">
select 型号
from 便携式电脑
where 速度 < all
(
select 速度
from PC电脑
)
4、找出具有最高价格的机器(PC,便携式电脑或打印机)的型号。

select 型号
from PC电脑
where 价钱=
(
select MAX(价钱)
from PC电脑
)
union
select 型号
from 便携式电脑
where 价钱=
(
select MAX(价钱)
from 便携式电脑
)
union
select 型号
from 打印机
where 价钱=
(
select MAX(价钱)
from 打印机
)
5、找出具有最低价格的彩色"打印机"的制造商。

("=any和in" "<=all和MIN()") select 制造商
from 产品
where 产品型号 =any
(
select 型号
from 打印机
where 价钱<=all
(
select 价钱
from 打印机
where 是否彩色 ='是'
)
)
6、找出在具有最小内存容量的所有PC 中,具有最快处理器的PC 制造商。

select 制造商
from 产品
where 产品型号 =any
(
select 型号
from PC电脑
where 速度 =
(
select MAX(速度)
from PC电脑
where 内存<=all
(
select 内存
from PC电脑
)
)
and 内存 in
(
select min(内存)
from pc电脑
)
)
select 制造商
from 产品
where 产品型号 in
(
</all"和"<any"的区别)<> </p.型号<>。

相关文档
最新文档