You are on page 1of 15

1.

Examine this procedure: CREATE OR REPLACE PROCEDURE DELETE_PLAYER(V_IDIN NUMBER) IS BEGIN DELETE FROM PLAYER WHERE ID = V_ID EXCEPTION WHEN STATS_EXI TS_EXCEPTI ON THEN DBMS_OUTPUT. PUT_LINE(Cannotdeletethisplayer, childrecordsexistin PLAYER_BAT_STAT table);END; What prevents this procedure from being created successfully? A. A comma has been left after the STATS_EXIST_EXCEPTION exception. B. The STATS_EXIST_EXCEPTION has not been declared as a number. C. The STATS_EXIST_EXCEPTION has not been declared as an exception. D. Only predefined exceptions are allowed in the EXCEPTION section. Answer C 2. What is true about stored procedures? A. A stored procedure uses the DELCLARE keyword in the procedure specification to declare formal parameters. B. A stored procedure is named PL/SQL block with at least one parameter declaration in the procedure specification. C. A stored procedure must have at least one executable statement in the procedure body. D. A stored procedure uses the DECLARE keyword in the procedure body to declare formal parameters. Answer C 3. Which type of argument passes a value from a procedure to the calling environment? A. VARCHAR2 B. BOOLEAN C. OUT D. IN Answer C 4. You want to create a PL/SQL block of code that calculates discounts on customer orders. This code will be invoked from several places, but only within the program unit ORDERTOTAL. What is the most appropriate location to store the code that calculates the discounts? A. A stored procedure on the server. B. A block of code in a PL/SQL library. C. A standalone procedure on the client machine. D. A block of code in the body of the program unit ORDERTOTAL. E. A local subprogram defined within the program unit ORDERTOTAL. Answer E 5. Examine this procedure: CREATE OR REPLACE PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHAR2) IS BEGIN INSERT INTO PLAYER (ID,LAST_NAME) VALUES (V_ID, V_LAST_NAME);

COMMIT; END; This procedure must invoke the APD_BAT_STAT procedure and pass a parameter. Which statement, when added to the above procedure will successfully invoke the UPD_BAT_STAT procedure? A. EXECUTE UPD_BAT_STAT(V_ID); B. UPD_BAT_STAT(V_ID); C. RUN UPD_BAT_STAT(V_ID); D. START UPD_BAT_STAT(V_ID); Answer B 6. When creating a function in SQL *Plus, you receive this message: .Warning: Function created with compilation errors.. Which command can you issue to see the actual error message? A. SHOW FUNCTION_ERROR B. SHOW USER_ERRORS C. SHOW ERRORS D. SHOW ALL_ERRORS Answer C 7. Which two statements describe the state of a package variable after executing the package in which it is declared? (Choose two) A. It persists across transactions within a session. B. It persists from session to session for the same user. C. It does not persist across transaction within a session. D. It persists from user to user when the package is invoked. E. It does not persist from session to session for the same user. Answer E 8. You have created a stored procedure DELETE_TEMP_TABLE that uses dynamic SQL to remove a table in your schema. You have granted the EXECUTE privilege to user A on this procedure. When user A executes the DELETE_TEMP_TABLE procedure, under whose privileges are the operations performed by default? A. SYS privileges C. Public privileges D. User A.s privileges E. User A cannot execute your procedure that has dynamic SQL. Answer D 9. Where should the group by clause be placed in the SQL query.. Ans--- After Where clause

10. Will Delete from tablename work without where clause AnsYes 11. Qn based on this DBA_DATA_FILES, V$DATAFILE, DBA_SESSION.etc 12.Question based on Multiple row subquery compared with = operator in the where clause. Ans--- Query will fail 13. Qn based on Which are valid PL/SQL Blocks 14. DECLARE CURSOR query_cursor(v_salary)IS SELECT last_name,salary,dept_no FROM employee WHERE SALARY>v_salary; Why does this statement cause an error? A. The parameter mode is not defined. B. A where clause is not allowed in a cursor statement. C. The into clause is missing from the select statement. D. A scalar data type was not specified for the parameter. Answer: D 15. Which is used to restrict the group functions Ans--- Having clause 16. Syntax for creating INDEX Two questions on index -----------------------------17. Syntax for modifying a column from varchar2(1000) to varchar2(2000) in a table where already 20000 rows exists in that table Ans---ALTER TABLE TABLE_NAME MODIFY COLUMN_NAME VARCHAR2(2000) 18. See what a NOVALIDATE command will do Question goes like this A primary key column exists in a table after inserting some rows I disable the primary key constraint by giving the command

