已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
SQL exam(Please wirte your answer in-line in red font)1. You need to extract details of those products in the SALES table where the PROD_ID column contains the string _D123. Which WHERE clause could be used in the SELECT statement to get the required output?A. WHERE prod_id LIKE %_D123% ESCAPE _B. WHERE prod_id LIKE %_D123% ESCAPE C. WHERE prod_id LIKE %_D123% ESCAPE %_D. WHERE prod_id LIKE %_D123% ESCAPE _2. Evaluate the following two queries: SQL SELECT cust_last_name, cust_city FROM customers WHERE cust_credit_limit IN (1000, 2000, 3000); SQL SELECT cust_last_name, cust_city FROM customers WHERE cust_credit_limit = 1000 OR cust_credit_limit = 2000 OR cust_credit_limit = 3000; Which statement is true regarding the above two queries?A. Performance would improve in query 2.B. Performance would degrade in query 2.C. There would be no change in performance.D. Performance would improve in query 2 only if there are null values in the CUST_CREDIT_LIMIT column.3. Which three statements/commands would cause a transaction to end? (Choose three.)A. COMMITB. SELECTC. CREATED. ROLLBACKE. SAVEPOINT4. There are two table: T_A (name VARCHAR2(100)T_B (name VARCHAR2(100), name_a VARCHAR2(100);The values are:T_AT_BnameJaneLeoDavidnamename_aAppleJaneOrangeJaneAppleLeoOrangeLeoBananaJaneBananaDavid(1) Please write a SQL to output below result:Name Apple Orange Banana- - - -Jane Yes Yes YesLeo Yes Yes NoDavid No No YesSelect name, case when Ap =1 then Yes else No end Apple,case when Og =1 then Yes else No end Orange,case when Bn =1 then Yes else No end Bananafrom (Select name, sum(Ap) Ap , sum(Og) Og, sum(Bn) Bn(select name_a ,Decode( T_B.name, Apple , 1 ,0 ) Ap ,Decode( T_B.name, Orange , 1 ,0 ) Og,Decode( T_B.name, Banana , 1 ,0 ) Bn,from T_B) T group by name ) T2;(2) Please write a SQL to output below result:(calculate the number of owner for each row in T_B, the number of returned row should be the same as T_B)Name Owner_Count- -Apple 2Orange 2Banana 2 Apple 2Orange 2Banana 2Select name Name, count(1) over (partition by name) Owner_CountFrom T_B;(3) Please write a SQL to output below result:(Find rows between 2 and 4, using ROWNUM)Name Name_a- -Orange JaneBanana JaneApple Leo Select name Name, Name_aFrom T_BWhere ROWNUM between 2 and 4;(4) Please write a Function:This function has a parameter which has the same data type as name in T_A and return the second fruit name in T_B. if one person has no the second fruit, the function return the first fruit.Example: pass Jane as parameter, return Orange; pass David, return Banana.(5) Please add a Trigger on table T_B:Assuming there is a new row in T_A, name is Jacob, If inserting a row to T_B with name_a=Jacob, please change the name in T_B to Apple regardless of its original value.(We may insert many rows one time)Example: SQL INSERT INTO T_B (name, name_a) VALUES (Banana, Jacob );SQL COMMIT;SQL SELECT * FROM T_B WHERE name_a=Jacob;Name Name_a- -Apple Jacob5. Table : tab (col INT). The values are:colnull12QWhat will be result of the following query:select col from tab where col in (null,1)A only 1.6. Table : T1 (id INT, name VARCHAR(100). The values are:idname1ABC2PQR3XYZ4XYZ5ABCQWhat will be result of the following query : select * from T1 where rownum = 3A XYZQWrite a query to delete duplicate records in T1 based on column name.ADelete from T1 where rowid in (Select max(rowid),name from T1Group by name);having count(name) 1)QWrite a query to return first 3 records(sort by column name) of T1.A select * from (select * from T1 order by name) where rownum select * from emp where ename = JOHN;sql2select * from emp where ename = KATE;Qwhile running second sql, will it reuse the execution plan generate by first sql?ANO.It wil not use the explain plan of the first one9. What are the steps included in the compilation process of a pl/sql blocksyntax checking ,binding, p-code generation10. Can we create two procedures with same name but different parameters?11. To insert a lot of data into existing table, how to speed up the operation? Please consider as many situations an you can.Way1: drop the index, disable the constraintWay2: use hint /*+append nologging*/Way3: the insert statement must not have performance issue12. If you want to update a column value for all rows of a very big table(e.g. UPDATE t SET code = code|-EX), how to speed up the operation? Please consider as many situations an you can.Way1: Partition the tab
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 智能交通项目安全生产协议书模板
- 中空玻璃厂转让协议书
- 2026-2031中国光电鼠标市场动态监测及竞争战略研究报告
- 2025年合规管理合规培训案例分析题库附答案
- 诺如病毒胃肠炎诊疗方案2025年版测试题及答案
- 医学影像专业考试2025年试题及答案
- 1.3 水结冰了 教学设计-2024-2025学年科学三年级上册教科版
- 2023-2024学年道德与法治五年级下册5《建立良好的公共秩序》 教学设计+教案(统编版)
- 2026-2031中国配电开关控制设备制造市场全景调查与投资前景报告(定制版)
- 语文园地八 教学设计-2024-2025学年统编版语文一年级下册
- 2025年高压电工作业(特种作业)考试题库(带答案)
- (北师大2024版)生物八上全册知识点(默写版+背诵版)
- 苏州实验中学2026届数学高二第一学期期末监测试题含解析
- 2025年合同能源管理节能改造工程合同能源管理合同
- 小米全面预算管理案例
- 2025年山东省科创集团有限公司权属企业招聘(22人)笔试历年常考点试题专练附带答案详解试卷2套
- 2025年船舶租赁合同协议书模板
- 青海省西宁市大通县2025-2026学年高三上学期期中考试政治试卷
- 慢性阻塞性肺疾病急性加重期诊疗指南
- 门头招牌长期合同范本
- 江苏省宿迁市泗阳县2024-2025学年高一上学期11月期中物理试题(含答案)
评论
0/150
提交评论