1z0-047 Exam - Oracle Database SQL Expert

certleader.com

Q1. 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,COTT 10); INSERT INTO emp VALUES (3,ING 55); 

A. Both the INSERT statements would fail because all constraints are automatically retrieved when the table is flashed back. 

B. Both the INSERT statements would succeed because none of the constraints on the table are automatically retrieved when the table is flashed back. 

C. 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. 

D. 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. 

Answer: D

Q2. View the Exhibit and examine the description of the ORDER_ITEMS table. 

The following SQL statement was written to retrieve the rows for the PRODUCT_ID that has a UNIT_PRICE of more than 1,000 and has been ordered more than five times: 

SELECT product_id, COUNT(order_id) total, unit_price FROM order_items WHERE unit_price>1000 AND COUNT(order_id)>5 GROUP BY product_id, unit_price; 

Which statement is true regarding this SQL statement? 

A. The statementwouldexecute and give youthedesired result. 

B. Thestatementwould not execute becausetheaggregatefunction is usedintheWHEREclause. 

C. The statementwouldnot execute because the WHERE clause should havetheOR logical operator insteadofAND. 

D. The statement wouldnot execute because intheSELECT clause, the UNIT_PRICE column is placed afterthecolumn having the aggregate function. 

Answer: B

Q3. View the Exhibit and examine the structure of EMPLOYEES and JOB_IHISTORY tables. 

The EMPLOYEES table maintains the most recent information regarding salary, department, and job for all the employees. The JOB_HISTORY table maintains the record for all the job changes for the employees. You want to delete all the records from the JOB_HISTORY table that are repeated in the EMPLOYEES table. 

Which two SQL statements can you execute to accomplish the task? (Choose two.) 

A. DELETE FROM job_history j WHERE employee_id = (SELECT employee_id FROM employees e WHERE j.employee_id = e.employee_id) AND job _id = (SELECT job _id FROM employees e WHERE j.job_id = e.job_id); 

B. DELETE FROM job_history j WHERE (employee_id, job _id) = ALL (SELECT employee_id, job_id FROM employees e WHERE j.employee_id = e.employee_id and j.job_id = e.job_id) 

C. DELETE FROM job_history j WHERE employee_id = (SELECT employee_id 

FROM employees e 

WHERE j.employee_id = e.employee_id and j.job_id = e.job_id) 

D. DELETE FROM job_history j WHERE (employee_id, job _id) = (SELECT employee_id, job_id FROM employees e WHERE j.employee_id = e.employee_id and j.job_id = e.job_id) 

Answer: C,D

Q4. View the Exhibit and examine the descriptions of the EMPLOYEES and DEPARTMENTS tables. 

The following SQL statement was executed: 

SELECT e.department_id, e.job_id, d.location_id, sum(e.salary) total, 

GROUPING(e. department_id) GRP_DEPT, 

GROUPING(e.job_id) GRPJOB, 

GROUPING(d. location_id) GRP_LOC 

FROM employees e JOIN departments d 

ON e.department_id = d.department_id 

GROUP BY ROLLUP (e.department_id, e.job_id, d.location_id); 

View the Exhibit2 and examine the output of the command. 

Which two statements are true regarding the output? (Choose two.) 

A. The value1in GRP_LOC means that the LOCATION_ID column is taken into account to generate the subtotal. 

B. The value 1 in GRPJOBandGRP_LOC meansthatJOB_IDandLOCATION_ID columns are nottakeninto accountto generatethesubtotal. 

C. Thevalue1inGRPJOB and GRP_LOC meansthatthe NULL value in JOBJD and LOCATIONJD columns aretakeninto account togeneratethe subtotal. 

D. The value 0 inGRP_DEPT,GRPJOB, and GRP_LOC means that DEPARTMENT_ID, JOB_ID, and LOCATION_ID columnsaretaken into account to generate the subtotal 

Answer: BD

Q5. The details of the order ID, order date, order total, and customer ID are obtained from the ORDERS table. If the order value is more than 30000, the details have to be added to the LARGEjDRDERS table. The order ID, order date, and order total should be added to the ORDERJHISTORY table, and order ID and customer ID should be added to the CUSTJHISTORY table. Which multitable INSERT statement would you use? 

A. Pivoting INSERT 

B. Unconditional INSERT 

C. ConditionalALLINSERT 

D. Conditional FIRST INSERT 

Answer: C

Q6. View the Exhibit and examine the description of the ORDERS table. 

Which two WHERE clause conditions demonstrate the correct usage of conversion functions? (Choose two.) 

A. WHERE order_date > TO_DATE('JUL 10 2006','MON DD YYYY") 

B. WHERE TO_CHAR(order_date,'MON DD YYYY} = 'JAN 20 2003' 

C. WHERE order_date > T0_CHAR(ADD_M0NTHS(SYSDATE,6),'M0N DD YYYY’) 

D. WHERE order_date IN (T0_DATE('0ct 21 2003','Mon DD YYYY’), T0_CHAR('N0V 21 2003','Mon DD YYYY’)) 

Answer: AB