1Z0-051 Exam - Oracle Database: SQL Fundamentals I

certleader.com

Q1. - (Topic 2) 

Which SQL statement would you use to remove a view called EMP_DEPT_VU from your schema? 

A. DROP emp_dept_vu; 

B. DELETE emp_dept_vu; 

C. REMOVE emp_dept_vu; 

D. DROP VIEW emp_dept_vu; 

E. DELETE VIEW emp_dept_vu; 

F. REMOVE VIEW emp_dept_vu; 

Answer:

Explanation: 

DROP VIEW viewname; 

Incorrect Answer: ANot a valid drop view statement BNot a valid drop view statement CNot a valid drop view statement ENot a valid drop view statement FNot a valid drop view statement 

Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 11-20 

Q2. - (Topic 2) 

Examine the structure of the ORDERS table: 

You want to find the total value of all the orders for each year and issue the following command: 

SQL>SELECT TO_CHAR(order_date,'rr'), SUM(order_total) 

FROM orders 

GROUP BY TO_CHAR(order_date,'yyyy'); 

Which statement is true regarding the outcome? 

A. It executes successfully and gives the correct output. 

B. It gives an error because the TO_CHAR function is not valid. 

C. It executes successfully but does not give the correct output. 

D. It gives an error because the data type conversion in the SELECT list does not match the data type conversion in the GROUP BY clause. 

Answer:

Q3. - (Topic 2) 

SLS is a private synonym for the SH.SALES table. 

The user SH issues the following command: 

DROP SYNONYM sls; 

Which statement is true regarding the above SQL statement? 

A. Only the synonym would be dropped. 

B. The synonym would be dropped and the corresponding table would become invalid. 

C. The synonym would be dropped and the packages referring to the synonym would be dropped. 

D. The synonym would be dropped and any PUBLIC synonym with the same name becomes invalid. 

Answer:

Explanation: 

A synonym is an alias for a table (or a view). Users can execute SQL statements against the synonym, and the database will map them into statements against the object to which the synonym points. 

Private synonyms are schema objects. Either they must be in your own schema, or they must be qualified with the schema name. Public synonyms exist independently of a schema. A public synonym can be referred to by any user to whom permission has been granted to see it without the need to qualify it with a schema name. 

Private synonyms must be a unique name within their schema. Public synonyms can have the same name as schema objects. When executing statements that address objects without a schema qualifier, Oracle will first look for the object in the local schema, and only if it cannot be found will it look for a public synonym. 

Q4. - (Topic 1) 

View the Exhibit for the structure of the STUDENT and FACULTY tables. 

You need to display the faculty name followed by the number of students handled by the faculty at the base location. Examine the following two SQL statements: 

Which statement is true regarding the outcome? 

A. Only statement 1 executes successfully and gives the required result. 

B. Only statement 2 executes successfully and gives the required result. 

C. Both statements 1 and 2 execute successfully and give different results. 

D. Both statements 1 and 2 execute successfully and give the same required result. 

Answer:

Q5. - (Topic 2) 

The EMPLOYEES table contains these columns: 

EMPLOYEE_ID NUMBER(4) 

ENAME VARCHAR2 (25) 

JOB_ID VARCHAR2(10) 

Which SQL statement will return the ENAME, length of the ENAME, and the numeric position of the letter "a" in the ENAME column, for those employees whose ENAME ends with a the letter "n"? 

A. SELECT ENAME, LENGTH(ENAME), INSTR(ENAME, 'a') FROM EMPLOYEES WHERE SUBSTR(ENAME, -1, 1) = 'n' 

B. SELECT ENAME, LENGTH(ENAME), INSTR(ENAME, ,-1,1) FROM EMPLOYEES WHERE SUBSTR(ENAME, -1, 1) = 'n' 

C. SELECT ENAME, LENGTH(ENAME), SUBSTR(ENAME, -1,1) FROM EMPLOYEES WHERE INSTR(ENAME, 1, 1) = 'n' 

D. SELECT ENAME, LENGTH(ENAME), SUBSTR(ENAME, -1,1) FROM EMPLOYEES WHERE INSTR(ENAME, -1, 1) = 'n' 

Answer:

Explanation: 

INSTR is a character function return the numeric position of a named string. 

INSTR(NAMED,’a’) 

Incorrect Answer: 

BDid not return a numeric position for ‘a’. 

CDid not return a numeric position for ‘a’. 

DDid not return a numeric position for ‘a’. 

Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 3-8 

Q6. - (Topic 1) 

