Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception?...

51
Oracle Introduction to PL/SQL 1. For which column would you create an index? a. a column that is small b. a column that is updated frequently c. a column containing a wide range of values d. a column with a small number of null values 2. The TEACHER table contains these columns: ID NUMBER(7) PK SALARY NUMBER(7,2) SUBJECT_ID NUMBER(7) Evaluate these two SQL statements: 1. SELECT ROUND(SUM(salary),-4) FROM teacher; 2. SELECT subject_id, ROUND(SUM(salary),-2) FROM teacher GROUP BY subject_id; How will the results differ? a. Statement 1 will display a result for each teacher. b. Statement 2 could display more than one row of results. c. The results will be the same, but the display will differ. d. One of the statements will generate an error. 3. Evaluate this SQL*Plus command: START emp_rec.sql Which SQL*Plus command will achieve the same results? a. &emp_rec.sql b. @ emp_rec.sql c. GET emp_rec.sql d. SAVE emp_rec.sql 4. You issue this command: GRANT update ON inventory TO joe WITH GRANT OPTION; Which task has been accomplished? a. Only a system privilege was given to user JOE. b. Only an object privilege was given to user JOE. c. User JOE was granted all privileges on the object. d. Both an object privilege and a system privilege were given to user JOE. 5. With which option could a view be created to prevent a user from updating rows in the base table that are not accessible to the view? a. group function

Transcript of Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception?...

Page 1: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

Oracle Introduction to PL/SQL 1. For which column would you create an index? a. a column that is small b. a column that is updated frequently c. a column containing a wide range of values d. a column with a small number of null values 2. The TEACHER table contains these columns: ID NUMBER(7) PK SALARY NUMBER(7,2) SUBJECT_ID NUMBER(7) Evaluate these two SQL statements: 1. SELECT ROUND(SUM(salary),-4) FROM teacher; 2. SELECT subject_id, ROUND(SUM(salary),-2) FROM teacher GROUP BY subject_id; How will the results differ? a. Statement 1 will display a result for each teacher. b. Statement 2 could display more than one row of results. c. The results will be the same, but the display will differ. d. One of the statements will generate an error. 3. Evaluate this SQL*Plus command: START emp_rec.sql Which SQL*Plus command will achieve the same results? a. &emp_rec.sql b. @ emp_rec.sql c. GET emp_rec.sql d. SAVE emp_rec.sql 4. You issue this command: GRANT update ON inventory TO joe WITH GRANT OPTION; Which task has been accomplished? a. Only a system privilege was given to user JOE. b. Only an object privilege was given to user JOE. c. User JOE was granted all privileges on the object. d. Both an object privilege and a system privilege were given to user JOE. 5. With which option could a view be created to prevent a user from updating rows in the base table that are not accessible to the view? a. group function

Page 2: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

b. GROUP BY clause c. DISTINCT command d. WITH CHECK OPTION 6. The PERSONNEL table contains these columns: ID NUMBER(9) LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) MANAGER_ID NUMBER(9) For this example, department managers are personnel. Evaluate these two SQL statements: SELECT p.last_name, p.first_name, m.last_name, m.first_name FROM personnel p, personnel m WHERE m.id = p.manager_id; SELECT p.last_name, p.first_name, m.last_name, m.first_name FROM personnel p, personnel m WHERE m.manager_id = p.id; How do the two statements differ? a. One of the statements will not execute. b. One of the statements is not a self-join. c. The results of the statements will be the same, but the format will be different. d. The results of the statements will be different, but the display will be the same. 7. You want to display the name, department, and salary of all employees that have the same department and salary as a particular employee identified by the employee id entered by the user. The employees displayed must not have received bonuses. Which statement will you use?

a. SELECT name, department_id, salary

FROM employee WHERE (department_id, salary) IN (SELECT department_id, salary

FROM employee WHERE employee_id = &1)

AND bonus IS NULL; b. SELECT name, department_id, salary

FROM employee WHERE (department_id, salary, bonus) = (SELECT department_id, salary, bonus

FROM employee WHERE employee_id = &1)

AND bonus = NULL;

Page 3: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

c. SELECT name, department_id, salary FROM employee WHERE (department_id, salary)(*) = (SELECT department_id, salary

FROM employee WHERE employee_id = &1)

AND bonus IS NULL; d. SELECT name, department_id, salary

FROM employee WHERE (SELECT department_id, salary

FROM employee WHERE employee_id = &1)

AND bonus = 0; 8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement is missing a required clause. d. The datatypes within the SELECT statement are inconsistent. 9. Which clause would you use in a SELECT statement to limit the display of the ID_NUMBER values to those whose price is less than 5.00? a. WHERE price < 5.00 b. HAVING price < 5.00 c. ORDER BY price < 5.00 d. GROUP BY price < 5.00 10. Evaluate this SQL statement: SELECT i.id_number, m.id_number FROM inventory i, manufacturer m WHERE i.manufacturer_id = m.id_number ORDER BY 1; Which clause prevents all the rows in the INVENTORY table from being joined to all the rows in the MANUFACTURER table? a. ORDER BY 1; b. SELECT i.id_number, m.id_number c. FROM inventory I, manufacturer m d. WHERE i.manufacturer_id = m.id_number 11. Evaluate this PL/SQL block: BEGIN FOR i IN 1..6 LOOP IF i = 2 OR i = 3 THEN null; ELSE INSERT INTO example(one) VALUES (i); END IF; ROLLBACK; END LOOP; COMMIT; END;

Page 4: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

How many values will be inserted into the EXAMPLE table? a. 0 b. 1 c. 2 d. 3 e. 4 12.You want to display inventory id numbers and their descriptions with these desired results: 1. The price of the item must be 8.25 or .25. 2. The display must be sorted alphabetically by the item description. 3. The items must have been ordered prior to June 10, 1997.

Evaluate this SQL script: SELECT id_number, description FROM inventory WHERE price IN (8.25, 0.25) ORDER BY description desc; What does the proposed solution provide? a. one of the desired results b. two of the desired results c. all of the desired results d. no results because the statement will not execute 13. Evaluate this SQL statement: SELECT * FROM USER_CATALOG; What might be displayed by this statement? a. names of all the views that you own b. names of all the views you can query c. names of all the views in the database d. names of all the data dictionary views 14. Which statement concerning the executable section of a PL/SQL block is true? a. PL/SQL expressions may contain group functions. b. PL/SQL expressions may not contain SQL functions. c. Some group functions are available within SQL statements. d. Statements within a nested block may contain an exception section.

Page 5: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

15. You need to disable the PRIMARY KEY constraint on the ID column in the INVENTORY table and update all the values in the INVENTORY table. After the update is complete, you need to enable the constraint and verify that column values do not violate the constraint. If any of the ID column values do not conform to the constraint, an error message should be returned. Evaluate this command: ALTER TABLE inventory ENABLE CONSTRAINT inventory_id_pk; Which statement is true? a. The statement will achieve the desired results. b. The statement will execute, but will not enable the PRIMARY KEY constraint. c. The statement will execute, but will not verify that values in the ID column do not violate the

constraint. d. The statement will return a syntax error. 16. Which SELECT statement displays the number of items whose PRICE value is greater than 5.00?

a. SELECT SUM(*)

FROM inventory WHERE price > 5.00;

b. SELECT COUNT(*)

FROM inventory ORDER BY price;

c. SELECT COUNT(*)

FROM inventory WHERE price > 5.00;

d. SELECT SUM(*)

FROM inventory GROUP BY price > 5.00;

17. Given the following…

Page 6: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

Evaluate this PL/SQL block: DECLARE v_new_tech_id NUMBER := 879563; v_old_tech_id NUMBER := 874512; v_rows_updated NUMBER := 1; BEGIN UPDATE service SET technician_id = v_new_tech_id WHERE technician_id = v_old_tech_id; v_rows_updated := SQL%ROWCOUNT; DBMS_OUTPUT.PUT_LINE (TO_CHAR(v_rows_updated)); END; Which value would be displayed? a. 1 b. 2 c. 7 d. 874512 18. Given the following…

You created a report to display the prices of products from your warehouse inventory. Which script will you use to display the prices in this format: "$0.25"? a. SELECT TO_CHAR(price, '$999990')

FROM inventory;

b. SELECT TO_NUM(price, '$999990.99') FROM inventory;

c. SELECT TO_NUMBER(price, '$999990.99') FROM inventory;

d. SELECT TO_CHAR(price, '$999990.99') FROM inventory;

19. The CLASSES and SCHEDULE tables contain these columns:

Page 7: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

CLASSES ---------------- ID NUMBER(9) CLASS_NAME VARCHAR2(20) TEACHER_ID NUMBER(9) SCHEDULE ------------------- CLASS_TIME DATE CLASS_ID NUMBER(9) You need to create a view that displays the class name and class time of each class ordered by the teacher id. Evaluate this command: CREATE VIEW class_schedule AS SELECT c.class_name, s.class_time FROM classes c, schedule s WHERE c.id = s.class_id; Which result does the statement provide? a. The statement will create the CLASS_SCHEDULE view and achieve the desired result. b. The statement will create the CLASS_SCHEDULE view, but will not create the desired result. c. The statement will return a syntax error because a CREATE VIEW statement CANNOT be based on a

