




已閱讀5頁,還剩9頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
.1)找出 MGM studios 的地址。select 地址 from 制片公司where 公司名稱=MGM studios2)找出 Sandra Bullock 的出生日期。select 生日from 電影明星where 姓名=Sandra Bullock3)找出在2003年拍攝過電影的所有影星,或者拍攝過電影中含有天空的電影的所有明星。select 演員姓名from 演員參演電影where 拍攝年份=2003 or 電影名稱 like%天空%4)找出凈資產(chǎn)至少1000萬美元的所有行政長官。select 姓名from 制片人與行政總裁where 資產(chǎn)=100000005)找出所有的男影星或者是住址中含有 Malibu 的影星。select 姓名from 電影明星where 地址 like Malibu or 性別 like 男1)電影加勒比海盜4中的男影星都有誰。select 姓名from 電影明星where 性別 =男 and 姓名 in(select 演員姓名from 演員參演電影where 電影名稱=加勒比海盜4)2)誰是米高梅制片公司的總裁。select 姓名from 制片人與行政總裁where 身份證號(hào) =(select 行政總裁from 制片公司where 公司名稱 =MGM studios)4)那些電影比亂世佳人更長。select 電影名稱from 電影where 長度 (select 長度from 電影where 電影名稱 = 亂世佳人)5)那些行政長官比 Tom 更富有。select 姓名from 制片人與行政總裁where 資產(chǎn)(select 資產(chǎn)from 制片人與行政總裁where 姓名=Tom)1、找出價(jià)格低于6000元的PC計(jì)算機(jī)型號(hào)、速度、以及硬盤容量。select 型號(hào),速度,硬盤容量from PC電腦where 價(jià)錢 60002、同上要求,另外將 速度 改名為 兆赫,將 硬盤 改名為 G字節(jié)。select 型號(hào),速度 兆赫,硬盤容量 G字節(jié)from PC電腦where 價(jià)錢 60005、從打印機(jī)關(guān)系中找出所有彩色打印機(jī)的元組。select *from 打印機(jī)where 是否彩色 = 是6、找出具有300GB以上的硬盤容量而價(jià)格低于2000元的所有個(gè)人計(jì)算機(jī)的型號(hào)、速度及硬盤。select 型號(hào),速度,硬盤容量from PC電腦where 硬盤容量300 and 價(jià)錢 3002、找出由生產(chǎn)廠商蘋果生產(chǎn)的所有產(chǎn)品的型號(hào)和價(jià)格。select 型號(hào),價(jià)錢from PC電腦where 型號(hào) in(select 產(chǎn)品型號(hào)from 產(chǎn)品where 制造商=蘋果)unionselect 型號(hào),價(jià)錢from 便攜式電腦where 型號(hào) in(select 產(chǎn)品型號(hào)from 產(chǎn)品where 制造商=蘋果)unionselect 型號(hào),價(jià)錢from 打印機(jī)where 型號(hào) in(select 產(chǎn)品型號(hào)from 產(chǎn)品where 制造商=蘋果)3、找出所有出售便攜式電腦(而不出售PC)的生產(chǎn)廠商。select 制造商from 產(chǎn)品where 產(chǎn)品類型 LIKE 便攜式電腦 and 制造商 not in(select 制造商from 產(chǎn)品where 產(chǎn)品類型 LIKE PC電腦 or 產(chǎn)品類型 LIKE 打印機(jī))4、找出在兩種或兩種以上PC上出現(xiàn)的硬盤容量。select 硬盤容量from PC電腦group by 硬盤容量having count(*)=25、找出擁有相同速度和內(nèi)存的PC的成對(duì)的型號(hào)。select distinct Q.型號(hào),P.型號(hào)from PC電腦 Q, PC電腦 Pwhere Q.速度=P.速度 and Q.內(nèi)存=P.內(nèi)存 and Q.型號(hào)=1500)2、找出價(jià)格最高的打印機(jī)。(注意 all 和 any 的區(qū)別) (=all和=max()select 型號(hào)from 打印機(jī)where 價(jià)錢 =all(select 價(jià)錢from 打印機(jī))3、找出速度低于任何PC的便攜式電腦。(注意all和any的區(qū)別)select 型號(hào)from 便攜式電腦where 速度 all(select 速度from PC電腦)4、找出具有最高價(jià)格的機(jī)器(PC,便攜式電腦或打印機(jī))的型號(hào)。select 型號(hào)from PC電腦where 價(jià)錢=(select MAX(價(jià)錢)from PC電腦)unionselect 型號(hào)from 便攜式電腦where 價(jià)錢=(select MAX(價(jià)錢)from 便攜式電腦)unionselect 型號(hào)from 打印機(jī)where 價(jià)錢=(select MAX(價(jià)錢)from 打印機(jī))5、找出具有最低價(jià)格的彩色打印機(jī)的制造商。(=any和in =all和MIN()select 制造商from 產(chǎn)品where 產(chǎn)品型號(hào) =any(select 型號(hào)from 打印機(jī)where 價(jià)錢=all(select 價(jià)錢from 打印機(jī)where 是否彩色 =是)6、找出在具有最小內(nèi)存容量的所有 PC 中,具有最快處理器的 PC 制造商。select 制造商from 產(chǎn)品where 產(chǎn)品型號(hào) =any(select 型號(hào)from PC電腦where 速度 =(select MAX(速度) from PC電腦where 內(nèi)存=all(select 內(nèi)存from PC電腦)and 內(nèi)存 in(select min(內(nèi)存)from pc電腦)select 制造商from 產(chǎn)品where 產(chǎn)品型號(hào) in(select 型號(hào)from PC電腦where 速度=(select MAX(速度)from PC電腦where 內(nèi)存=(select MIN(內(nèi)存)from PC電腦)and 內(nèi)存 in(select MIN(內(nèi)存)from pc電腦)select 制造商from 產(chǎn)品,PC電腦where 產(chǎn)品.產(chǎn)品型號(hào)=PC電腦.型號(hào) andPC電腦.速度=(select MAX(速度)from PC電腦where 內(nèi)存133 and 產(chǎn)品類型 LIKE PC電腦 or 產(chǎn)品類型 LIKE 便攜式電腦 and 制造商 in(select min(制造商)from vproductgroup by 制造商having COUNT(產(chǎn)品型號(hào))=2)3、找出生產(chǎn)最高速度的計(jì)算機(jī)(PC電腦或便攜式電腦)廠商。select distinct 制造商from vproductwhere 速度133 and 產(chǎn)品類型 LIKE PC電腦 or 產(chǎn)品類型 LIKE 便攜式電腦 and 制造商 in(select min(制造商)from vproductgroup by 制造商having COUNT(產(chǎn)品型號(hào))=2)create view 最高速度1asselect distinct 制造商from 產(chǎn)品,PC電腦where 產(chǎn)品.產(chǎn)品型號(hào)=PC電腦.型號(hào)and 速度=(select MAX(速度)from PC電腦)unionselect distinct 制造商from 產(chǎn)品,便攜式電腦where 產(chǎn)品.產(chǎn)品型號(hào)=便攜式電腦.型號(hào)and 速度=(select MAX(速度)from 便攜式電腦 )4、找出至少生產(chǎn)三種不同速度 PC的廠商。select distinct 制造商from vproductwhere 產(chǎn)品類型 LIKE PC電腦 and 制造商 in (select min(制造商) from vproduct group by 產(chǎn)品類型 having count(速度)=3)5.找出只賣三種不同型號(hào)的PC的廠商。create view 三種asselect 制造商from 產(chǎn)品 A where A.產(chǎn)品型號(hào)=any(select 型號(hào)from PC電腦 )AND A.制造商 not in (select B.制造商from 產(chǎn)品 Bwhere 產(chǎn)品類型=便攜式電腦 or 產(chǎn)品類型=打印機(jī) )GROUP BY 制造商having count(*)=3create view vproduct3(制造商,產(chǎn)品型號(hào),產(chǎn)品類型)asselect 制造商,產(chǎn)品型號(hào),產(chǎn)品類型from 產(chǎn)品where 制造商 not in(select 制造商 from 產(chǎn)品 where 產(chǎn)品類型 LIKE 便攜式電腦 or 產(chǎn)品類型 LIKE 打印機(jī))select 制造商from vproduct3group by 制造商having count(產(chǎn)品型號(hào))=2select avg(速度)from PC電腦select avg(速度)from 便攜式電腦where 價(jià)錢2500select avg(價(jià)錢)from PC電腦where 型號(hào) in(select 產(chǎn)品型號(hào)from 產(chǎn)品 where 制造商=A)實(shí)驗(yàn)六1)找出PC的平均速度。select AVG(速度)from vproduct3 where 產(chǎn)品類型=PC電腦2)找出價(jià)格超過2500美元的便攜式電腦的平均速度。select AVG(速度)from vproduct3where 產(chǎn)品類型=便攜式電腦 and 價(jià)錢25003)找出廠商A生產(chǎn)PC的平均價(jià)格。select AVG(價(jià)錢)from vproduct3where 制造商=A and 產(chǎn)品類型=PC電腦4)找出廠商D生產(chǎn)的PC和便攜式電腦的平均價(jià)格。select AVG(價(jià)錢)from vproduct3where 制造商=D(5)找出各種不同速率的pc的平均價(jià)格create view fiveasselect 價(jià)錢,速度from PC電腦select 速度,AVG(價(jià)錢) as 平均價(jià)錢from fivegroup by 速度直接查詢select 速度,AVG(價(jià)錢)from PC電腦group by 速度6)找出各廠商生產(chǎn)的便攜式電腦的顯示器平均尺寸。create view vproduct4(制造商,產(chǎn)品型號(hào),速度,價(jià)錢,屏幕大小)asselect 制造商,產(chǎn)品型號(hào),速度,價(jià)錢,屏幕大小from 產(chǎn)品,便攜式電腦where 產(chǎn)品.產(chǎn)品型號(hào)=便攜式電腦.型號(hào)select 制造商,AVG(屏幕大小)from vproduct4group by 制造商7)找出生產(chǎn)三種不同型號(hào)的PC的廠商。create view vproduct5(制造商,產(chǎn)品型號(hào),產(chǎn)品類型,價(jià)錢)asselect 制造商,產(chǎn)品型號(hào),產(chǎn)品類型,價(jià)錢from 產(chǎn)品,PC電腦 where 產(chǎn)品.產(chǎn)品型號(hào)=PC電腦.型號(hào)select 制造商from vproduct5group by 制造商having count(產(chǎn)品型號(hào))=38)找出各廠商生產(chǎn)的PC的最高價(jià)格。select 制造商,MAX(價(jià)錢)from vproduct5group by 制造商9)找出速度超過150MHz的各種速度的PC的平均價(jià)格。select AVG(速度)from vproduct3where 產(chǎn)品類型=PC電腦 and 速度15010)找出所有生產(chǎn)打印機(jī)的廠商生產(chǎn)PC的硬盤平均容量。create view nowasselect 制造商,產(chǎn)品型號(hào)from 產(chǎn)品where 制造商 in(select 制造商 from 產(chǎn)品where 產(chǎn)品類型=打印機(jī))and 產(chǎn)品類型=PC電腦create view now1asselect 制造商,產(chǎn)品型號(hào),硬盤容量from now,PC電腦where now.產(chǎn)品型號(hào)=PC電腦.型號(hào)select avg(硬盤容量)平均硬盤容量from now1實(shí)驗(yàn)七1)create procedure P1制造商 char(10),產(chǎn)品型號(hào) char(10),產(chǎn)品類型 char(10),速度 int,內(nèi)存 int,硬盤容量 int,價(jià)錢 money asbegin transactiondeclare error1 intinsert into 產(chǎn)品 values(制造商,產(chǎn)品型號(hào),產(chǎn)品類型)set error1=error1+errorinsert into PC電腦 values(產(chǎn)品型號(hào),速度,內(nèi)存,硬盤容量,價(jià)錢)set error1=error1+errorif(error10) beginprint 插入失敗,回滾事物rollback transactionendelsebeginprint 成插入成功,提交事物commit transactionendexec P1 制造商=C,產(chǎn)品型號(hào)=11100,產(chǎn)品類型=PC電腦,速度=240,內(nèi)存=32,硬盤容量=2.5,價(jià)錢=24992)create procedure P2 as begin transactiondeclare Error2 intinsert into 產(chǎn)品(制造商,產(chǎn)品型號(hào),產(chǎn)品類型)select 制造商,產(chǎn)品型號(hào)+1100,便攜式電腦from 產(chǎn)品where 產(chǎn)品.產(chǎn)品類型=PC電腦set Error2=Error2+errorinsert into 便攜式電腦(型號(hào),速度,內(nèi)存,硬盤,屏幕大小,價(jià)錢)select 型號(hào)+1100,速度,內(nèi)存,硬盤容量,11,價(jià)錢+500from PC電腦set Error2=Error2+errorif(Error20)beginprint插入失敗,回滾事物rollback transactionendelsebeginprint插入成功,提交事物commit transactionend3)create trigger P3on PC電腦for deleteasdelete from 產(chǎn)品where 產(chǎn)品型號(hào) in (select 型號(hào) from deleted)delete from PC電腦where 硬盤容量50create trigger P4on 產(chǎn)品for updateasdeclare 型號(hào)1 char(10)declare 制造商 char(10)select 型號(hào)1=產(chǎn)品型號(hào) from insertedselect 制造商=制造商from inserted bwhere b.產(chǎn)品型號(hào)=型號(hào)1if 制造商 is nullbegin print 錯(cuò)誤!rollback transactionendupdate 產(chǎn)品set 制造商=Awhere 制造商=B(4)廠商A收購了B,將所有由B制造的產(chǎn)品改為A制造declare MyCursor cursorDYNAMICfor select 制造商,產(chǎn)品型號(hào),產(chǎn)品類型from 產(chǎn)品where 制造商 = Bfor updateopen MyCursorfetch next from MyCursorupdate 產(chǎn)品set 制造商 = Awhere current of MyCursorwhile(FETCH_STATUS =0)beginfetch next from MyCursorupdate 產(chǎn)品set 制造商 = Awhere current of MyCursorENDdeallocate MyCursorcreate database Moviescreate table 電影明星( 姓名 varchar(20) not null primary key, 地址 varchar(50), 性別 char(2)check(性別=男 or 性別=女), 生日 datetime);create table 制作人與行政總裁( 姓名 varchar(20), 地址 varchar(50), 身份證號(hào) char(18) not null primary key, 資產(chǎn) int);create table 制片公司( 公司名稱 varchar(50) not null primary key, 地址 varchar(50), 行政總裁 char(18)not null references 制作人與行政總裁(身份證號(hào)),);create table 電影( 電影名稱 varchar(50) not null, 拍攝年份 datetime not null, 長度 int, 是否彩色 char(2)check(是否彩色 = 是 or 是否彩色 = 否), 所屬電影公司 varchar(50) references 制片公司(公司名稱), 制片人 char(18) referenc
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 企業(yè)培訓(xùn)課件分享
- 營銷活動(dòng)成效評(píng)估與優(yōu)化
- 油罐區(qū)安全防護(hù)制度
- 茶山承包與茶葉種植病蟲害防治合同
- 廠房物業(yè)服務(wù)及智慧園區(qū)建設(shè)合作協(xié)議
- 智能家居系統(tǒng)采購合同終止及供應(yīng)商更換
- 企業(yè)團(tuán)體意外險(xiǎn)課件
- 體育拉傷考試題及答案
- 常年法律顧問報(bào)價(jià)單制作與執(zhí)行規(guī)范合同
- 電子設(shè)備搬運(yùn)工技能培訓(xùn)勞動(dòng)合同
- 教育政策執(zhí)行情況調(diào)查報(bào)告范文
- 2025至2030年中國全大麻行業(yè)投資前景及策略咨詢報(bào)告
- 國家開放大學(xué)《中國法律史》期末機(jī)考題庫
- 鞍鋼勞研考試題庫及答案
- 保定市污水處理廠3993.7kW光伏發(fā)電項(xiàng)目可行性研究報(bào)告
- 跨國公司研發(fā)管理
- 《咖啡機(jī)操作培訓(xùn)資料》課件
- 民宿義工勞務(wù)合同協(xié)議
- 小學(xué)數(shù)學(xué)教學(xué)策略與方法講座
- GB/T 2878.1-2025液壓傳動(dòng)連接普通螺紋斜油口和螺柱端第1部分:斜油口
- 銀行保密知識(shí)培訓(xùn)課件
評(píng)論
0/150
提交評(píng)論