ALTER TABLE TABLENAME DISABLE CONTRAINT Primary_key_name After that novalidate is given for enabling options are : A.Primary key constraint is enabled, it will check for the existing rows and also the new rows to be inserted. B. Primary key constraint is not enabled, it will not check for the existing rows but check for the new rows to be inserted Various combinations of these. Ans--- B 19. Which cursor attribute is used to find whether the current fetch was unsuccessful AnsSQL%NOTFOUND 20. PL/SQL BLOCK Begin i=0 While i<=3 loop ----End loop How many times this loop will be executed. Ans4 21. One question based on %Rowtype.. listing the advantages of using it 22.Check based qn.. A. No index created for varrays B. index created for Nested Table C. ---- Not sure D.----- Not sure

23. You want to create a cursor that can be used several times in a block. Selecting a

different active set each time that it is opened. Which type of cursor do you create? A. A cursor for loop. B. A multiple selection cursor. C. A cursor for each active set. D. A cursor that uses parameters. Ans --- D 24.Evaluate this PL/SQL block. BEGIN FOR i IN 1..10 LOOP IF I=4 OR I=6 THEN null; ELSE INSERT INTO test(result) VALUES (I) ; END IF; COMMIT; END LOOP; ROLL BACK; END. How many values will be inserted into the TEST table? A. 0 B. 4 C. 6 D. 8 E. 10 Ans --- D 25. Name of the exception which is used to handle row errors AnsTOO_MANY ROWS 26. NVL function based qn 27. Correct Ordering of the clause Where, having, group by,distinct,union,order by Ansdistinct, Where ,group by, having, order by, union 28. Question based on USING clause. Ans: for Non equi join we cant use USING.

29. Which is an iSQL * command? A. Select. B. Insert. C. Delete. D. Update. E. Describe. AnsE 30. Difference bet SQL commands and SQL* PLUS commands Options A.SQL commands can be abbreviated and SQL *plus cannot be abbreviated B.SQL commands can do data manipulation but SQL*plus cannot do data manipulation in Database C/D not sure Ans : B 31. Qn based on SELECTION, PROJECTION, JOIN Select --- to select rows Projection --- to select columns Join ---- to link the tables Two qns based on this 32. Variable defined in the inner block of the PL/SQL is only visible in the inner block. It is not visible in the outer block. One qn based on this.. 33. Default LINESIZE 80,120,100,60 etc. Ans : 80(NOT SURE.) 34. Choose the invalid one Declare ----Begin

A. Select name into vname from table where some condition. B. Select name,age into vname,vage from table where some condition. C. Select name,age into vname from table where some condition. Ans ---- C 35. Qns based on WITH CHECK OPTION and WITH READ ONLY option in Views. 36. SYSDATE TO BE DISPLAYED IN SOME SPECIFIC FORMAT Options given like DD MONTH YYYY Day MM YYYY HH:Mi:AM

37. insert into tablename( few columns mentioned here) values (corresponding values mentioned here) But the Fault in the query is that a NOTNULL Column was missed while inserting values in the table. 38. Which aggregate function is valid on the START_DATE column? (START_DATE datatype DATE) A. SUM(start_date) B. AVG(start_date) C. COUNT(start_date) D. AVG(start_date, end_date) E. MAXIMUM(start_date) Ans--- C

38. PL/SQL Block Begin Delete statement Commit End Rollback

Options: A. use Describe to view the structure of table (Ans) 39. Which of the following options is not a constraint? A. B. C. D. Check Primary Key Not Null Constant

Ans D 40. Qn based on SelectFOR UPDATE clause 41. Which of the following correctly shows the correct use of the TRUNC command on a date? A. SELECT TRUNC(TO_DATE(12-Feb-99,DD-MON-YY, 'YEAR')) "Date " FROM DUAL; B. TRUNC = TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR', "Date " FROM DUAL; C. SELECT TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') "Date " FROM DUAL; D. date = TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') "Date " FROM DUAL Answer: C 42. Qn based on WITH ADMIN OPTION 43. Which of the following has been achieved by the following SQL codes? SELECT employee_id FROM employees WHERE commission_pct = .5 OR salary > 23000; A. it returns employees who have a 50% of a salary greater than $23,000: B. it returns employees who have a 50% commission rate or a salary greater than $23,000: C. runtime error D. it returns employees who have a 50% of a salary less than $23,000: E. invalid syntax F. it returns employees who have a 50% commission rate and a salary greater than $23,000: Answer: B 44. select -------(-45) from dual -------------should return -45