join query. d. The statement will return a syntax error because a CREATE VIEW statement does NOT contain an

ORDER BY clause. 20. You issue this statement: CREATE PUBLIC SYNONYM parts FOR marilyn.inventory; Which task was accomplished? a. A new object was created. b. A new object privilege was assigned. c. A new system privilege was assigned. d. The need to qualify an object name with its schema was eliminate 21. Which logical operator could you use to add additional conditions that must be met to the WHERE clause in a simple join query? a. OR b. NOT c. AND d. None 22. Which arithmetic operation will return a numeric value? a. '01-FEB-1998' + 25 b. '03-DEC-1997' - 30 c. '07-JUL-1997' + (480/24) d. TO_DATE('01-JAN-1998') - TO_DATE('01-DEC-1996') 23. In which two statements would you typically use the CURRVAL pseudocolumn? (Choose two.) a. SELECT list of a view b. SET clause of an UPDATE statement

Page 8: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

c. subquery in an UPDATE statement d. VALUES clause of an INSERT statement e. SELECT statement with the HAVING clause 24. How many values could a subquery with a single row comparison operator return? a. only 1 b. up to 2 c. up to 10 d. unlimited 25. You attempt to query the database with this SQL statement: SELECT 100/NVL(quantity, 0)

FROM inventory; Why does this statement cause an error when QUANTITY values are null? a. The expression attempts to divide by zero. b. The expression attempts to divide by a null value. c. The datatypes in the conversion function are incompatible. d. A null value used in an expression cannot be converted to an actual value. 26. Which statement will you use to eliminate the need for all users to qualify Marilyn's INVENTORY table with its schema when querying? a. CREATE SYNONYM inventory

FOR inventory;

b. CREATE PUBLIC SYNONYM inventory FOR marilyn;

c. CREATE PUBLIC SYNONYM inventory FOR marilyn.inventory;

d. CREATE PUBLIC inventory SYNONYM FOR marilyn.inventory;

27. In a PL/SQL IF-THEN-ELSE statement, which value will cause the conditional statement to execute? a. NULL b. TRUE c. FALSE 28. Which command would cause an implicit COMMIT command? a. GRANT b. UPDATE c. COMMIT d. SELECT e. ROLLBACK

Page 9: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

29. Which SELECT statement would display the next value of the PARTS_ID sequence? a. SELECT NEXTVAL(parts_id)

FROM SYS.DUAL; b. SELECT parts_id.NEXTVAL

FROM inventory; c. SELECT parts_id.NEXTVAL

FROM SYS.DUAL d. SELECT NEXTVAL(parts_id)

FROM inventory; 30. Which clause would you use in an ALTER TABLE command to remove a constraint from the PRICE column in the INVENTORY table? a. DROP b. ALTER c. REMOVE d. DELETE 31. Which statement would you use to display the id and description of each item that was ordered before January 1, 1997 and has a price less than 1.00 or greater than 5.00? Sort the results by the most recent date ordered.

a. SELECT id_number, description FROM inventory WHERE price IN (1.00, 5.00) OR order_date < '01-JAN-97' SORT BY order_date;

b. SELECT id_number, description

FROM inventory WHERE price BETWEEN 1.00 AND 5.00 OR order_date < '01-JAN-1997' ORDER BY order_date;

c. SELECT id_number, description

FROM inventory WHERE price < 1.00 OR price > 5.00 AND order_date < '01-Jan-97' ORDER BY order_date ASC;

d. SELECT id_number, description

FROM inventory WHERE (price <1.00 OR price > 5.00) AND order_date < '01-JAN-1997' ORDER BY order_date DESC;

Page 10: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

32. What does the COMMENT ON TABLE command do? a. assigns a table alias b. adds a comment column to a table c. adds a comment about a table to the data dictionary d. adds a comment about a column to the data dictionary 33. Which privilege must you have to drop another user's sequence? a. DROP SEQUENCE b. DELETE SEQUENCE c. DROP ANY SEQUENCE d. DELETE ANY SEQUENCE 34. These are the columns in the PRODUCT table: PRODUCT_ID NUMBER(9) PRODUCT_NAME VARCHAR2(25) COST NUMBER(5,2) PRICE NUMBER(5,2) MANUFACTURER_ID NUMBER(9) You need to display product names, prices, manufacturer ids, and average prices for all the products that cost more than the average cost of products by the same manufacturer. Which SELECT statement will achieve these results? a. SELECT product_name, cost, manufacturer_id, AVG(price)

FROM product p, product a WHERE p.manufacturer_id = a.manufacturer_id GROUP BY product_name, cost, manufacturer_id;

b. SELECT product_name, cost, p.manufacturer_id, AVG(price)

FROM product p, (SELECT manufacturer_id, AVG(cost) avg_cost FROM product GROUP BY manufacturer_id) a

WHERE p.cost > a.avg_cost GROUP BY product_name, cost, manufacturer_id;

c. SELECT product_name, cost, manufacturer_id, AVG(price)

FROM product WHERE manufacturer_id IN (SELECT manufacturer_id, AVG(cost) avg_cost

FROM product GROUP BY manufacturer_id)

GROUP BY product_name, cost, manufacturer_id; d. SELECT product_name, cost, p.manufacturer_id, AVG(price)

FROM product p, (SELECT manufacturer_id, AVG(cost) avg_cost FROM product GROUP BY manufacturer_id) a

WHERE p.manufacturer_id = a.manufacturer_id AND p.cost > a.avg_cost GROUP BY product_name, cost, manufacturer_id;

35. Which command allows you to alter a view without regranting object privileges previously granted on it? a. ALTER b. CREATE c. MODIFY

Page 11: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

d. CREATE OR REPLACE 36. Given the following…

Which statement would you use to increase the NAME column length to 25? a. ALTER TABLE employee MODIFY name VARCHAR2(25); b. ALTER TABLE employee

RENAME name VARCHAR2(25); c. ALTER employee TABLE

MODIFY COLUMN name VARCHAR2(25); d. ALTER employee TABLE

MODIFY COLUMN (name VARCHAR2(25)); 37. In which section of a PL/SQL block is a WHEN OTHERS clause allowed? a. header b. exception c. executable d. declarative 38. Evaluate this SQL statement: SELECT id_number, description, price FROM inventory WHERE manufacturer_id IN (SELECT manufacturer_id FROM inventory WHERE price > 8.00 OR quantity > 1000); Which values will be displayed? a. The id number, description, and price of items in inventory that are priced greater than 8.00 and have a

quantity value greater than 1000. b. The id number, description, and price of items in inventory that are priced greater than 8.00 or that

have a quantity value greater than 1000. c. The id number, description, and price of items in inventory that are priced greater than 8.00 or that

have a quantity value greater than 1000 and have a manufacturer id value. d. The id number, description, and price of items in inventory that were manufactured by a manufacturer

with items in inventory that are priced greater than 8.00 or with items in inventory that have a quantity value greater than 1000.

39. Evaluate this SELECT statement: SELECT s.student_name, s.grade_point_avg, s.major_id, m.gpa_avg

Page 12: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

FROM student s, (SELECT major_id, AVG(grade_point_avg) gpa_avg FROM student GROUP BY major_id) m WHERE s.major_id = m.major_id AND s.grade_point_avg > m.gpa_avg; Which statement about this SELECT statement is true? a. The subquery produces a nonpairwise comparison of the columns. b. The subquery can be used as a data source for other SELECT statements. c. The SELECT statement will cause a syntax error because a FROM clause CANNOT contain a

subquery. d. The need to create a grade point average view is eliminated by using a subquery in the FROM clause. 40. Evaluate this IF statement: IF v_num > 5 THEN v_example := 1; ELSIF v_num > 10 THEN v_example := 2; ELSIF v_num < 20 THEN v_example := 3; ELSIF v_num < 39 THEN v_example := 4; ELSE v_example := 5; END IF; If V_NUM is 37, which value would be assigned to V_EXAMPLE? a. 1 b. 2 c. 3 d. 4 e. 5 41. The CUSTOMER table contains these columns: CUSTOMER_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) CREDIT_LIMIT NUMBER(9,2) Examine this code: DECLARE CURSOR cust_cursor IS SELECT cust_id, last_name, first_name FROM customer; cust_rec cust_cursor%ROWTYPE; How could you populate the CUST_REC record? a. Add a LOOP to the cursor declaration. b. Use an INSERT INTO statement in the executable section of the PL/SQL block. c. Use a LOOP that contains a FETCH statement in the executable section of the PL/SQL block. d. Use a SELECT statement with the INTO option in the executable section of the PL/SQL block. 42. Which is a SQL*Plus command? a. UPDATE

Page 13: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

