Oracle Final Test

40 Questions | Total Attempts: 230

SettingsSettingsSettings
Please wait...
Oracle Quizzes & Trivia

Questions and Answers
  • 1. 
    You attempt to query the data base with this command: SELECT name,salary FROM employee WHERE salary= (SELECT salary FROM employee WHERE last_name= ‘Wagner’ OR dept_no=233) Why could this statement cause an error?
    • A. 

      A. Sub queries are not allowed in the where clause.

    • B. 

      B. Logical apparatus are not allowed in where clause.

    • C. 

      C. A multiple row sub query used with a single row comparison operator.

    • D. 

      D. A single row query is used with a multiple row comparison operator.

  • 2. 
    Under which situation it is necessary to use an explicit cursor?
    • A. 

      A. When any DML or select statement is used in a PL/SQL block?

    • B. 

      B. When a delete statement in a PL/SQL block deletes more than one row.

    • C. 

      C. When a select statement in a PL/SQL block is more than one row.

    • D. 

      D. When an update statement in a PL/SQL block has to modify more than one row.

  • 3. 
    Which order does the Oracle Server evaluate clauses?
    • A. 

      A. HAVING, WHERE, GROUP BY

    • B. 

      B. WHERE, GROUP BY, HAVING

    • C. 

      C. GROUP BY, HAVING, WHERE

    • D. 

      D. WHERE, HAVING, GROUP BY

  • 4. 
    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. 

      A. only those hired before 1999 and earning less than $3500 a month are returned

    • B. 

      B. compile time error

    • C. 

      C. only those hired after 1999 and earning more than $3500 a month are returned

    • D. 

      D. runtime error

    • E. 

      E. only those hired before 1999 and earning more than $3500 a month are returned

  • 5. 
    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. 

      A. The SELECT statement is syntactically accurate.

    • B. 

      B. The SELECT statement does not work because there is no HAVING clause.

    • C. 

      C. The SELECT statement does not work because the column specified in the GROUP BY clause is not in the SELECT list.

    • D. 

      D. The SELECT statement does not work because the GROUP BY clause should be in the main query and not in the subquery.

  • 6. 
    Which aggregate function is valid on the START_DATE column? (START_DATE datatype DATE)
    • A. 

      A. SUM(start_date)

    • B. 

      B. AVG(start_date)

    • C. 

      C. COUNT(start_date)

    • D. 

      D. AVG(start_date, end_date)

  • 7. 
    Examine the structure of the STUDENT table: NAME NULL? TYPE STUDENT_ID NOT NULL NUMBER(3) NAME NOT NULL VARCHAR2(25) ADDRESS VARCHAR2(50) GRADUATION DATE Graduation column is a foreign key column to the graduate table. Examine the data in the GRADE DATE table: Graduation 20-jan-1999 12-may-1999 19-jan-2000 25-may-2000 13-jan-2001 29-may-2001 Which update statement produces the following error: ORA-02291 integrity constraint(sys_c23) violated parent key not found?
    • A. 

      A. UPDATE student SET stud-id=999, graduation= ’29-MAY-2001’ WHERE stud-id=101;’

    • B. 

      B. UPDATE student SET name= ‘Smith’, graduation= ’29-MAY-2001’ WHERE stud-id=101;

    • C. 

      C. UPDATE student SET name= ‘Smith’, graduation= ‘15-AUG-2000’ WHERE stud-id=101

    • D. 

      D. UPDATE student SET stud-id=NULL, address= ‘100 Main Street’ WHERE graduation= ‘20-JAN-1999’

  • 8. 
    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. A cursor for loop.

    • B. 

      B. A multiple selection cursor.

    • C. 

      C. A cursor for each active set.

    • D. 

      D. A cursor that uses parameters.

  • 9. 
    You created a view called EMP_DEPT_VU that contains three columns from the EMPLOYEES  and DEPARTMENTS  tables EMPLOYEE_ID, EMPLOYEE_NAME  AND DEPARTMENT_NAME The DEPARTMENT_ID column of the EMPLOYEES table is the foreign key to the primary key DEPARTMENT_ID column of the DEPARTMENTS table. You want to modify the view by adding a fourth column, MANAGER_Id of NUMBER data type from the EMPLOYEES table.  How can you accomplish this task?
    • A. 

      A. ALTER VIEW emp_dept_vu (ADD manager_id NUMBER),

    • B. 

      B. MODIFY VIEW emp_dept_vu (ADD manager_id NUMBER);

    • C. 

      C. ALTER VIEW emp_dept_vu AS SELECT employee_id, employee_name Department_name, manager_id FROM employees e, departments d WHERE department_id = d.department_id;

    • D. 

      D. MODIFY VIEW emp_depat_vu AS SELECT employee_id, employee_name, Department_name, manager_id FROM employees e, departments d WHERE e.department_id = d.department_id;

    • E. 

      E. CREATE OR REPLACE VIEW emp_dept_vu AS SELECT emplouee_id, employee_ name, Department_name, manager _id FROM employees e, departments d WHERE e.department_id=d.department_id;

    • F. 

      F. You must remove the existing view first, and then run the CRATE VIEW command with a new column list to modify a view.

  • 10. 
     Which statement describes the ROWID data type?
    • A. 

      A. binary data up to 4 gigabytes

    • B. 

      B. character data up to 4 gigabytes

    • C. 

      C. raw binary data of variable length up to 2 gigabytes

    • D. 

      D. binary data stored in an external file, up to 4 gigabytes

    • E. 

      E. a hexadecimal string representing the unique address of a row in its table

  • 11. 
    The DBA issues this SQL command: CREATE USER scott  INDENTIFIED by tiger; What privileges does the user Scott have at this point?
    • A. 

      A. no privileges

    • B. 

      B. only the SELECT privilege

    • C. 

      C. only the CONNECT privilege

    • D. 

      D. all the privileges of a default user

  • 12. 
    Which substitution variable would you use if you want to reuse the variable value without prompting the user each time?
    • A. 

      A. &

    • B. 

      B. ACCEPT

    • C. 

      C. PROMPT

    • D. 

      D. &&

  • 13. 
     Which three are true regarding the use of outer joins? (Choose three.)
    • A. 

      A. You cannot use IN operator in a condition that involves an outerjoin

    • B. 

      B. You use (+) on both sides of the WHERE condition to perform an outerjoin

    • C. 

      C. You use (*) on both sides of the WHERE condition to perform an outerjoin.

    • D. 

      D. You use an outerjoin to see only the rows that do not meet the join condition

    • E. 

      E. In the WHERE condition, you use (+) following the name of the column in the table without matching rows, to perform an outerjoin

    • F. 

      F. You cannot link a condition that is involved in an outerjoin to another condition by using the OR operator

  • 14. 
     Which statement creates a new user?
    • A. 

      A. CREATE USER susan

    • B. 

      B. CREATE OR REPLACE USER susan

    • C. 

      C. CREATE NEW USER susan DEFAULT,

    • D. 

      D. CREATE USER susan INDENTIFIED BY blue

    • E. 

      E. CREATE NEW USER susan IDENTIFIED BY blue

    • F. 

      F. CREATE OR REPLACE USER susan IDENTIFIED BY blue;

  • 15. 
    The EMPLOYEES table contains these columns:EMPLOYEE_ID NUMBER(4)LAST_NAME VARCHAR2 (25)JOB_ID VARCHAR2(10) You want to search for strings that contain 'SA_' in the JOB_ID column. Which SQLstatement do you use?
    • A. 

      A. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE'%SA\_%' ESCAPE '\';

    • B. 

      B. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE'%SA_';

    • C. 

      C. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_'ESCAPE "\";

    • D. 

      D. SELECT employee_id, last_name, job_id FROM employees WHERE job_id = '%SA_'

  • 16. 
    EMPLOYEES and DEPARTMENTS data: EMPLOYEES EMPLOYEE_ID EMP_NAME DEPT_ID MGR_ID JOB_ID SALARY 101 Smith 20 120 SA_REP 4000 102 Martin 10 105 CLERK 2500 103 Chris 20 120 IT_ADMIN 4200 104 John 30 108 HR_CLERK 2500 105 Diana 30 108 IT_ADMIN 5000 106 Smith 40 110 AD_ASST 3000 108 Jennifer 30 110 HR_DIR 6500 110 Bob 40 EX_DIR 8000 120 Ravi 20 110 SA_DIR 6500 DEPARTMENTS DEPARTMENT_ID DEPARTMENT_NAME 10 Admin 20 Education 30 IT On the EMPLOYEES table, EMPLOYEE_ID is the primary key. MGR_ID is the ID managers and refers to the EMPLOYEE_ID. On the DEPARTMENTS table DEPARTMENT_ID is the primary key. Evaluate this UPDATE statement. UPDATE employees SET mgr_id = (SELECT mgr_id FROM employees WHERE dept_id= (SELECT department_id FROM departments WHERE department_name = 'Administration')), Salary = (SELECT salary FROM employees WHERE emp_name = 'Smith') WHERE job_id = 'IT_ADMIN'; What happens when the statement is executed?
    • A. 

      A. The statement executes successfully, leaves the manager ID as the existing value, and changes the salary to 4000 for the employees with ID 103 and 105.

    • B. 

      B. The statement executes successfully, changes the manager ID to NULL, and changes the salary to 4000 for the employees with ID 103 and 105.

    • C. 

      C. The statement executes successfully, changes the manager ID to NULL, and changes the salary to 3000 for the employees with ID 103 and 105.

    • D. 

      D. The statement fails because there is more than one row matching the employee name Smith.

    • E. 

      E. The statement fails because there is more than one row matching the IT_ADMIN job ID in the EMPLOYEES table.

    • F. 

      F. The statement fails because there is no 'Administration' department in the DEPARTMENTS table.

  • 17. 
    What is true about the WITH GRANT OPTION clause?
    • A. 

      A. It allows a grantee DBA privileges.

    • B. 

      B. It is required syntax for object privileges.

    • C. 

      C. It allows privileges on specified columns of tables.

    • D. 

      D. It is used to grant an object privilege on a foreign key column.

    • E. 

      E. It allows the grantee to grant object privileges to other users and roles.

  • 18. 
    Which constraint can be defines only at the column level?
    • A. 

      A. UNIQUE

    • B. 

      B. NOT NULL

    • C. 

      C. CHECK

    • D. 

      D. PRIMARY KEY

    • E. 

      E. FOREIGN KEY

  • 19. 
    Which SELECT statement should you use to extract the year from the system date and display it in the format "1998"?
    • A. 

      A. SELECT TO_CHAR(SYSDATE,'yyyy') FROM dual;

    • B. 

      B. SELECT TO_DATE(SYSDATE,'yyyy') FROM dual;

    • C. 

      C. SELECT DECODE(SUBSTR(SYSDATE, 8), 'YYYY') FROM dual;

    • D. 

      D. SELECT DECODE(SUBSTR(SYSDATE, 8), 'year') FROM dual;

    • E. 

      E. SELECT TO_CHAR(SUBSTR(SYSDATE, 8,2),'yyyy') FROM dual;

  • 20. 
    Scott issues the SQL statements: CREATE TABLE dept (deptno NUMBER(2), dname VARCHAR2(14), loc VARCHAR2(13)}; GRANT SELECT ON DEPT TO SUE; If Sue needs to select from Scott's DEPT table, which command should she use?
    • A. 

      A. SELECT * FROM DEPT;

    • B. 

      B. SELECT * FROM SCOTT.DEPT;

    • C. 

      C. SELECT * FROM DBA.SCOTT.DEPT;

    • D. 

      D. SELECT * FROM ALL_USERS WHERE USER_NAME = 'SCOTT' AND TABLE NAME = 'DEPT';

  • 21. 
    .What is true about joining tables through an equijoin?
    • A. 

      A. You can join a maximum of two tables through an equijoin.

    • B. 

      B. You can join a maximum of two columns through an equijoin.

    • C. 

      C. You specify an equijoin condition in the SELECT or FROM clauses of a SELECT statement.

    • D. 

      D. To join two tables through an equijoin, the columns in the join condition must be primary key and foreign key columns.

    • E. 

      E. You can join n tables (all having single column primary keys) in a SQL statement by specifying a minimum of n-1 join conditions.

  • 22. 
    Mark for review The PRODUCTS table has these columns: PRODUCT_ID NUMBER(4) PRODUCT_NAME VARCHAR2(45) PRICE NUMBER(8,2) Evaluate this SQL statement: SELECT * FROM PRODUCTS ORDER BY price, product_name; What is true about the SQL statement?
    • A. 

      A. The results are not sorted.

    • B. 

      B. The results are sorted numerically

    • C. 

      C. The results are sorted alphabetically

    • D. 

      . D. The results are sorted numerically and then alphabetically.

  • 23. 
    What is true about updates through a view?
    • A. 

      A. You cannot update a view with group functions.

    • B. 

      B. When you update a view group functions are automatically computed.

    • C. 

      C. When you update a view only the constraints on the underlying table will be in effect

    • D. 

      D. When you update a view the constraints on the views always override the constraints on the underlying tables

  • 24. 
    Which of the following correctly shows the correct use of the TRUNC command on a date?
    • A. 

      A. SELECT TRUNC(TO_DATE(12-Feb-99,DD-MON-YY, 'YEAR')) "Date " FROM DUAL;

    • B. 

      B. TRUNC = TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR', "Date " FROM DUAL;

    • C. 

      C. SELECT TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') "Date " FROM DUAL;

    • D. 

      D. date = TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') "Date " FROM DUAL

  • 25. 
    Examine the data in the EMPLOYEES and DEPARTMENTS tables. You want to retrieve all employees' last names, along with their manager's last names and their department names. Which query would you use?
    • A. 

      A. SELECT last_name, manager_id, department_name FROM employees e FULL OUTER JOIN departments d ON (e.department_id = d.department_id);

    • B. 

      B. SELECT e.last_name, m.last_name, department_name FROM employees e LEFT OUTER JOIN employees m on ( e.managaer_id = m.employee_id) LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);

    • C. 

      C. SELECT e.last_name, m.last_name, department_name FROM employees e RIGT OUTER JOIN employees m on ( e.manager_id = m.employee_id) LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);

    • D. 

      D. SELECT e.last_name, m.last_name, department_name FROM employees e LEFT OUTER JOIN employees m on ( e.manager_id = m.employee_id) RIGT OUTER JOIN departments d ON (e.department_id = d.department_id);

    • E. 

      E. SELECT e.last_name, m.last_name, department_name FROM employees e RIGHT OUTER JOIN employees m on ( e.manager_id = m.employee_id) RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id)

    • F. 

      F. SELECT last_name, manager_id, department_name FROM employees e JOIN departments d ON (e.department_id = d.department_id) ;