Which function should be used to return the same value Options--- A. Round() B. Abs() C. ceil() D. Floor() Ans --- A/C/D 45. View the image below to examine the structures of the EMPLOYEES and TAX tables. You need to find the percentage tax applicable for each employee. Which SQL statement would you use? A. SELECT employee_id, salary, tax_percent FROM employees e, tax t WHERE e.salary BETWEEN t.min_salary AND t.max_salary; B. SELECT employee_id, salary, tax_percent FROM employees e, tax t WHERE e.salary > t.min_salary AND < t.max_salary; C. SELECT employee_id, salary, tax_percent FROM employees e, tax t WHERE MIN(e.salary) = t.min_salary AND MAX(e.salary) = t.max_salary; D. You cannot find the information because there is no common column between the two tables. Answer: A 46 .Examine the description of the EMPLOYEES table: EMP_ID NUMBER(4) NOT NULL LAST_NAME VARCHAR2(30) NOT NULL FIRST_NAME VARCHAR2(30) DEPT_ID NUMBER(2) Which statement produces the number of different departments that have employees with last name Smith? A. SELECT COUNT(*) FROM employees WHERE last_name='Smith'; B. SELECT COUNT (dept_id) FROM employees WHERE last_name='Smith'; C. SELECT DISTINCT(COUNT(dept_id)) FROM employees WHERE last_name='Smith'; D. SELECT COUNT(DISTINCT dept_id) FROM employees WHERE last_name='Smith'; E. SELECT UNIQUE(dept_id) FROM employees WHERE last_name='Smith'; Answer: D 47. Examine the subquery: SELECT last_name

FROM employees WHERE salary IN (SELECT MAX(salary) FROM employees GROUP BY department_id); Which statement is true? A. The SELECT statement is syntactically accurate. B. The SELECT statement does not work because there is no HAVING clause. C. The SELECT statement does not work because the column specified in the GROUP BY clause is not in the SELECT list. D. The SELECT statement does not work because the GROUP BY clause should be in the main query and not in the subquery. Answer: A 48.Qn based on Grant and revoke privileges 49. Which of these are optional in a PL/SQL block A. declare B. Executable C. Exception Handling Ans : Declare/ Exception handling part 50. One qn based on Raise Exception. 51. which of the following is true w.r.to Explicit cursors. Ans: Explicit cursors can be applied for all DML and select Statements.
52. which constraint does the Oracle Server implicitly create a unique index? A. NOT NULL B. PRIMARY KEY C. FOREIGN KEY D. CHECK Answer: B

53 .Which statement adds a constraint that ensures the CUSTOMER_NAME column of the CUSTOMERS table holds a value? A. ALTER TABLE customers ADD CONSTRAINT cust_name_nn CHECK customer_name IS NOT NULL; B. ALTER TABLE customers MODIFY CONSTRAINT cust_name_nn CHECK customer_name IS NOT NULL;

C. ALTER TABLE customers MODIFY customer_name CONSTRAINT cust_name_nn NOT NULL; D. ALTER TABLE customers MODIFY customer_name CONSTRAINT cust_name_nn IS NOT NULL; E. ALTER TABLE customers MODIFY name CONSTRAINT cust_name_nn NOT NULL; F. ALTER TABLE customers ADD CONSTRAINT cust_name_nn CHECK customer_name NOT NULL; Answer: C 54 .The STUDENT_GRADES table has these columns: STUDENT_ID NUMBER(12) SEMESTER_END DATE GPA NUMBER(4,3) Which statement finds the highest grade point average (GPA) per semester? A. SELECT MAX(gpa) FROM student_grades WHERE gpa IS NOT NULL; B. SELECT (gpa) FROM student_grades GROUP BY semester_end WHERE gpa IS NOT NULL; C. SELECT MAX(gpa) FROM student_grades WHERE gpa IS NOT NULL GROUP BY semester_end; D. SELECT MAX(gpa) GROUP BY semester_end WHERE gpa IS NOT NULL FROM student_grades; E. SELECT MAX(gpa) FROM student_grades GROUP BY semester_end WHERE gpa IS NOT NULL; Answer: C 55 .You need to write a SQL statement that returns employee name, salary, department ID, and maximum salary earned in the department of the employee for all employees who earn less than the maximum salary in their department. Which statement accomplishes this task? A. SELECT a.emp_name, a.sal, b.dept_id, MAX(sal) FROM employees a, departments b WHERE a.dept_id = b.dept_id AND a.sal < MAX(sal) GROUP BY b.dept_id; B. SELECT a.emp_name, a.sal, a.dept_id, b.maxsal FROM employees a, (SELECT dept_id, MAX(sal) maxsal FROM employees GROUP BY dept_id) b WHERE a.dept_id = b.dept_id AND a.sal < b.maxsal; C. SELECT a.emp_name, a.sal, a.dept_id, b.maxsal FROM employees a WHERE a.sal < (SELECT MAX(sal) maxsal FROM employees b GROUP BY dept_id); D. SELECT emp_name, sal, dept_id, maxsal FROM employees, (SELECT dept_id, MAX(sal) maxsal FROM employees GROUP BY dept_id) WHERE a.sal < maxsal;

