orcale考试操作题及答案.docx
《orcale考试操作题及答案.docx》由会员分享,可在线阅读,更多相关《orcale考试操作题及答案.docx(9页珍藏版)》请在冰点文库上搜索。
orcale考试操作题及答案
1、查询商品的所有信息。
2、网站管理人员在了解商品信息时只需要了解所有商品的商品号、商品名称和商品单价。
3、在Goods表中存储有商品数量和商品单价,现在需要了解所有商品的商品号、商品名称和商品名额。
4、要求需要了解所有商品号、商品名称和总价值,但希望分别以汉字标题商品号、商品名称和总价值表示g_ID、g_Name和g_Price*g_Number。
5、显示所有会员的编号、姓名、性别和年龄。
6、查询所有商品中的“热点”商品的所有信息。
7、查询商品类别为“01”,商品单价在2500元以上的商品信息,要求分别以汉字标题商品号、商品名称、商品类别号和价格。
8、查询所有年龄在20~25岁的会员的名称和年龄(用NL表示,不是基本表中的字段,是计算出来的)。
9、查询所有年龄不在20~25岁的会员的名称、籍贯和NL(同8)。
10、查询来自“湖南株洲”或“湖南长沙”两地会员的详细信息。
11、查询家庭地址不是“湖南株洲”或“湖南长沙”的商品的详细信息。
12、查询所有商品中以“三星”两字开头的商品的详细信息。
13、查询姓“黄”且名字中只有两个汉字的会员的会员名、真实姓名、电话和店子邮箱。
14、知道一个商品的商品名称中包含有“520”字样,要求查询该商品的商品号、商品名称、商品单价和商品折扣。
15、查询暂时没有商品图片的商品信息。
16、查询在WebShop网站进行了网购并下订单的会员编号。
17、查询商品表中钱5条商品的详细信息。
18、查询商品类别号为“01”的商品的商品号、商品名称和商品单价,并根据商品的价格进行降序(价格由高到低)排列。
19、在上例中,如果商品的价格相同,要求根据商品名称进行升序排列。
20、查询所有商品的最高价、最低价、平均价和所有库存量之和。
21、查询每一类别的商品总数。
22、查询商品单价超过2000的商品类别编号和库存量。
23、显示每个商品类别的商品库存量及商品总库存量。
24、显示商品总库存量、每个种类商品的商品总量和每一商品的数量。
25、查询订单总额大于5000的订单信息,并按升序排列。
26、查询每个商品的商品号、商品名称和商品类别名称。
27、查询所有订单中订购的商品信息(商品名称、购买价格和购买数量)和订单日期。
28、查询不低于“三星SGH-C178”价格的商品号、商品名称和商品单价,查询后的结果要求按商品单价升序排列。
29、查询所有商品类别及其应用商品信息,如果该商品类别没有对应商品也需要显示其类别信息。
30、查询所有商品信息(即使不存在对应的商品类别信息,实际上这种情况是不存在的)。
31、查询所有商品的基本信息和类别信息。
32、查询与“摩托罗拉W380”为同类商品的商品号、商品名称和类别号。
33、查询购买了“红双喜牌乒乓球拍”的订单号、订单时间和订单总金额。
34、查询购买了商品号为“060001”的会员e_ID(会员号)、e_Name(会员名称)和e_Address(籍贯)。
35、查询购买了“红双喜牌乒乓球拍”的订单号、订单时间和订单总金额(使用“=”完成)。
36、查询比籍贯为“湖南长沙”人以会员年龄小的会员信息,查询结果按降序排列。
37、针对Employees表中的每一位员工,在Orders表中查找处理过订单并且送货模式为“邮寄”的多有订单信息。
38、求每一类商品的平均价格,并将结果保存到数据库中。
39、将商品中的类别名称为“家用电器”的商品折扣修改为0.8。
40、使用两条Update语句保证数据库的一致性。
41、删除类别名称为“家用电器”的商品的基本信息。
42、查询“三星”的商品以及价格不高于2000的商品。
1、select*
fromscott.goods;
2、selectg_id,g_name,g_price
fromscott.goods;
3、selectg_id,g_name,g_price*g_number
fromgoods;
4、selectg_id商品号,g_name商品名称,g_price*g_number总价值
fromscott.goods;
5、selectc_id编号,c_name姓名,c_gender性别,to_char(sysdate,'yyyy')—to_char(c_birth,'yyyy')as年龄
fromscott.customers;
6、select*
fromscott.goods
whereg_status='热点'
7、selectg_id商品号,g_name商品名称,t_id类别号,g_price价格
fromgoods
wheret_id='01'andg_price>2500
8、selectc_name,to_char(sysdate,'yyyy')—to_char(c_birth,'yyyy')nlfromcustomers
whereto_char(sysdate,'yyyy')—to_char(c_birth,'yyyy')between20and259、selectc_name,to_char(sysdate,'yyyy')—to_char(c_birth,'yyyy')nlfromcustomers
whereto_char(sysdate,'yyyy')—to_char(c_birth,'yyyy')notbetween20and2510、selectc_id,c_name,c_address
fromcustomers
wheresubstr(c_address,1,4)in('湖南株洲','湖南长沙')
11、selectc_id,c_name,c_address
fromcustomers
wheresubstr(c_address,1,4)notin('湖南株洲','湖南长沙')
12、select*
fromgoods
whereg_namelike'三星%'
13、selectc_name,c_truename,c_phone,c_e-mail
fromcustomers
wherec_truenamelike'黄_'
14、selectg_id,g_name,g_price,g_discount
fromgoods
whereg_namelike'%520%'
15、select*
fromgoods
whereg_imageisnull
16、selectg_id
fromorderdetails
17、select*
fromscott.goods
whererownum<=5;
18、selectg_id,g_name,g_price
fromscott.goods
wheret_id='01'
orderbyg_pricedesc
19、selectg_id,g_name,g_price
fromscott.goods
wheret_id='01'
orderbyg_pricedesc,g_nameasc
20、selectmax(g_price)最高价,min(g_price)最低价,avg(g_price)价,sum(g_number)总库存
fromscott.goods
21、selectt_id类别号,count(t_id)商品数
fromscott.goods
groupbyt_id;
22、selectt_id,sum(g_number)库存量
fromscott.goods
whereg_price>=2000
groupbyt_id;
23、selectg_id,t_id,sum(g_number)库存量
fromscott.goods
groupbyrollup(t_id,g_id);
24、selectg_id,t_id,sum(g_number)库存量
fromscott.goods
groupbycube(t_id,g_id);
25、selecto_id订单编号,sum(d_price*d_number)总金额
fromscott.orderdetails
groupbyo_id
havingsum(d_price*d_number)>5000
orderbysum(d_price*d_number)
26、selectgoods.g_id,goods.t_id,types.t_name,goods.g_name
fromscott.goodsa
joinscott.typesb
ona.t_id=b.t_id;平均27、selectorder.o_id,o_date,o_date,g_name,d_price,d_numberfromscott.ordera
joinscott.orderdetailsb
ona.o_id=b.o_id
joingoodsc
onb.g_id=c.g_id;
28、selectb.g_id商品号,b.g_name商品名称,b.g_price价格
fromscott.goodsa
joinscott.goodsb
ona.g_name='三星SGH-C178'anda.g_price<=b.g_price
orderbyb.g_price;
29、selecttypes.t_id,t_name,g_id,g_name,g_price,g_number
fromscott.types
leftouterjoinscott.goodsontypes.t_id=goods.t_id;
30、selecttypes.t_id,t_name,g_id,g_name,g_price,g_number
fromscott.types
rightouterjoinscott.goodsontypes.t_id=goods.t_id;
31、selecttypes.t_id,t_name,g_id,g_name,g_price,g_number
fromscott.types
fullouterjoinscott.goodsontypes.t_id=goods.t_id;
32、selectg_id,g_name,t_id
fromscott.goods
wheret_idin(selectt_idfromgoodswhereg_name='摩托罗拉W380');33、selecto_id,o_date,o_sum
fromscott.orders
whereo_idin
(selecto_idfromorderdetailswhereg_idin
(selectg_idfromgoodswhereg_name='红双喜牌乒乓球拍'));
34、selectc_id,c_name,c_address
fromscott.customers
wherec_idin
(selectc_id
fromordersa
joinorderdetailsb
ona.o_id=b.o_id
whereg_id='060001');
35、selecto_id,o_date,o_sum
fromscott.orders
whereo_idin
(selecto_idfromorderdetailswhereg_id=
(selectg_idfromgoodswhereg_name='红双喜牌乒乓球拍'));
36、selectc_id,c_name,to_char(sysdate)-to_char(c_birth)age,c_addressfromscott.customers
wheresubstr(c_address,1,4)<>'湖南长沙'andc_birth>all
(selectc_birthfromcustomerswheresubstr(c_address,1,4)='湖南长沙')orderbyagedesc;
37、select*
fromorders
whereo_sendmode='邮寄'
andEXISTS(selecte_idfromemployeesasempwhereemp.e_id=order.e_id)38、
(1)先建立一个新表:
createtableavggoods(t_idchar
(2),a_avgfloat);其中t_id代表商品类别号,a_avg代表平均价格
(2)对数据库的商品表按商品号分组求平均价格,并把商品号和平均价格存入新表;insert
intoavggoods(t_id,a_avg)
selectt_id,avg(g_price)
fromgoodsgroupbyt_id;
(3)查看avggoods表中的记录select*fromavggoods;
39、updategoods
setg_discount=0.8
where'家用电器'=
(selectt_namefromtypeswheregoods.t_id=types.t_id);
再用查询语句selectg_id,g_name,t_id,g_discountfromgoods;40、
(1)修改goods表
updategoods
setg_id='110001'
whereg_id='060001'
(2)修改orderdetails表
updateorderdetails
setg_id='110001'
whereg_id='060001'
41、delete
fromgoods
where'家用电器'=(selectt_namefromtypeswheregoods.t_id=types.t_id)42、selectg_id商品号,g_name商品名称,g_price价格
fromgoods
wheresubstr(g_name,1,2)='三星'
UNION
selectg_id商品号,g_name商品名称,g_price价格
fromgoods
whereg_price<2000;