b. CHANGE c. SELECT d. ALTER TABLE 43. Which PL/SQL section contains SQL statements to manipulate data in the database? a. header b. exception c. executable d. declarative 44. Evaluate this cursor declaration: DECLARE CURSOR prod_cursor IS SELECT product_name, cost, manufacturer_id, AVG(price) FROM product p, (SELECT manufacturer_id, AVG(cost) avg_cost) FROM product GROUP BY manufacturer_id) a WHERE p.manufacturer_id = a.manufacturer_id AND p.cost > a.avg_cost GROUP BY product_name, cost, manufacturer_id; Which statement is true? a. The subquery creates a temporary data source for the SELECT statement. b. The cursor declaration will return a syntax error because a cursor CANNOT be based on a join. c. The cursor will contain the MANUFACTURER_ID and AVG(COST) values from the PRODUCT

table when opened. d. The cursor will contain the PRODUCT_NAME, COST, MANUFACTURER_ID, AVG(PRICE),

MANUFACTURER_ID and AVG(COST) values from the PRODUCT table when opened. 45. Evaluate this incomplete loop: LOOP INSERT INTO inventory (id_number, description) VALUES (v_id_number, v_description); v_counter := v_counter + 1; Which statement will need to be added to conditionally stop the execution of the loop? a. END b. EXIT c. END LOOP d. EXIT WHEN 46. When executed, which statement displays a zero if the QUANTITY value is null? a. SELECT id_number, 100 / quantity

FROM inventory; b. SELECT id_number, NVL(100 / quantity, 0)

FROM inventory; c. SELECT id_number, NULL(100 / quantity, 0)

FROM inventory; d. SELECT id_number, TO_CHAR(100 / quantity, 0)

FROM inventory;

Page 14: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

47. In which section of a PL/SQL block could a new value be assigned to an initialized variable? a. end b. header c. executable d. declarative 48. Given the following…

Select machine_ID from service where technician_id=null; Which result does the query provide? a. No values will be displayed. b. The value 980076 will be displayed. c. The value 678523 will be displayed. d. A syntax error will be returned. 49. Given the following…

You need to reduce the PRICE column precision to 6 with a scale of 2 and ensure that when inserting a row into the INVENTORY table without a value for the PRICE column, a price of $5.00 will automatically be inserted. There are no records in the INVENTORY table. Which statement will you use? a. ALTER TABLE inventory

ADD OR REPLACE (price NUMBER(8,2) DEFAULT 5); b. ALTER TABLE inventory

MODIFY (price NUMBER(6,2) DEFAULT 5);

c. ALTER TABLE inventory MODIFY COLUMN (price NUMBER(6,2) DEFAULT '$5.00')

d. You cannot reduce the size of a column. 50.Evaluate this PL/SQL block: SET VERIFY OFF SET SERVEROUTPUT ON

Page 15: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

ACCEPT p_value1 PROMPT 'Please enter the first number: ' ACCEPT p_value2 PROMPT 'Please enter the second number: ' DECLARE v_value1 NUMBER := &p_value1; v_value2 NUMBER := &p_value2; v_result NUMBER; BEGIN v_result := v_value1 / v_value2; DMBS_OUTPUT.PUT_LINE (TO_CHAR(NVL(v_result, 0))); END; / SET VERIFY ON SET SERVEROUTPUT OFF Which statement about this PL/SQL block is true? a. The block will display a zero, regardless of the value of V_RESULT. b. The block will display a zero if the V_RESULT parameter is equal to null. c. The block will return an error because a PL/SQL variable was used. d. The block will return an error because a SQL*Plus variable was NOT used. 51. Given the following…????????????????????????????????????????/

SELECT id_number, manufacturer_id FROM inventory WHERE description = '&description';

SELECT id_number, manufacturer_id

FROM inventory WHERE description = LOWER('&description');

SELECT id_number, manufacturer_id

FROM inventory WHERE LOWER(description) = '&description';

SELECT id_number, manufacturer_id

FROM inventory WHERE UPPER(description) = UPPER('&description');

52. The STUDENT table contains these columns: ID NUMBER(9) PK LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) SUBJECT_ID NUMBER(9) Compare these two SQL statements:

Page 16: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

1. SELECT DISTINCT subject_id, last_name, first_name FROM student ORDER BY 1; 2. SELECT id, last_name, first_name, subject_id FROM student ORDER BY subject_id; How will the results differ? a. Statement 1 will be sorted alphabetically; statement 2 will not. b. Statement 1 will limit duplicate subject id's; statement 2 will not. c. Statement 2 will eliminate duplicate rows from the output; statement 1 will not. d. Statement 1 and 2 will display distinct combinations of the values in the STUDENT table. 53. Which statement concerning the referencing of declared variables within the executable section of a PL/SQL block is true? a. A variable declared in a nested block may not be referenced in any outer blocks. b. A variable declared in an outer block may reference variables declared in nested blocks. c. A declared variable may be referenced in all nested sub-blocks as well as any outer blocks. d. A variable declared in the executable section of a nested block may reference a variable declared in an

outer block. 54. Examine the structure of the TEACHER table: Name Null? Type --------------------------------------- ------------------------- ------------------------- ID NOT NULL NUMBER(9) SALARY NUMBER(7,2) SUBJECT_ID NOT NULL NUMBER(3) SUBJECT_DESCRIPTION VARCHAR2(20) There are 200 teachers and 15 subjects. Each subject is taught by at least 2 teachers. Evaluate this PL/SQL block: DECLARE v_pct_raise number := 1.10; BEGIN UPDATE teacher SET salary = salary * 1.10 WHERE subject_id IN (102, 105); COMMIT; END; Which result will the PL/SQL block provide? A. Only two teachers will receive a 10% salary increase. b. All of the teachers will receive a 10% salary increase. C. At least four teachers will receive a 10% salary increase. D. A syntax error will occur. 55. Evaluate this view definition: CREATE OR REPLACE VIEW parts_view AS SELECT manufacturer_id, COUNT(part_id) TOTAL_PARTS FROM parts

Page 17: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

GROUP BY manufacturer_id; Which statement can be issued on the PARTS_VIEW view? A. SELECT *

FROM parts_view;

B. UPDATE parts_view SET total_parts = 10000

WHERE manufacturer_id = 3983; C. DELETE FROM parts_view

WHERE manufacturer_id=340394 D. INSERT INTO parts_view

VALUES (89485, 1009); 56. Evaluate this SQL statement: SELECT manufacturer_id, COUNT(*), order_date FROM inventory WHERE price > 5.00 GROUP BY order_date, manufacturer_id HAVING COUNT(*) > 10 ORDER BY order_date DESC; Which clause specifies which rows will be returned from the INVENTORY table? A. WHERE price > 5.00 B. HAVING COUNT(*) > 10 C. ORDER BY order_date DESC; D. GROUP BY order_date, manufacturer_id 57. Which statement represents an equijoin? A. SELECT. id_number, m.manufacturer_id

FROM inventory i, manufacturer m WHERE i.manufacturer_id = m.manufacturer_id;

B. SELECT. id_number, m.manufacturer_id

FROM inventory i, manufacturer m WHERE i.manufacturer_id = m.manufacturer_id(+);

C. SELECT. id_number, m.manufacturer_id

FROM inventory i, manufacturer m WHERE i.manufacturer_id(+) = m.manufacturer_id;

D. SELECT. id_number, m.manufacturer_id

FROM inventory i, manufacturer m WHERE i.manufacturer_id = i.manufacturer_id AND i.id_number = 2365;

58. You attempt to query the database with this SQL statement: SELECT inventory.id_number, manufacturer.id_number FROM inventory i, manufacturer m WHERE i.manufacturer_id = m.id_number ORDER BY 1;

Page 18: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

Which clause causes an error? A. ORDER BY 1; B. FROM inventory i, manufacturer m C. WHERE i.manufacturer_id = m.id_number D. SELECT inventory.id_number, manufacturer.id_number 59. Evaluate this SELECT statement: SELECT s.student_name, s.grade_point_avg, s.major_id, m.gpa_avg FROM student s, (SELECT major_id, AVG(grade_point_avg) gpa_avg FROM student m GROUP BY major_id) m WHERE s.major_id = m.major_id AND s.grade_point_avg > m.gpa_avg; What will be the result of this SELECT statement? A. The names of all students with a grade point average that is higher than the average grade point average

in their major will be displayed. B. The names of all students with a grade point average that is higher than the average grade point average

of all students will be displayed. C. The names of all students with a grade point average that is higher than the average grade point average

of all students in each major will be displayed. D. A syntax error will be returned because the FROM clause CANNOT contain a subquery. 60. In the declaration section of a PL/SQL block, you create this variable: v_price NUMBER(4,2) NOT NULL; Which statement is true? A. The variable will be assigned the default value. B. The block will not execute because the variable must be initialized. C. The variable must be assigned a value in the executable section of the block. D. The variable contains a syntax error because a variable CANNOT use the NOT NULL constraint. 61. When would an index decrease the speed of a query? A. The table is small. B. The column is used in the WHERE clause. C. The column contains a wide range of values. D. The column contains a large number of null values. 62. Why would you NOT create an index on a column in the CLASS_SCHEDULE table? a. to reduce disk I/O b. to speed up row retrieval c. to speed up queries if the table has less than 50 rows d. to speed up queries that return less than 3% of the rows 63. For which result would you use a group function? a. to display the order date of orders in 'DD MON YYYY' format b. to convert the character string 'January 28, 2000' to a date format c. to produce a total of all the values in the COST column in the PRODUCT table d. to display all the values in the DESCRIPTION column in the PRODUCT table in lowercase 64. Which statement will Barbara use to create a private synonym for the EMPLOYEE table existing in her schema? a. CREATE SYNONYM emp