Answer: A 56 Mark for review Evaluate the SQL statement: SELECT ROUND(45.953, -1), TRUNC(45.936, 2) FROM dual; Which values are displayed? A. 46 and 45 B. 46 and 45.93 C. 50 and 45.93 D. 50 and 45.9 E. 45 and 45.93 F. 45.95 and 45.93 Answer: C 57 . Mark for review Which SQL statement generates the alias Annual Salary for the calculated column SALARY*12? A. SELECT ename, salary*12 'Annual Salary' FROM employees; B. SELECT ename, salary*12 "Annual Salary" FROM employees; C. SELECT ename, salary*12 AS Annual Salary FROM employees; D. SELECT ename, salary*12 AS INITCAP("ANNUAL SALARY") FROM employees Answer: B 58.Evaluate the SQL statement DROP TABLE DEPT: Which four statements are true of the SQL statement? (Choose four) A. You cannot roll back this statement. B. All pending transactions are committed. C. All views based on the DEPT table are deleted. D. All indexes based on the DEPT table are dropped. E. All data in the table is deleted, and the table structure is also deleted. F. All data in the table is deleted, but the structure of the table is retained. G. All synonyms based on the DEPT table are deleted. Answer: A, B, D, E 59 . Mark for review You need to create a view EMP_VU. The view should allow the users to manipulate the records of only the employees that are working for departments 10 or 20. Which SQL statement would you use to create the view EMP_VU?

A. CREATE VIEW emp_vu AS SELECT * FROM employees WHERE department_id IN (10,20); B. CREATE VIEW emp_vu AS SELECT * FROM employees WHERE department_id IN (10,20) WITH READ ONLY; C. CREATE VIEW emp_vu AS SELECT * FROM employees WHERE department_id IN (10,20) WITH CHECK OPTION; D. CREATE FORCE VIEW emp_vu AS SELECT * FROM employees WHERE department_id IN (10,20); E. CREATE FORCE VIEW emp_vu AS SELECT * FROM employees WHERE department_id IN (10,20) NO UPDATE; 60. Evaluate the set of SQL statements: CREATE TABLE dept (deptbi NUMBER (2) dname VARCHAR2(14), Ioc VARCHAR2(13)); ROLLBACK; DESCRIBE DEPT What is true about the set? A. The DESCRIBE DEPT statement displays the structure of the DEPT table B. The ROLLBACK statement frees the storage space occupied by the DEPT table. C. The DESCRIBE DEPT statement returns an error ORA-04043: object DEPT does not exist D. The DESCRIBE DEPT statement displays the structure of the DEPT table only if there is a COMMIT statement introduced before the ROLLBACK statement. Answer: A Explanation: The structure of the DEPT table will be displayed because the CREATE TABLE statement is DDL operation and it cannot be rolled back because implicit commit occurs on the database when a user exits SQL*Plus or issues a data-definition language (DDL) command such as a create table statement, user to create a database object, or an alter table statement, used to alter a database object. Incorrect Answers B: The ROLLBACK statement has nothing to do with the storage space of the DEPT table. C: The DESCRIBE DEPT statement does not produce the error. It displays the structure of the DEPT table. D: The COMMIT statement does not need to be introduced because implicit commit occurs on the database after creation of the table.

OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 281-283 Chapter 6: Manipulating Oracle Data 61. Which clause would you use in a SELECT statement to limit the display to those employees whose salary is greater than 5000? A. ORDER BY SALARY > 5000 B. GROUP BY SALARY > 5000 C. HAVING SALARY > 5000 D. WHERE SALARY > 5000

Answer: D 62. You define a multiple-row subquery in the WHERE clause of an SQL query with a comparison operator"=" What happens when the main query is executed? A. the main query executes with the first value returned by the subquery B. the main query executes with the last value returned by the subquery C. the main query executes with all the values returned by the subquery D. the main query fails because the multiple-row subquery cannot be used with the comparison operator. E. You cannot define multiple-row subquery in the WHERE clause of a SQL query Ans :D 63. which three statements correctly describe the functions and use of constraints? (Choose three) A. constraints provide data independence B. constraint make complex queries easy C. constraints enforce rules at the view level D. constraints enforce rules at the table level E. constraints prevent the deletion of a table if there are dependencies F. constraints prevent the deletion of an index if there are dependencies Answer: CDE 64.You have Employee table given below: Id 110 111 Etc Name ---King dept 10 10 Salary 4500

NVL(salary,NONE) what it will return for King? And: Error Because datatype mismatch. 65. (1Z0-007q8) Which of the following has been achieved by the following SQL codes? SELECT * FROM employees WHERE hire_date < TO_DATE ('01-JAN-1999', 'DD-MON-YYYY') AND salary > 3500; A. only those hired before 1999 and earning less than $3500 a month are returned B. compile time error C. only those hired after 1999 and earning more than $3500 a month are returned D. runtime error E. only those hired before 1999 and earning more than $3500 a month are returned Answer: E

You might also like