Which SQL statement displays the date March 19, 2001 in a format that appears as “Nineteenth of March 2001 12:00:00 AM”? 

A. SELECT TO_CHAR(TO_DATE('19-Mar-2001’, ‘DD-Mon-YYYY’), ‘fmDdspth “of” Month YYYY fmHH:MI:SS AM’) NEW_DATE FROM dual; 

B. SELECT TO_CHAR(TO_DATE(’19-Mar-2001’, ‘DD-Mon-YYYY’), ‘Ddspth “of” Month YYYY fmHH:MI:SS AM’) NEW_DATE FROM dual; 

C. SELECT TO_CHAR(TO_DATE(’19-Mar-2001’, ‘DD-Mon-YYYY’), ‘fmDdspth “of” Month YYYY HH:MI:SS AM’) NEW_DATE FROM dual; 

D. SELECT TO_CHAR(TO_DATE(’19-Mar-2001’, ‘DD-Mon-YYYY), ‘fmDdspth “of” Month YYYYfmtHH:HI:SS AM') NEW_DATE FROM dual; 

Answer:

Q7. - (Topic 1) 

See the Exhibit and examine the structure of the PROMOTIONS table: Exhibit:

 

Using the PROMOTIONS table, you need to find out the average cost for all promos in the 

range $0-2000 and $2000-5000 in category A. 

You issue the following SQL statements: 

Exhibit: 

What would be the outcome? 

A. It generates an error because multiple conditions cannot be specified for the WHEN clause 

B. It executes successfully and gives the required result 

C. It generates an error because CASE cannot be used with group functions 

D. It generates an error because NULL cannot be specified as a return value 

Answer:

Explanation: 

CASE Expression Facilitates conditional inquiries by doing the work of an IF-THEN-ELSE statement: CASE expr WHEN comparison_expr1 THEN return_expr1 [WHEN comparison_expr2 THEN return_expr2 WHEN comparison_exprn THEN return_exprn ELSE else_expr] END 

Q8. - (Topic 2) 

View the Exhibit and examine the data in the PROJ_TASK_DETAILS table. 

The PROJ_TASK_DETAILS table stores information about tasks involved in a project and the relation between them. 

The BASED_ON column indicates dependencies between tasks. Some tasks do not depend on the completion of any other tasks. 

You need to generate a report showing all task IDs, the corresponding task ID they are dependent on, and the name of the employee in charge of the task it depends on. 

Which query would give the required result? 

A. 

SELECT p.task_id, p.based_on, d.task_in_charge FROM proj_task_details p JOIN proj_task_details d ON (p.based_on = d.task_id); 

B. 

SELECT p.task_id, p.based_on, d.task_in_charge 

FROM proj_task_details p LEFT OUTER JOIN proj_task_details d ON (p.based_on = 

d.task_id); 

C. 

SELECT p.task_id, p.based_on, d.task_in_charge 

FROM proj_task_details p FULL OUTER JOIN proj_task_details d ON (p.based_on = 

d.task_id); 

D. 

SELECT p.task_id, p.based_on, d.task_in_charge FROM proj_task_details p JOIN proj_task_details d ON (p.task_id = d.task_id); 

Answer:

Q9. - (Topic 2) 

Which two statements are true regarding constraints? (Choose two.) 

A. A foreign key cannot contain NULL values. 

B. The column with a UNIQUE constraint can store NULLS . 

C. A constraint is enforced only for an INSERT operation on a table. 

D. You can have more than one column in a table as part of a primary key. 

Answer: B,D 

Q10. - (Topic 2) 

The user Sue issues this SQL statement: 

GRANT SELECT ON sue.EMP TO alice WITH GRANT OPTION; 

The user Alice issues this SQL statement: 

GRANT SELECT ON sue.EMP TO reena WITH GRANT OPTION; 

The user Reena issues this SQL statement: 

GRANT SELECT ON sue.EMP TO timber; 

The user Sue issues this SQL statement: 

REVOKE select on sue.EMP FROM alice; 

For which users does the revoke command revoke SELECT privileges on the SUE.EMP table? 

A. Alice only 

B. Alice and Reena 

C. Alice, Reena, and Timber 

D. Sue, Alice, Reena, and Timber 

Answer:

Explanation: use the REVOKE statement to revoke privileges granted to other users. Privilege granted to others through the WITH GRANT OPTION clause are also revoked. Alice, Reena and Timber will be revoke. 

Incorrect Answer: Athe correct answer should be Alice, Reena and Timber Bthe correct answer should be Alice, Reena and Timber Dthe correct answer should be Alice, Reena and Timber 

Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 13-17