Page 19: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

FOR employee; b. CREATE PUBLIC SYNONYM emp

FOR barbara; c. CREATE PRIVATE SYNONYM emp

FOR barbara.employee; d. CREATE PUBLIC emp SYNONYM

FOR barbara.employee; 65. You have a command containing five lines of text stored in the SQL buffer. At the SQL prompt, you issue this command: DEL 2 3 What is the state of the buffer? a. The buffer is clear. b. The buffer is holding two lines of text. c. The buffer is holding five lines of text. d. The buffer is holding three lines of text. 66. Which command deletes the data in the EMPLOYEE table, its table structure, and any integrity constraints that reference the tables' primary and unique keys? a. DROP employee; b. DROP TABLE employee CASCADE CONSTRAINTS; c. TRUNCATE employee;

ALTER TABLE employee DROP PRIMARY KEY CASCADE;

d. Delete * FROM employee; ALTER TABLE employee

DROP PRIMARY KEY CASCADE; 67. Examine the EMP_HIST_V view: EMP_HIST_V Name Type ------------------------------ ---------------------- EMPLOYEE_ID NUMBER(6) NAME VARCHAR2(15) JOB VARCHAR2(9) MANAGER NUMBER(4) DATE_HIRED DATE SALARY NUMBER(7,2) BONUS NUMBER(7,2) DEPARTMENT_ID NUMBER(2) Which two statements will NOT successfully query the EMP_HIST_V view? (Choose two.) a. SELECT *

FROM emp_hist_v; b. SELECT *

FROM VIEW emp_hist_v; c. SELECT COUNT(*)

Page 20: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

FROM emp_hist_v; d. SELECT COUNT(*)

FROM VIEW emp_hist_v; 68.In which section of a PL/SQL block is a declared exception associated with a non-predefined Oracle Server exception? a. header b. exception c. executable d. declarative 69.Given the following…

Evaluate this SQL statement: SELECT id_number, description, SUM(price) FROM inventory WHERE price > 6.00 GROUP BY id_number ORDER BY manufacturer_id; Why will this statement cause an error? a. The ORDER BY clause should immediately follow the WHERE clause. b. The MANUFACTURER_ID column is not included in the SELECT clause. c. The ORDER BY clause cannot be used in a SELECT statement with a GROUP BY clause. d. The DESCRIPTION and MANUFACTURER_ID columns are not included in the GROUP BY clause. 70. Evaluate this CURSOR statement: DECLARE CURSOR price_cursor (v_price NUMBER(8,2)) IS SELECT id_number, description, manufacturer_id FROM inventory WHERE price > v_price; Why will this statement cause an error? a. A parameter is not defined. b. The SELECT statement is missing the INTO clause. c. A WHERE clause cannot be used in a CURSOR statement. d. The size of the variable does not need to be specified. 71. In the declaration section of a PL/SQL block, you create these variables:

Page 21: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

v_quantity_on_hand, v_quantity_needed NUMBER(9); Why does this statement cause an error? a. The datatype is invalid. b. A parameter mode was not declared. c. A value must be assigned to each variable. d. A constraint for each variable was not declared. e. Multiple variables cannot be declared in the same statement. 72. Which type of constraint can be defined at the column or table level, and whose condition can apply to any column in the table, not just the column on which it is defined? a. CHECK b. UNIQUE c. NOT NULL d. FOREIGN KEY 73. Which statement about nested blocks in a PL/SQL program is true? a. A nested block becomes a statement. b. Nested blocks can only contain an executable section. c. A variable defined in a nested block is only visible to its enclosing block. d. Statements can only be nested in the executable section of a PL/SQL block. 74. Which statement would you use to display the structure of the PARTS_VU view? a. DESCRIBE parts_vu b. DESCRIBE user_views c. SELECT *

FROM user_views WHERE lower(view) = parts_vu;

d. SELECT * FROM user_objects WHERE lower(user_view) = parts_vu;

75. Evaluate this block of code: 1. BEGIN 2. DECLARE 3. v_new_tech_id NUMBER := 879563; 4. v_old_tech_id NUMBER := 874512; 5. v_rows_updated NUMBER := 1; 6. BEGIN 7. UPDATE service 8. SET technician_id = v_new_tech_id 9. WHERE technician_id = v_old_tech_id; 10. v_rows_updated := SQL%ROWCOUNT; 11. END; 12. TEXT_IO.PUT_LINE (TO_CHAR(v_rows_updated)); 13. END; Which line of this code will return an error? a. 2 b. 5 c. 7 d. 12 76. Which characteristic applies to an implicit cursor? a. will process only one row

Page 22: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

b. will attempt only one fetch c. allows the programmer to control the number of fetches performed d. will perform only one fetch and will process all of the rows returned by the query 77. How does the USER_TABLES dictionary view differ from the ALL_TABLES data dictionary view? a. ALL_TABLES will display only the tables owned by the user. b. USER_TABLES will display only the tables owned by the user. c. ALL_TABLES will display only the tables on which the user has SELECT privileges. d. USER_TABLES will display all the tables on which the user has SELECT privileges. 78. How does the USER_TABLES dictionary view differ from the ALL_TABLES data dictionary view? a. ALL_TABLES will display only the tables owned by the user. b. USER_TABLES will display only the tables owned by the user. c. ALL_TABLES will display only the tables on which the user has SELECT privileges. d. SER_TABLES will display all the tables on which the user has SELECT privileges. 79. Evaluate the columns in the CUSTOMER and ORDER tables. CUSTOMER -------------------- CUSTOMER_ID NUMBER(5) NAME VARCHAR2(25) CREDIT_LIMIT NUMBER(8,2) ACCT_OPEN_DATE DATE ORDER ------------- ORDER_ID NUMBER(5) CUSTOMER_ID NUMBER(5) ORDER_DATE DATE TOTAL NUMBER(8,2) Which scenario would require a subquery to return the desired results? a. You need to display the names of all the customers who placed an order today. b. You need to determine the number of orders placed this year by the customer with ID value 30450. c. You need to determine the average credit limit of all the customers who opened an account this year. d. You need to determine which customers have a credit limit greater than the customer with ID value

30450. 80. Evaluate this IF statement: IF v_num < 10 THEN v_example := 1; ELSIF v_num < 15 THEN v_example := 2; ELSIF v_num < 20 THEN v_example := 3; ELSIF v_num < 39 THEN v_example := 4; ELSE v_example := 5; END IF; If V_NUM is 15, which value would be assigned to V_EXAMPLE? a. 1 b. 2 c. 3

Page 23: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

d. 4 e. 5 81. Given the following…

Evaluate this SQL statement: DELETE FROM inventory WHERE order_date > TO_DATE('25.07.1997', 'DD.MM.YYYY'); What is the ID_NUMBER of the row to be deleted? a. 32096 b. 25026 c. 32081 d. No value will be deleted. 82. Given the following…

The user needs to retrieve information on employees that have the same department id and salary as an employee id that they will enter. You want the query results to include employees that do not have a salary. Which statement will provide you with the desired results? a. SELECT *

FROM employee WHERE (department, salary) NOT IN (SELECT department, salary)

FROM employee WHERE employee_id = &1); b. SELECT *

FROM employee WHERE (department_id, salary) IN (SELECT department_id, NVL(salary, 0)

FROM employee WHERE employee_id = &1); c. SELECT *

FROM employee

Page 24: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

WHERE (department_id, NVL(salary, 0)) IN (SELECT department_id, NVL(salary, 0) FROM employee WHERE employee_id = &1); d. SELECT *

FROM employee WHERE (department_id, salary) IN (SELECT department_id, salary)

FROM employee WHERE employee_id = &1 AND salary IS NULL); 83. How does an implicit cursor differ from an explicit cursor? a. Explicit cursors are only for queries that return more than one row. b. Implicit cursors can be controlled using the OPEN, FETCH, and CLOSE statements. c. Explicit cursors are declared explicitly for all DML and PL/SQL SELECT statements. d. Implicit cursors are used to individually process each row returned by a multiple-row SELECT

statement. 84. On which side of the outer join condition would you place the outer join symbol? a. the side with matching rows b. the side without matching rows c. both sides of the join condition d. neither side of the join condition 85. The TEACHER table contains these columns: Name Null? Type --------------------------------------- ------------------------- ---------------------------- TEACHER_ID NOT NULL NUMBER(9) NAME VARCHAR2(25) SALARY NUMBER(7,2) SUBJECT_ID NOT NULL NUMBER(3) SUBJECT_DESCRIPTION VARCHAR2(2) You need to increase the salary of all science teachers by 8%. The SUBJECT_ID for science teachers is 011. Which statement will you use? a. UPDATE teacher

