OCP12c题库071第1次课CUUG内部资料.pdf_第1页
OCP12c题库071第1次课CUUG内部资料.pdf_第2页
OCP12c题库071第1次课CUUG内部资料.pdf_第3页
OCP12c题库071第1次课CUUG内部资料.pdf_第4页
OCP12c题库071第1次课CUUG内部资料.pdf_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1.choose the best answer What is the primary difference between the relational database (RDB) and object-oriented database (00DB) models? A) RDB allows the definition of relationships between different tables, whereas OODB does not allow this. B) OODB incorporates methods with data structure definition, whereas RDB does not allow this. C) OODB supports multiple objects in the same database, whereas RDB supports only tables. D) RDB supports E.F. Codds rules, whereas OODB does not support them. Answer: 2.choose two Examine the description of the EMP_DETAILS table given below: Which two statements are true regarding SQL statements that can be executed on the EMP_DETAIL table? A) You cannot add a new column to the table with LONG as the data type. B) An EMP_IMAGE column can be included in the GROUP BY clause. C) You can alter the table to include the NOT Nun., constraint on the EMP_IMAGE column. D) An EMP_IMAGE column cannot be included in the ORDER BY clause. Answer:AD (解析: 答案 A: SQL alter table sales add emp_info long; alter table sales add emp_info long * 第 1 行出现错误: ORA-01754: 表只能包含一个 LONG 类型的列。 答案 D: SQL select * from sales 2 order by emp_image; select * from sales * 第 1 行出现错误: ORA-00997: 非法使用 LONG 数据类型 ) 3.choose three View the Exhibit and examine the description of SALES and PROMOTIONS tables. You want to delete rows from the SALES table, where the PROMO_NAME column in the PROMOTIONS table has either blowout sale or everyday low price as values. Which three DELETE statements are valid? A) DELETE FROM sales WHERE promo_id = (SELECT promo_id FROM promotions WHERE promo_name = blowout sale) OR promo_id = (SELECT promo_id FROM promotions WHERE promo_name = everyday low price); B) DELETE FROM sales WHERE promo_id = (SELECT promo_id FROM promotions WHERE promo_name = blowout sale) AND promo_id = (SELECT promo_id FROM promotions WHERE promo_name = everyday low price); C) DELETE FROM sales WHERE promo_id IN (SELECT promo_id FROM promotions WHERE promo_name = blowout sale OR promo_name = everyday low price); D) DELETE FROM sales WHERE promo_id IN (SELECT promo_id FROM promotions WHERE promo_name IN (blowout sale,everyday low price); Answer:ACD 4.choose the best answer View the Exhibits and examine PRODUCTS and SALES tables. You issue the following query to display product name and the number of times the product has been sold: SQLSELECT d_name, i.item_cnt FROM (SELECT prod id, COUNT(*) item_cnt FROM sales GROUP BY prod_id) i RIGHT OUTER JOIN products p ON d_id = d_id; What happens when the above statement is executed? A) The statement executes successfully and produces the required output. B) The statement produces an error because a subquery in the FROM clause and outer-joins cannot be used together. C) The statement produces an error because ITEM_CNT cannot be displayed in the outer query. D) The statement produces an error because the GROUP BY clause cannot be used in a subquery in the FROM clause. Answer:A (SQL select d.dname,e.emp_cnt from (select deptno,count(*) emp_cnt from emp group by deptno)e right outer join dept d on e.deptno=d.deptno; DNAME EMP_CNT - - ACCOUNTING 2 RESEARCH 4 SALES 6 OPERATIONS TRAIN) 5.choose the best answer Evaluate the following CREATE SEQUENCE statement: CREATE SEQUENCE seq1 START WITH 100 INCREMENT BY 10 MAXVALUE 200 CYCLE NOCACHE; The sequence SEQ1 has generated numbers up to the maximum limit of 200. You issue the following SQL statement: SELECT seq1.nextval FROM dual; What is displayed by the SELECT statement? A) 1 B) 100 C) an error D) 10 Answer:B 6. choose the best answer In the EMPLOYEES table there are 1000 rows and employees are working in the company for more than 10 years. Evaluate the following SQL statement: SQL UPDATE employees SET salary = NVL(salary,0) + NVL(comm,0),comm = NVL(comm,0) WHERE hire_date update emp 2 set sal=nvl(sal,0)+nvl(comm,0),comm=nvl(comm,0) 3 where hiredate CREATE TABLE product (pcode NUMBER(2), pname VARCHAR2(10); SQL INSERT INTO product VALUES (1, pen); SQL INSERT INTO product VALUES (2,pencil); SQL SAVEPOINT a; SQL UPDATE product SET pcode = 10 WHERE pcode = 1; SQL SAVEPOINT b; SQL DELETE FROM product WHERE pcode = 2; SQL COMMIT; SQL DELETE FROM product WHERE pcode=10; SQL ROLLBACK TO SAVEPOINT a; Which two statements describe the consequences of issuing the ROLLBACK TO SAVE POINT a command in the session? A) Only the second DELETE statement is rolled back. B) No SQL statements are rolled back. C) Both the DELETE statements and the UPDATE statement are rolled back. D) The rollback generates an error. E) Only the DELETE statements are rolled back. Answer:BD (因为 commit 操作,前面所有的保存点都结束) 10.choose the best answer Evaluate the following SQL statement: SQL SELECT promo_id, promo_category FROM promotions WHERE promo_category = Internet ORDER BY 2 DESC UNION SELECT promo_id, promo_category FROM promotions WHERE promo_category = TV UNION SELECT promo_id, promo_category FROM promotions WHERE promo_category =Radio; Which statement is true regarding the outcome of the above query? A) It produces an error because the ORDER BY clause should appear only at the end of a compound query-that is, with the last SELECT statement. B) It executes successfully and displays rows in the descending order of PROMO_CATEGORY. C) It produces an error because positional notation cannot be used in the ORDER BY clause with SET operators. D) It executes successfully but ignores the ORDER BY clause because it is not located at the end of the compound statement. Answer:A (执行时 order by 子句只能出现最后的 select 语句,否则出现“ORA-00933: SQL 命令未正 确结束”错误) 11.choose the best answer Examine the commands used to create DEPARTMENT_DETAILS and COURSE_DETAILS: SQL CREATE TABLE DEPARTMENT_DETAILS (DEPARTMENT_ID NUMBER PRIMARY KEY, DEPARTMENT_NAME VARCHAR2(50) , HOD VARCHAR2(50); SQL CREATE TABLE COURSE_DETAILS (COURSE_ID NUMBER PRIMARY KEY, COURSE_NAME VARCHAR2 (50) , DEPARTMENT_ID NUMBER REFERENCES DEPARTMENT_DETAILS(DEPARTMENT_ID); You want to generate a list of all department IDs that do not exist in the COURSE_DETAILS table. You execute the SQL statement: SQL SELECT d.department_id FROM course_details c INNER JOIN department_details d ON c.department_idd.department_id; What is the outcome? A) It fails because the ON clause condition is not valid. B) It executes successfully and displays the required list. C) It executes successfully but displays an incorrect list. D) It fails because the join type used is incorrect. Answer:C (如果条件中用,得从来的结果就是笛卡尔积,inner join 并不以谁为基础,它只显示符 合条件的记录 联合连接(UNION JOIN) :这是一种很少见的连接方式。Oracle、MySQL 均不支持,其作用 是:找出全外连接和内连接之间差异的所有行。这在数据分析中排错中比较常用。也可以利 用数据库的集合操作来实现此功能。 ORACLE 中可以用 minus 等同联合连接的功能。 select deptno from dept minus select deptno from emp; ) 12.choose the best answer Evaluate the following query: SQL SELECT promo_name | qs start date was | promo_begin_date AS “Promotion Launches“ FROM promotions; What would be the outcome of the above query? A) It produces an error because the data types are not matching. B) It executes successfully and displays the literal “s start date was “ for each row in the output. C) It executes successfully and introduces an s at the end of each promo_name in the output. D) It produces an error because flower braces have been used. Answer:B (执行结果如下: Promotion Launches - NO PROMOTION #s start date was 01-1 月 -99 newspaper promotion #16-108s start date was 23-12 月-00 ) 13.choose the best answer Which statement is true regarding the USING clause in table joins? A) It can be used to access data from tables through equijoins as well as nonequijoins. B) It can be used to join tables that have columns with the same name and compatible data types. C) It can be used to join a maximum of three tables. D) It can be used to restrict the number of columns used in a NATURAL join. Answer:B (解析:using 只能用在 equiue join ,而且必须列的名字要相同,类型可以不同,但是可以 隐式转过去) 14.choose the best answer View the Exhibit and examine the data in EMP and DEPT tables. In the DEPT table, DEPTNO is the PRIMARY KEY. In the EMP table, EMPNO is the PRIMARY KEY and DEPTNO is the FOREIGN KEY referencing the DEPTNO column in the DEPT table. What would be the outcome of the following statements executed in the given sequence? DROP TABLE emp; FLASHBACK TABLE emp TO BEFORE DROP; INSERT INTO emp VALUES (2,SCOTT, 10); INSERT INTO emp VALUES (3,KING, 55); A) Both the INSERT statements would succeed because none of the constraints on the table are automatically retrieved when the table is flashed back. B) Only the second INSERT statement would succeed because all the constraints except referential integrity constraints that reference other tables are retrieved automatically after the table is flashed back. C) Both the INSERT statements would fail because all constraints are automatically retrieved when the table is flashed back. D) Only the first INSERT statement would succeed because all the constraints except the primary key constraint are automatically retrieved after a table is flashed back. Answer:B (解析:除了引用其他表的引用完整性约束之外,所有约束在表被闪回之后自动恢复,已经 做过实验) 15.choose the best answer View the Exhibit and examine the structure of the ORDER_ITEMS table. Examine the following SQL statement: SELECT order_id, product_id, unit_price FROM order_items WHERE unit_price = (SELECT MAX(unit_price) FROM order items GROUP BY order_id); You want to display the PRODUCT_ID of the product that has the highest UNIT_PRICE per ORDER_ID. What correction should be made in the above SQL statement to achieve this? A) Replace = with the ALL operator. B) Replace = with the ANY operator. C) Remove the GROUP BY clause from the subquery and place it in the main query. D) Replace = with the IN operator. Answer:D (解析:题意是希望显示每个 ORDER_ID 具有最高 UNIT_PRICE 的产品的 PROT_ID 的信息) 16.choose two View the Exhibit and examine the structure of the PRODUCT_INFORMATION and INVENTORIES tables. You have a requirement from the supplies department to give a list containing PRODUCT_ID, SUPPLIER_ID, and QUANTITY_ON_HAND for all the products where in QUANTITY_ON_HAND is less than five. Which two SQL statements can accomplish the task? (Choose two.) A) SELECT product_id, quantity_on_hand,supplier_id FROM product_information NATURAL JOIN inventories AND quantity_on_hand select next_day(sysdate,2) from dual; NEXT_DAY(SYSDA - 03-12 月-18 #这一天是周日 SQL select next_day(sysdate,1) from dual; NEXT_DAY(SYSDA - 02-12 月-18 #这一天是周一 18.choose the best answer View the Exhibits and examine the structures of the PRODUCTS, SALES, and CUSTOMERS tables. You issue the following query: SQLSELECT d_id,prod_name,prod_list_price, quantity_sold,cust_last_name FROM products p NATURAL JOIN sales s NATURAL JOIN customers c WHERE prod_id =148; Which statement is true regarding the outcome of this query? A) It executes successfully. B) It produces an error because a column used in the NATURAL join cannot have a qualifier. C) It produces an error because all columns used in the NATURAL join should have a qualifier. D) It produces an error because the NATURAL join can be used only with two tables. Answer:B (解析:执行该语句时返回错误: SELECT d_id,prod_name,prod_list_price, * 第 1 行出现错误: ORA-25155: NATURAL 联接中使用的列不能有限定词 ) 19.choose the best answer View the Exhibit and examine the structure of the PROMOTIONS table. Evaluate the following SQL statement: SQLSELECT promo_name,CASE WHEN promo_cost=(SELECT AVG(promo_cost) FROM promotions WHERE promo_category= TV) THEN HIGH ELSE LOW END COST_REMARK FROM promotions; Which statement is true regarding the outcome of the above query? A) It shows COST_REMARK for all the promos in the promo category TV . B) It produces an error because subqueries cannot be used with the CASE expression. C) It shows COST_REMARK for all the promos in the table. D) It produces an error because the subquery gives an error. Answer:C (解析: category TV只是判定 promo_cost 的一个条件, 显示的是所有 category 的内容。 使用如下语句验证: SELECT promo_name,promo_category,CASE WHEN promo_cost=(SELECT AVG(promo_cost) FROM promotions WHERE promo_category= TV) THEN HIGH ELSE LOW END COST_REMARK FROM promotions where rownum 30; ) 20.choose the best answer View the Exhibit and examine the data in the PROMOTIONS table. PROMO_BEGIN_DATE is stored in the default date format, dd-mon-rr. You need to produce a report that provides the name,cost,and start date of all promos in the POST category that were launched before January 1, 2000. Which SQL statement would you use? A) SELECT promo_name, promo_cost, promo_begin_date FROM prom

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论