SET salary = salary * 1.08 WHERE subject_description LIKE 'SCIENCE'

b. UPDATE teacher

SET salary = salary * .08 WHERE subject_description LIKE 'SCIENCE' AND subject_id = 011

c. UPDATE teacher

SET salary = salary * 1.08 WHERE subject_id = 011;

d. UPDATE teacher

SET salary = salary + (salary * .08) WHERE subject_description LIKE 'SCIENCE' OR subject_id = 011

86. Which single row function can NOT be used on a VARCHAR2 column? a. NVL

Page 25: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

b. TRUNC c. ROUND d. SYSDATE 87. Given the following…

You must remove products from your system whose quantity is too low to be listed in your catalog and whose manufacturer, wallpp0925, is now out of business. You want to delete any products from inventory that were produced by this manufacturer, ordered before December 31, 1997, and have a quantity of less than 250. Which script will you use? a. DROP FROM inventory

WHERE quantity < 250 AND order_date < 31-DEC-97 AND manufacturer_id = wallpp0925;

b. DROP FROM inventory

WHERE quantity < 250 AND order_date > 31-DEC-97 AND manufacturer_id = 'wallpp0925';

c. DELETE FROM inventory

WHERE quantity < 250 AND order_date < '31-DEC-1997' AND manufacturer_id = 'wallpp0925';

d. DELETE FROM inventory

WHERE quantity < 250 AND order_date =< '31-DEC-1997' AND NOT manufacturer_id = wallpp0925;

88. Given the following…

You query the database with this SQL statement: SELECT MIN(manufacturer_id) FROM inventory;

Page 26: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

Which value is displayed? a. ejmad0225 b. sundel0525 c. belsot0426 d. The statement will not execute 89.Evaluate this SQL* Plus command: COLUMN product_name HEADING 'Product Name' FORMAT A20 Which two tasks will this command accomplish? (Choose two.) a. It will center the column heading of the PRODUCT_NAME column. b. It will set the PRODUCT_NAME column heading to 'Product Name'. c. It will limit the PRODUCT_NAME column heading to 20 characters. d. It will set the display width of the PRODUCT_NAME column to 20. e. It will display the current settings for the PRODUCT_NAME column. 90. Which statement will you use to display only the name, view definition, and the length of the view definition of the EMPLOYEE_HIST view? a. SELECT *

FROM user_views WHERE view_name = 'EMPLOYEE_HIST';

b. SELECT view_name, text, text_length

FROM user_views WHERE view_name = 'EMPLOYEE_HIST';

c. SELECT view_name, text, text_length

FROM VIEW user_objects WHERE view_name = 'EMPLOYEE_HIST

d. SELECT VIEW view_name, text, text_length

FROM all_objects WHERE view_name = 'EMPLOYEE_HIST';

91. Evaluate this executable section of a PL/SQL block: BEGIN SELECT last_name, first_name INTO v_last_name, v_first_name FROM student WHERE student_id = 3950; WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE ('Student not found'); END; Which result will the code provide? A. An error because there is an exception in the executable section of the block. B. An error because a SELECT statement with an INTO clause is not allowed in a PL/SQL block. C. The first and last name values in the PL/SQL variables will be inserted into the STUDENT table. D. The first and last name values of the student with student id 3950 will be stored in the PL/SQL variables.

Page 27: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

92. Which data dictionary view could you query to display the names of tables you have access to? a. USER_VIEWS b. USER_TABLES c. ALL_OBJECTS d. USER_OBJECTS 93. Which privilege is an object privilege? A. INDEX B. DROP USER C. CREATE SESSION D. BACKUP ANY TABLE 94. Which SQL statement creates the PARTS_456874_VU view that contains the ID_NUMBER, DESCRIPTION, and QUANTITY columns for MANUFACTURER_ID 456874 from the INVENTORY table and does not allow the manufacturer values to be changed through the view? a. CREATE VIEW parts_456874_vu

AS SELECT id_number, description, quantity FROM inventory WITH CHECK CONSTRAINT;

b. CREATE VIEW parts_456874_vu

AS SELECT id_number, description, quantity FROM inventory HAVING manufacturer_id = 456874 WITH READ ONLY;

c. CREATE VIEW parts_456874_vu

AS SELECT id_number, description, quantity FROM inventory WHERE manufacturer_id = 456874 WITH READ ONLY;

d. CREATE VIEW parts_456874_vu

AS SELECT id_number, description, quantity FROM inventory WHERE manufacturer_id = 456874 WITH CHECK OPTION;

95. Evaluate this cursor declaration: 1. DECLARE 2. CURSOR cust_cursor (p_cust_id, p_last_name) 3. IS 4. SELECT cust_id, first_name, last_name, credit_limit 5. FROM customer 6. WHERE cust_id = p_cust_id 7. AND last_name = p_last_name; Which line causes an error? A. 2 B. 3 C. 4 D. 5 E. 6 96. For which task would it be most appropriate to use a PL/SQL IF-THEN-ELSE statement?

Page 28: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

a. to add four new manufacturers to the MANUFACTURER table b. to increase the price values by 25% for all the items in inventory c. to increase the price values by 25% for all items in inventory that were manufactured by the Roomco

Company d. to decrease the price values by 25% for items with more than 500 in stock and by 15% for items with

more than 250 in stock 97. Examine the EMP_HIST_V view: EMP_HIST_V Name Type ------------------------- ---------------------- EMPLOYEE_ID NUMBER(6) NAME VARCHAR2(15) JOB VARCHAR2(9) MANAGER NUMBER(4) DATE_HIRED DATE SALARY NUMBER(7,2) BONUS NUMBER(7,2) DEPARTMENT_ID NUMBER(2) You need to query the EMP_HIST_V view. You must determine the average salary for all employees assigned to department 10 that were hired prior to January 1, 1995. Which statement will you use? A. SELECT department_id, AVG(salary)

FROM emp_hist_v WHERE date_hired < '01-JAN-1995' AND department_id = 10;

B. SELECT department_id, AVG(salary)

FROM emp_hist_v VIEW WHERE date_hired < '01-JAN-1995' AND department_id = 10;

C. SELECT department_id, AVG(salary)

FROM VIEW emp_hist_v WHERE date_hired < '01-JAN-1995' AND department_id = 10 GROUP BY department_id;

D. SELECT department_id, AVG(salary)

FROM emp_hist_v WHERE date_hired < '01-JAN-1995' AND department_id = 10 GROUP BY department_id;

98. Evaluate this SQL statement: SELECT i.id_number, m.manufacturer_id FROM inventory i, inventory m WHERE i.manufacturer_id = m.id_number; Which type of join is used in this statement? a. self b. outer c. equijoin

Page 29: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

d. non-equijoin 99. Which statement regarding cursor FOR loop guidelines is true? A. They require an OPEN statement. B. They require a terminating condition. C. They do not require a FETCH statement. D. They must declare the record that controls the loop. 100.Given the following…

You query the database with this SQL statement: SELECT manufacturer_id, SUM(price) FROM inventory GROUP BY manufacturer_id; Which MANUFACTURER_ID value is displayed first? a. sundel0525 b. belsot0426 c. ejmadb0225 d. packex0122 101.Which clause is required in a SELECT statement within a PL/SQL block? A. INTO B. WHERE C. HAVING D. GROUP BY E. ORDER BY 102.In the executable section of a PL/SQL block, you include this statement: inventory (55) := 'Walt'; Which task will this accomplish? a. A constant will be assigned a value. b. A scalar variable will be assigned a value. c. A PL/SQL table element will be assigned a number value. d. PL/SQL table element will be assigned a character string value. 103.Evaluate this PL/SQL block: BEGIN UPDATE teacher SET salary = salary * 1.05 WHERE subject_id IN (101, 102, 103); COMMIT;

Page 30: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

EXCEPTION WHEN SQL%NOTFOUND = TRUE THEN dbms_output.put_line(TO_CHAR(SQL%ROWCOUNT)); END; What would cause output to be displayed? A. An error occurs B. No rows were updated. C. Only one row was updated. D. More than one row was updated. 104. Given the following…

Evaluate this statement: CREATE TABLE sale_items (id_number NUMBER(9), description VARCHAR2(25)) AS SELECT id_number, description FROM inventory WHERE quantity > 500; Why will this statement cause an error? A. A clause is missing. B. A keyword is missing. C. The WHERE clause cannot be used when creating a table. D. The datatypes in the new table do not need to be defined. 105. Which script will you execute to create new user DAVE and give him the ability to connect to the database and the ability to create tables, sequences, and procedures? a. CREATE USER dave

IDENTIFIED BY dave18; GRANT create table, create sequence, create procedure TO dave;

b. CREATE USER dave

IDENTIFIED BY dave18; GRANT create session, create table, create sequence, create procedure TO dave;

c. CREATE dave

IDENTIFIED BY dave18; GRANT create connect, table, sequence, procedure TO dave;

Page 31: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

d. CREATE OR REPLACE USER dave IDENTIFIED BY dave18; GRANT create session, table, sequence, procedure;

106. Review this SQL statement: SELECT i. manufacturer_id, m.id_number FROM inventory i, manufacturer m WHERE i.manufacturer_id = m.id_number ORDER BY inventory.description; This statement fails when executed. Which change will correct the problem? A. Use the table alias in the ORDER BY clause. B. Remove the table aliases from the WHERE clause. C. Use the table names instead of the table aliases in the WHERE clause. D. Remove the table name from the ORDER BY clause, and use only the column name. 107. Given the following…????????????????

A sort order of ASC or DESC must be specified in the ORDER BY clause. Remove the column alias from the WHERE clause and use the column name. Remove the column alias from the ORDER BY clause and use the column name. Enclose all of the column aliases in single quotes instead of double quotes. 108. Which clause could you use to restrict values returned by a group function? a. WHERE b. HAVING c. ORDER BY d. A group function cannot be restricted 109. What is an appropriate label for a nested loop? A. --Inner loop B. &&Inner_loop C. /*Inner Loop*/ D. <<Inner_loop>> 110. Which system privilege may be granted to a role? A. ALTER B. EXECUTE C. REFERENCES D. BACKUP ANY TABLE 111. What is the syntax for removing a primary key constraint and all its dependent constraints? a. ALTER TABLE table

DROP PRIMARY KEY CASCADE;

Page 32: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

b. ALTER TABLE table

REMOVE CONSTRAINT PRIMARY KEY CASCADE; c. ALTER TABLE table

DISABLE CONSTRAINT PRIMARY KEY CASCADE; d. A primary key constraint cannot be removed. 112. Examine this declaration section of a PL/SQL block: DECLARE TYPE product_table_type IS TABLE OF product%ROWTYPE INDEX BY BINARY_INTEGER; product_table product_table_type; Evaluate this statement: product_table(10).manufacturer_id := 5; Which statement is true? A. The statement sets the MANUFACTURER_ID in the PRODUCT table to 10. B. The statement sets the MANUFACTURER_ID in the PRODUCT table to 5. C. The statement assigns the MANUFACTURER_ID field in record 10 of the PL/SQL table the value of 5. D. The statement assigns the MANUFACTURER_ID field in record 5 of the PL/SQL table the value of 10. 113. You need to create the ELEMENT table. The atomic weights of elements have varying decimal places. For example, values could be 4, 4.35, or 4.3567. Which datatype would be most appropriate for the atomic weight values? A. LONG B. NUMBER C. NUMBER(p,s) D. None 114. Which action will cause an automatic rollback? a. a GRANT command b. a CREATE command c. the system crashes d. exiting from SQL*Plus without first issuing a COMMIT command 115. Which type of commands are supported by PL/SQL? A. DDL B. DCL C. DML D. No commands are supported by PL/SQL 116. In the declaration section of a PL/SQL block, you create this variable: v_price_increase BOOLEAN := 0; Why does this statement cause an error? A. A value must be assigned. B. Constraints are not allowed. C. Default values are not allowed. D. The variable is initialized incorrectly.

Page 33: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

117. Given the following…

You want to display all of the product identification numbers of products if there are more than 100 of the product in stock. You want the product numbers displayed alphabetically by the manufacturer, then by the product number from lowest to highest. Which statement will you use to achieve the required results? a. SELECT id_number

FROM inventory WHERE quantity > 100 ORDER BY manufacturer_id, id_number;

b. SELECT id_number

FROM inventory WHERE quantity => 100 SORT BY manufacturer_id, id_number;

c. SELECT id_number

FROM inventory WHERE quantity > 100 ORDER BY manufacturer_id, id_number DESC;

d. SELECT id_number

FROM inventory WHERE quantity > 100 SORT BY manufacturer_id, id_number;

118. You query the database with this SQL statement: SELECT price FROM inventory WHERE price BETWEEN 1 AND 50 OR (price IN(25, 70, 95) AND price BETWEEN 25 AND 75); Which value could the statement retrieve? 30 51 75 95 119. Which SELECT statement could you use if you wanted to display unique combinations of the ID_NUMBER and MANUFACTURER_ID values from the INVENTORY table? A. SELECT DISTINCT manufacturer_id

FROM inventory

Page 34: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

B. SELECT id_number, manufacturer_id FROM inventory;

C. SELECT DISTINCT id_number, manufacturer_id

FROM inventory; D. SELECT id_number, manufacturer_id DISTINCT

FROM inventory; 120. You need to create a variable in a PL/SQL block to allow all the rows and columns from the CUSTOMER table to be retrieved using a single SELECT statement. Which declaration statement should you use to achieve this result? a. DECLARE

TYPE customer_table_type IS TABLE OF customer%ROWTYPE INDEX BY BINARY_INTEGER; customer_table customer_table_type; b. DECLARE

TYPE customer_table_type IS TABLE OF customer%TYPE INDEX BY BINARY_INTEGER; customer_table customer_table_type; c. DECLARE

customer_table_type customer%ROWTYPE INDEX BY BINARY_INTEGER; customer_table customer_table_type; d. DECLARE

customer_table_type customer%ROWTYPE; customer_table customer_table_type; 121. Which three values are displayed by the DESCRIBE command? (Choose three.) A. table owner B. column names C. table name D. column datatypes E. NOT NULL columns 122. In which section of a PL/SQL block would you place a RAISE statement? A. header B. exception C. executable D. declarative 123. You accidentally changed all the TECHNICIAN_ID values to 999999 using the UPDATE command without a WHERE clause. Which command could you issue to undo these changes? a. EXIT b. QUIT c. COMMIT d. ROLLBACK 124. You issue this statement: CREATE FORCE VIEW parts_vu (company, contact) AS SELECT manufacturer_name, contact_name FROM inventory

Page 35: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

WITH READ ONLY; Which command can be issued on the PARTS_VU view? A. UPDATE B. DELETE C. SELECT D. INSERT 125.Which operator could be used to test a column for NULL values? A. = B. != C. <> D. = NULL E. IS NULL 126.Which predefined Oracle Server exception would you use to handle an error caused by a SQL statement that returns more than one row? a. VALUE_ERROR b. NO_DATA_FOUND c. TOO_MANY_ROWS d. ACCESS_INTO_NULL e. COLLECTION_IS_NULL 127.Which two operators can be used in an outer join condition? (Choose two.) A. = B. OR C. IN D. AND 128.Evaluate this PL/SQL block: DECLARE v_low NUMBER := 1; v_high NUMBER := 6; v_count NUMBER := 2; BEGIN FOR i IN v_low..v_high LOOP v_count := v_count + 1; END LOOP; END; How many times will the loop execute? A. 0 B. 1 C. 4 D. 6 E. 7 129.Which script displays the ORDER_DATE value of '23-MAY-00' as '01-JAN-00'? a. SELECT ROUND(order_date, 'DAY')

FROM inventory; b. SELECT ROUND(order_date, 'YEAR')

FROM inventory; c. SELECT ROUND(order_date, 'MONTH')

Page 36: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

FROM inventory; d. SELECT ROUND(TO_CHAR(order_date, 'YYYY'))

FROM inventory; 130.Which section of a PL/SQL block contains the keyword BEGIN? a. end b. executable c. declarative d. exception handling 131.Which SQL command would you use to remove the PARTS_VU view? A. DROP parts_vu; B. DELETE parts_vu; C. DROP VIEW parts_vu; D. DELETE VIEW parts_vu; 132.Which SELECT statement will return a numeric value? a. SELECT order_date / 7

FROM inventory; b. SELECT (order_date + 366/24)

FROM inventory; c. SELECT (SYSDATE, order_date) / 7

FROM inventory; d. SELECT (SYSDATE - order_date) / 7

FROM inventory; 133. You query the database with this SQL statement: SELECT manufacturer_id FROM inventory WHERE manufacturer_id LIKE '%N\%P\%O%' ESCAPE '\'; For which character pattern is the LIKE operator searching? a. NPO b. N\P\O c. N%P%O d. N\%P\%O 134. Which data dictionary view would you query to list only the views you own? A. ALL_VIEWS B. USER_VIEWS C. ALL_OBJECTS D. USER_OBJECTS 135. The STUDENT table contains these columns: ID NUMBER(9) FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25) Evaluate this SQL statement:

Page 37: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

SELECT * FROM student WHERE id = (SELECT id FROM student WHERE UPPER(first_name) = 'KATE' AND UPPER(last_name) = 'HENRY'); What would cause this statement to fail? A. There are no students named Kate Henry. B. There is more than one student named Kate. C. There is more than one student named Kate Henry. D. The FIRST_NAME and LAST_NAME values in the database are in lowercase. 136. For which two types of constraints are indexes automatically created? (Choose two.) a. CHECK b. UNIQUE c. NOT NULL d. PRIMARY KEY e. FOREIGN KEY 137. Evaluate this SELECT statement: SELECT employee_id, name FROM employee WHERE employee_id NOT IN (SELECT employee_id FROM employee WHERE department_id = 30 AND job = 'CLERK'); What would happen if the inner query returned a NULL value? a. No rows would be selected from the EMPLOYEE table. b. All the EMPLOYEE_ID and NAME values in the EMPLOYEE table would be displayed. c. Only the rows with EMPLOYEE_ID values equal to null would be included in the results. d. A syntax error would be returned. 138. Evaluate this command: TRUNCATE TABLE inventory; Which two statements about this TRUNCATE TABLE command are true? (Choose two.) A. This statement will retain the structure of the INVENTORY table. B. You must be the owner of the INVENTORY table to use this command. C. The results of this statement can be rolled back using the ROLLBACK command. D. This statement will permanently remove all the data from the INVENTORY table. E. This statement will produce the same result as the DROP TABLE inventory command. Why would you use the RAISE_APPLICATION_ERROR procedure in a PL/SQL block? A. to trap a user-defined exception B. to trap a TOO_MANY_ROWS exception C. to raise a TOO_MANY_ROWS exception D. to issue a user-defined error message 140. Evaluate this SQL statement: SELECT id_number

Page 38: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

FROM inventory WHERE manufacturer_id IN (SELECT manufacturer_id FROM inventory WHERE price < 1.00 OR price > 6.00); How many values can the subquery return? a. 0 b. only 1 c. up to 2 d. unlimited 141.Why would you query the ALL_COL_PRIVS_RECD data dictionary view? a. to display the owner of the ORDER table on which you have NOT been granted any privileges b. to display all the users to which you have granted the SELECT privileges on the EMP_ID column c. to display all the users to which you have granted the UPDATE privilege on the INVENTORY table d. to display the schema that owns the CUSTOMER table on which you have been granted SELECT

privileges on the LAST_NAME and FIRST_NAME columns 142. A subquery CANNOT be used in a(n) ______ operation. A. CREATE VIEW statement B. CREATE TABLE statement C. VALUES clause an INSERT statement D. INTO clause of a SELECT statement E. SET clause of an UPDATE statement 143. Examine the structure of the TEACHER table: Name Null? Type --------------------------------------- ------------------------- ------------------------- ID NOT NULL NUMBER(9) SALARY NUMBER(7,2) SUBJECT_ID NOT NULL NUMBER(3) SUBJECT_DESCRIPTION VARCHAR2(2) You must give every teacher with a SUBJECT_ID of 101, 102, and 103 a 5 percent pay increase. You want to display a "0" (zero) if no rows are updated. Which PL/SQL block will you use? A. BEGIN

UPDATE teacher SET salary = salary * 1.05 WHERE subject_id IN (101, 102, 103); COMMIT; IF SQL%NOTFOUND = TRUE THEN dbms_output.put_line(TO_CHAR(SQL%ROWCOUNT)); END IF; END; B. BEGIN

UPDATE teacher SET salary = salary + .05 WHERE subject_id IN (101, 102, 103); COMMIT; EXCEPTION WHEN SQL%NOTFOUND = TRUE THEN dbms_output.put_line(TO_CHAR(SQL%ROWCOUNT));

Page 39: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

END; C. BEGIN

UPDATE teacher SET salary = salary * 1.05 WHERE subject_id IN (101, 102, 103); COMMIT; EXCEPTION IF SQL%FOUND = FALSE THEN dbms_output.put_line(TO_CHAR(SQL%ROWCOUNT)); END IF; END; D. BEGIN

UPDATE teacher SET salary = salary * 1.05 WHERE subject_id = (101, 102, 103); COMMIT; END; EXCEPTION IF SQL%NOTFOUND = TRUE THEN dbms_output.put_line(TO_CHAR(SQL%ROWCOUNT)); 144. When displaying data from two or more related tables, which clause would contain the join condition? a. FROM b. WHERE c. SELECT d. HAVING e. GROUP BY 145. Which clause restricts the groups of rows displayed to those groups meeting a specified condition? a. FROM b. WHERE c. SELECT d. HAVING e. GROUP BY 146. Which privilege can only be granted to a user and not to a role? A. ALTER B. DELETE C. INSERT D. EXECUTE E. REFERENCES 147. Tim created the SCHEDULE table. These are the columns in the SCHEDULE table: ID NUMBER(9) PK NAME VARCHAR2(25) CLASS_DATE DATE He granted you the INSERT privilege on the table. You insert three records into the SCHEDULE table without issuing a COMMIT command. Tim issues this command: SELECT * FROM schedule;

Page 40: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

Which three statements are true? (Choose three.) A. Tim will be able to access the SCHEDULE table. B. Tim will NOT be able to access the SCHEDULE table. C. Tim will see the three records you inserted into the SCHEDULE table. D. Tim will NOT see the three records you inserted into the SCHEDULE table. E. Tim will NOT be able to insert the same records into the SCHEDULE table. 148. Which ALTER TABLE statement would you use to add a primary key constraint on the MANUFACTURER_ID column of the INVENTORY table? a. ALTER TABLE inventory

ADD CONSTRAINT manufacturer_id PRIMARY KEY; b. ALTER TABLE inventory

ADD CONSTRAINT PRIMARY KEY (manufacturer_id); c. ALTER TABLE inventory

MODIFY manufacturer_id CONSTRAINT PRIMARY KEY; d. ALTER TABLE inventory

MODIFY CONSTRAINT PRIMARY KEY manufacturer_id; 1. 149. Evaluate this statement: ALTER TABLE inventory DISABLE CONSTRAINT inventory_id_number_pk CASCADE; Which task would this statement accomplish? a. Delete only the primary key. b. Disable only the primary key. c. Alter all dependent integrity constraints. d. Disable all dependent integrity constraints. 2. 150.Benefits are based on the number of years an employee has been employed. You need to create a

report to display each employee's name, id number, date hired, and the number of years employed, rounded to a whole number, based on the number of months from the date hired until today. Which statement produces the required results?

A. SELECT first_name, last_name, emp_id, date_hired, ROUND(SYSDATE) - ROUND(date_hired) FROM employee;

B. SELECT first_name, last_name, emp_id, date_hired,

(ROUND(SYSDATE) - ROUND(date_hired)) / 12 FROM employee;

C. SELECT first_name, last_name, emp_id, date_hired,

TRUNC(SYSDATE, 'YY') - TRUNC(date_hired, 'YY') FROM employee;

D. SELECT first_name, last_name, emp_id, date_hired,

ROUND(MONTHS_BETWEEN(SYSDATE, date_hired) / 12) FROM employee;

151. Which data dictionary view would you query to display the SELECT privileges granted on columns of tables that you own? A.USER_CATALOG B.DBA_CONS_COLUMNS

Page 41: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

C.ALL_COL_PRIVS_RECD D.ALL_COL_PRIVS_MADE 152.Which statement will Marilyn use to eliminate the need to type the full table name when querying the TRANSACTION_HISTORY table existing in her schema? a. CREATE PUBLIC SYNONYM trans_hist

FOR marilyn; b. CREATE SYNONYM trans_hist

FOR transaction_history; c. CREATE PRIVATE SYNONYM trans_hist

FOR marilyn.transaction_history; d. CREATE PUBLIC trans_hist SYNONYM

FOR marilyn.transaction_history; 153. Which value is stored in %NOTFOUND if the query returns two rows and the first FETCH statement has been issued? a. TRUE b. NULL c. FALSE d. None 154. The INSTRUCTOR table contains these columns: ID NUMBER(9) PK LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(15) SALARY NUMBER(9) Evaluate this SQL statement: SELECT salary, last_name FROM instructor ORDER BY salary, last_name; Which conclusion can be drawn after the execution of this statement? A. The results are sorted numerically only. B. The results are sorted alphabetically only. C. The results are sorted numerically and then alphabetically. D. The results are sorted alphabetically and then numerically. 155. In the executable section of a PL/SQL block, you include this statement: inventory_record.manufacturer_id := 'jklm1234'; inventory_record.description := 'cotton'; Which task will this accomplish? a. A constant will be created. b. A constant will be initialized. c. A scalar value will be assigned a value. d. A record field will be assigned a number value. e. A record field will be assigned a character string value. 156. Evaluate this PL/SQL assignment statement:

Page 42: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

v_choice := v_first AND v_second; Which value is assigned to V_CHOICE if V_FIRST is set to NULL and V_SECOND is set to TRUE? a. 0 b. NULL c. TRUE d. FALSE 157. Evaluate the DEPARTMENT table: DEPT_ID NUMBER(9) DEPT_NAME VARCHAR2(20) REGION_ID NUMBER(9) The REGION_ID column has a foreign key constraint to the REGION table. You attempt to update the DEPARTMENT table using this statement: UPDATE department SET dept_id = 6546, region_id = 9705 WHERE dept_id = 8940; You receive this error: ORA-02291: integrity constraint (SYS_C23) violated - parent key not found What caused this error to be generated? a. Value 6546 already exists in the REGION table. b. Value 6546 already exists in the DEPARTMENT table. c. Value 9705 does not exist in the REGION table. d. Value 8940 does not exist in the DEPARTMENT table. 158. Evaluate this PL/SQL block: BEGIN FOR i IN 1..8 LOOP IF i = 2 THEN null; ELSE IF i = 5 THEN ROLLBACK; ELSE IF i = 8 THEN COMMIT; ELSE INSERT INTO example(one) VALUES (i); END IF; END IF; END IF; END LOOP; COMMIT; END; How many values will be inserted into the EXAMPLE table?

Page 43: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

A. 0 B. 1 C. 2 D. 3 E. 5 159. The CUSTOMER table contains these columns: CUSTOMER_ID NUMBER(9) LAST_NAME VARCHAR2(20) FIRST_NAME VARCHAR2(20) STREET_ADDRESS VARCHAR2(30) CITY VARCHAR2(20) STATE VARCHAR2(15) POSTAL_CODE VARCHAR2(9) Evaluate these two statements: 1. SELECT CONCAT(INITCAP(first_name), INITCAP(last_name)) FROM customer; 2. SELECT INITCAP(first_name) || INITCAP(last_name) FROM customer; Which statement is true? a. The statements will display the same output. b. The two statements will not display the same data. c. The data retrieved by the statements will be the same, but the display will differ. d. One of the statements will fail because it contains a syntax error. 160. You create this sequence: CREATE SEQUENCE part_id; How many sequential values will the Oracle Server preallocate and keep in memory? a. 1 b. 20 c. 10^27 d. It was not defined. 161. The TEACHER table contains these columns: ID NUMBER(9) PK SALARY NUMBER(7,2) SUBJECT_ID NUMBER(3) You need to create a SQL script that will prompt the user to input an id number and a percent increase value. Each teacher's salary should be multiplied by the percent increase provided. Which SQL*Plus script would you use to achieve the desired results? a. UPDATE teacher

SET salary = salary * &increase /

b. UPDATE teacher

SET salary = salary * &increase WHERE id = &id

Page 44: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

/ c. UPDATE teacher

SET salary = &salary WHERE subject_id = &subject_id /

d. UPDATE teacher

SET salary = salary * &increase WHERE subject_id = &subject_id /

162. In the declaration section of a PL/SQL block, you create this variable: v_price_increase NUMBER(2); What is the value of this variable when the block executes? A. 0 B. 1 C. 2 D. null 163. Evaluate this SQL script: CREATE USER hr IDENTIFIED BY hr01; CREATE ROLE hr_director; GRANT hr_director TO hr; GRANT SELECT ON teacher TO hr_director; CREATE OR REPLACE ROLE hr_director / How many users are granted the HR_DIRECTOR role and how many privileges are granted to the HR_DIRECTOR role? a. 1 user and 1 privilege b. 1 user and no privileges c. no users and 1 privilege d. no users and no privileges 164. Which datatype's default display is right justified? a. CHAR b. DATE c. NUMBER d. VARCHAR2 165. You are writing PL/SQL code to set the operator name to Jane, the department number to 15, and the service charge to 25.00 if the customer id is 2004. Which type of control structure should you use to achieve this result? a. FOR loop b. basic loop c. simple IF statement d. IF-THEN-ELSE statement e. IF-THEN-ELSIF statement 166. You gave user JOE the INDEX and REFERENCES privileges on the INVENTORY table. Which command did you use?

Page 45: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

A. GRANT ALL ON inventory TO joe;

B. GRANT ANY PRIVILEGE

ON inventory TO joe;

C. GRANT INDEX AND REFERENCES

ON inventory TO joe;

D. GRANT ALL WITH GRANT OPTION

ON inventory TO joe;

167. The STUDENT table contains these columns: ID NUMBER(9) PK LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) ENROLL_DATE DATE Evaluate this SQL script: DEFINE enroll_date_2 = '01-JUN-1999' SELECT * FROM student WHERE enroll_date = ('&enroll_date_2') / Which change should you make to the script so that it will execute? a. Remove the '&'. b. Remove the single quotation marks. c. Specify the DATE datatype in the DEFINE command. d. Replace the DEFINE command with 'ACCEPT enroll_date_2 DATE'. 168. Given the following…

A value of 8 is returned when you execute your query. Which statement did you use? a. SELECT SUM(price)

FROM inventory; b. SELECT manufacturer_id

FROM inventory;

Page 46: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

c. SELECT COUNT(AVG(price)

FROM inventory; d. SELECT COUNT(manufacturer_id)

FROM inventory; 169. When controlling an explicit cursor, which statement contains the INTO clause? a. OPEN b. FETCH* c. CLOSE d. CURSOR 170. The PERSONNEL table contains these columns: ID NUMBER(9) LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) MANAGER_ID NUMBER(9) DEPT_ID NUMBER(9) Evaluate this SQL statement: SELECT p.dept_id, p.first_name|| ' ' ||p.last_name employee, c.first_name|| ' ' ||c.last_name coworker FROM personnel p, personnel c WHERE p.dept_id = c.dept_id AND p.id <> c.id; Which result will the statement provide? A. It will display each employee's department number, name, and their manager's name. B. It will display each employee's department number, name, and all their coworkers in the same

department. C. It will display each department, the manager in each department, and all the employees in each

department. D. It will return a syntax error. 171. Evaluate this SQL statement: SELECT e.name, e.employee_id, e.department_id, d.location FROM employee e, department d WHERE employee.department_id = department.department_id ORDER BY e.name; This statement fails when executed. Which change will correct the problem? a. Use the table alias in the ORDER BY clause. b. Remove the table aliases from the WHERE clause. c. Use the table aliases instead of the table names in the WHERE clause. d. Remove the table name from the ORDER BY clause and use only the column name. 172. Evaluate this SQL statement: SELECT id_number "Part Number", SUM(price) "Price" FROM inventory WHERE price > 5.00 GROUP BY "Part Number"

Page 47: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

ORDER BY 2; Which clause will cause an error? a. ORDER BY 2; b. FROM inventory c. WHERE price > 5.00 d. GROUP BY "Part Number" 173. In which two commands could you use the ENABLE clause? (Choose two.) a. ALTER VIEW b. ALTER TABLE c. CREATE VIEW d. CREATE TABLE 174. Which cursor attribute evaluates to TRUE if the most recent SQL statement affects one or more rows? A. SQL%FOUND B. SQL%ISOPEN C. SQL%ROWCOUNT D. SQL%NOTFOUND 175. Evaluate this cursor declaration: DECLARE CURSOR inv_cursor (p_man_id NUMBER, p_name VARCHAR2) IS SELECT id, name FROM inventory WHERE manufacturer_id = p_man_id AND name = p_name; Which statement could be used to open this cursor? a. OPEN inv_cursor (40594, 'Cable');] b. OPEN CURSOR inv_cursor (40594, Cable); c. OPEN CURSOR inv_cursor (40594, 'Cable'); d. OPEN inv_cursor CURSOR (40594, 'Cable'); Answer Key: 1. C 2. B 3. B 4. B 5. D 6. C 7. A 8. B 9. A 10. D 11. A 12. A

Page 48: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

13. A 14. C 15. A 16. C 17. B 18. D 19. B 20. D 21. C 22. D 23. B,D 24. A 25. A 26. C 27. B 28. A 29. C 30. A 31. D 32. C 33. C 34. D 35. D 36. A 37. B 38. D 39. D 40. A 41. C 42. B 43. C 44. A 45. D 46. B 47. C 48. A 49. B 50. B 51. D 52. D 53. A 54. C 55. A

Page 49: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

56. A 57. A 58. D 59. A 60. B 61. A 62. C 63. C 64. A 65. D 66. B 67. B,D 68. D 69. D 70. D 71. E 72. A 73. A 74. A 75. D 76. A 77. B 78. B 79. D 80. C 81. B 82. C 83. A 84. B 85. C 86. D 87. C 88. C 89. B,D 90. B 91. A 92. C 93. A 94. C 95. A 96. D 97. D 98. A

Page 50: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

99. C 100. B 101. A 102. D 103. A 104. D 105. B 106. A 107. B 108. B 109. D 110. D 111. A 112. C 113. B 114. C 115. C 116. D 117. A 118. A 119. C 120. A 121. B,D,E 122. C 123. D 124. C 125. E 126. C 127. A,D 128. D 129. B 130. B 131. C 132. D 133. C 134. B 135. C 136. B,D 137. A 138. A,D 139. D 140. D 141. D

Page 51: Oracle Introduction to PL/SQL8. When will a SELECT statement in a PL/SQL block raise an exception? a. It retrieves only one row. b. It retrieves more than one row. c. The SELECT statement

142. C 143. A 144. B 145. D 146. E 147. A,D,E 148. B 149. D 150. D 151. D 152. B 153. C 154. C 155. E 156. B 157. C 158. C 159. A 160. B 161. B 162. D 163. A 164. C 165. C 166. A 167. D 168. D 169. B 170. B 171. C 172. D 173. B,D 174. A 175. A