Wednesday, August 10, 2011

SQL IQA 1


1. Which of the following queries can you use to search for employees with the pattern 'A_B' in their names?
A.     SELECT last_name FROM employees WHERE last_name LIKE '%A\_B%' ESCAPE '\\'; 
B.     SELECT last_name FROM employees WHERE last_name LIKE '%A_B%' ESCAPE;
C.    SELECT last_name FROM employees WHERE last_name LIKE 'A_B%' ESCAPE '%';
D.    SELECT last_name FROM employees WHERE last_name LIKE '%A\_B%' ESCAPE '\';

2. Refer to the SQL codes below:
SELECT manager_id, last_name, hire_date, salary, AVG (salary) OVER (PARTITION BY manager_id ORDER BY hire_date ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS C_mavg FROM employees;
What has been achieved?
A.     Because of a syntax problem, no row will be returned
B.     It calculates, for each employee in the employees table, the average salary of the employees reporting to his/her respective manager
C.    It calculates, for each employee in the employees table, the average salary of the employees reporting to his/her respective manager who were hired just before the employee 
D.    It calculates, for each employee in the employees table, the average salary of the employees reporting to the same manager who were hired in the range just before through just after the employee 
E.     It calculates, for each employee in the employees table, the average salary of the employees reporting to his/her respective manager who were hired just after the employee 

3. With 9i SQL Plus, What kinds of commands can you enters at the command prompt (Choose all that apply)?
A.     PL/SQL blocks
B.     SQL*Plus commands
C.    Security commands
D.    SQL commands 

4. To write a query that performs an outer join of tables A and B and returns all rows from B, You need to write
A.     any outer join
B.     a left outer join
C.    a cross join
D.    a right outer join
E.     an inner join 

5. Which of the following is true if you use the alter tablespace statement and specify the TEMPORARY clause (Choose all that apply)?
A.     Oracle no longer perform any checkpoint for the online datafiles in the tablespace
B.     Oracle performs a checkpoint for all online datafiles in the tablespace
C.    Oracle does not ensure that all files are written
D.    The offline files may require media recovery before you bring the tablespace  online
E.     The offline files may require media recovery after you bring the tablespace online 

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

7. To grant a system privilege with the GRANT statement, you must (Choose all that apply)?
A.     have been granted the GRANT ROLE PRIVILEGE system privilege
B.     have been granted the system privilege with the ADMIN OPTION
C.    have been granted the GRANT ANY PRIVILEGE system privilege
D.    have been granted the system privilege with the GRANT OPTION 

8. Which of the following are the conditions that must be met before you can use RENAME DATAFILE with the alter tablespace command (Choose all that apply)?
A.     the datafile must be taken offline before renaming
B.     the database must be open
C.    when only a single datafile is to be renamed
D.    when only a single datafile on the same drive is to be renamed 

9. Before making a tablespace read only, which of the following conditions must be met (Choose all that apply)?
A.     The tablespace must contain an active rollback segments.
B.     The tablespace must be online.
C.    The tablespace must not contain any active rollback segments.
D.    The tablespace must not be involved in an open backup.
E.     The tablespace must be involved in an open backup. 

10. The MANAGE TABLESPACE system privilege allows you to perform which of the following operations (Choose all that apply)?
A.     Take the tablespace offline
B.     Begin a backup
C.    End a backup
D.    Take the tablespace online
E.     Make the tablespace read only
F.     Make the tablespace read write 

11. 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:

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

13. Which of the following SQL statements can calculate and return the absolute value of -33?
A.     SELECT ABS("-33") Absolute FROM DUAL;
B.     SELECT ABS('-33') "Absolute" FROM DUAL;
C.    SELECT ABS(-33) "Absolute" FROM DUAL;
D.    SELECT ABS(-33), Absolute FROM DUAL; 

14. Which two statements about Subqueries are true? (Choose two.)
A.     A single row subquery can retrieve data from only one table.
B.     A SQL query statement cannot display data from table B that is referred to in its subquery, unless table B is included in the main query's FROM clause.
C.    A SQL query statement can display data from table B that is referred to in its subquery, without including table B in its own FROM clause.
D.    A single row subquery can retrieve data from more than one table.
E.     A single row subquery cannot be used in a condition where the LIKE operator is used for comparison.
F.     A multiple-row subquery cannot be used in a condition where the LIKE operator is used for comparison.

15. Examine the description of the STUDENTS table: 
STD_ID   NUMBER (4)
COURSE_ID   VARCHAR2 (10)
START_DATE   DATE
END_DATE   DATE
Which two aggregate functions are valid on the START_DATE column? (Choose two)
A.     SUM(start_date)
B.     AVG(start_date)
C.    COUNT(start_date)
D.    AVG(start_date, end_date)
E.     MIN(start_date)
F.     MAXIMUM(start_date) 

16. Examine the structure of the EMP_DEPT_VU view:             Column Name   Type Remarks
EMPLOYEE_ID  NUMBER
From the EMPLOYEES table:                                                           EMP_NAME   VARCHAR2 (30)
JOB_ID   VARCHAR2 (20)                                                
SALARY   NUMBER
DEPARTMENT_ID  NUMBER          
From the DEPARTMENTS table:                                                      DEPT_NAME VARCHAR2 (30) 
Which SQL statement produces an error?
A.     SELECT * FROM emp_dept_vu;
B.     SELECT department_id, SUM(salary) FROM emp_dept_vu GROUP BY department_id;
C.    SELECT department_id, job_id, AVG(salary) FROM emp_dept_vu GROUP BY department_id, job_id;
D.    SELECT job_id, SUM(salary) FROM emp_dept_vu WHERE department_id IN (10,20) GROUP BY job_id HAVING SUM(salary) > 20000;
E.     None of the statements produce an error; all are valid.

17. 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)
JOB_CAT    VARCHAR (30)
SALARY    NUMBER (8, 2) 
Which statement shows the department ID, minimum salary, and maximum salary paid in that department, only if the minimum salary is less than 5000 and maximum salary is more than 15000?
A.     SELECT dept_id, MIN (salary), MAX (salary) FROM employees WHERE MIN(salary) < 5000 AND MAX (salary) > 15000; 
B.     SELECT dept_id, MIN (salary), MAX (salary) FROM employees WHERE MIN (salary) < 5000 AND MAX (salary) 15000 GROUP BY dept_id; 
C.    SELECT dept_id, MIN(salary), MAX(salary) FROM employees HAVING MIN (salary) < 5000 AND MAX (salary) 
D.    SELECT dept_id, MIN (salary), MAX (salary) FROM employees GROUP BY dept_id HAVING MIN(salary) < 5000 AND MAX (salary) > 15000 
E.     SELECT dept_id, MIN (salary), MAX (salary) FROM employees GROUP BY dept_id, salary HAVING MIN (salary) < 5000 AND MAX (salary) > 15000; 

18. You own a table called EMPLOYEES with this table structure:
EMPLOYEE_ID  NUMBER   Primary Key
FIRST_NAME   VARCHAR2 (25)
LAST_NAME   VARCHAR2 (25)
HIRE_DATE   DATE
What happens when you execute this DELETE statement?
DELETE employees;
A.     You get an error because of a primary key violation.
B.     The data and structure of the EMPLOYEES table are deleted.
C.    The data in the EMPLOYEES table is deleted but not the structure.
D.    You get an error because the statement is not syntactically correct. 

19. Evaluate this SQL statement:
SELECT e.employee_id, (.15* e.salary) + (.5 * e.commission_pct) + (s.sales_amount * (.35 *e.bonus)) AS CALC_VALUE
FROM employees e, sales WHERE e.employee_id = s.emp_id;
What will happen if you remove all the parentheses from the calculation?
A.     The value displayed in the CALC_VALUE column will be lower.
B.     The value displayed in the CALC_VALUE column will be higher.
C.    There will be no difference in the value displayed in the CALC_VALUE column.
D.    An error will be reported.

20. Examine the structure of the EMPLOYEES and NEW_EMPLOYEES tables:
EMPLOYEES:
EMPLOYEE_ID  NUMBER   Primary Key
FIRST_NAME   VARCHAR2 (25)
LAST_NAME   VARCHAR2 (25)
HIRE_DATE   DATE
NEW_EMPLOYEES:
EMPLOYEE_ID  NUMBER   Primary Key
NAME    VARCHAR2 (60) 
Which MERGE statement is valid?
A.     MERGE INTO new_employees c USING employees e ON (c.employee_id = e.employee_id) WHEN MATCHED THEN UPDATE SET c.name = e.first_name||','|| e.last_name WHEN NOT MATCHED THEN INSERT VALUES (e.employee_id,e.first_name ||', '||e.last_name); 
B.     MERGE new_employees c USING employees e ON (c.employee_id = e.employee_id) WHEN EXISTS THEN UPDATE SET c.name = e.first_name ||','||e.last_name WHEN NOT MATCHED THEN INSERT VALUES (e.employee_id,e.first_name ||', '||e.last_name); 
C.    MERGE INTO new_employees c USING employees e ON (c.employee_id = e.employee_id) WHEN EXISTS THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN NOT MATCHED THEN INSERT VALUES(e.employee_id, e.first_name ||', '||e.last_name); 
D.    MERGE new_employees c FROM employees e ON (c.employee_id = e.employee_id) WHEN MATCHED THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN NOT MATCHED THEN INSERT INTO new_employees VALUES (e.employee_id, e.first_name ||', '||e.! last_name); 

21 .The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(4)
ENAME VARCHAR2 (25) JOB_ID VARCHAR2(10) Which SQL statement will return the ENAME, length of the ENAME, and the numeric position of the letter "a" in the ENAME column, for those employees whose ENAME ends with a the letter "n"?
A.     SELECT ENAME, LENGTH(ENAME), INSTR(ENAME, 'a') FROM EMPLOYEES WHERE SUBSTR(ENAME, -1, 1) = 'n'; 
B.     SELECT ENAME, LENGTH(ENAME), INSTR(ENAME, ,-1,1) FROM EMPLOYEES WHERE SUBSTR(ENAME, -1, 1) = 'n'; 
C.    SELECT ENAME, LENGTH(ENAME), SUBSTR(ENAME, -1,1) FROM EMPLOYEES WHERE INSTR(ENAME, 1, 1) = 'n'; 
D.    SELECT ENAME, LENGTH(ENAME), SUBSTR(ENAME, -1,1) FROM EMPLOYEES WHERE INSTR(ENAME, -1, 1) = 'n'; 

22. You would like to display the system date in the format "Monday, 01 June, 2001". Which SELECT statement should you use?
A.     SELECT TO_DATE (SYSDATE, 'FMDAY, DD Month, YYYY') FROM dual;
B.     SELECT TO_CHAR (SYSDATE, 'FMDD, DY Month, YYYY') FROM dual;
C.    SELECT TO_CHAR (SYSDATE, 'FMDay, DD Month, YYYY') FROM dual;
D.    SELECT TO_CHAR (SYSDATE, 'FMDY, DDD Month, YYYY') FROM dual;
E.     SELECT TO_DATE (SYSDATE, 'FMDY, DDD Month, YYYY') FROM dual; 

23. What is true about joining tables through an Equijoin?
A.     You can join a maximum of two tables through an Equijoin.
B.     You can join a maximum of two columns through an Equijoin.
C.    You specify an Equijoin condition in the SELECT or FROM clauses of a SELECT statement.
D.    To join two tables through an Equijoin, the columns in the join condition must be primary key and foreign key columns.
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.

24. Which four are valid Oracle constraint types? (Choose four.)
A.     CASCADE
B.     UNIQUE
C.    NONUNIQUE
D.    CHECK
E.     PRIMARY KEY
F.     CONSTANT
G.    NOT NULL 

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

26. Which SQL statement would you use to remove a view called EMP_DEPT_VU from your schema?
A.     DROP emp_dept_vu;
B.     DELETE emp_dept_vu;
C.    REMOVE emp_dept_vu;
D.    DROP VIEW emp_dept_vu;
E.     DELETE VIEW emp_dept_vu;
F.     REMOVE VIEW emp_dept_vu; 

27. Click the Exhibit button to examine the structures of the EMPLOYEES, DEPARTMENTS and LOCATIONS tables.
EMPLOYEES
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
EMP NAME VARCHAR2 (30)
JOB_ID VARCHAR2 (20)
SALARY NUMBER
MGR_ID NUMBER References EMPLOYEE_ID column
DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID column of the
DEPARTMENTS table
DEPARTMENTS
DEPARTMENT_ID NUMBER NOT NULL, Primary Key
DEPARTMENT_NAME VARCHAR2 (30)
MGR_ID NUMBER References MGR_ID column of the EMPLOYEES table
LOCATION_ID NUMBER Foreign key to LOCATION_ID column of the LOCATIONS table
LOCATIONS
LOCATIONS_ID NUMBER NOT NULL, Primary Key
CITY VARCHAR2(30)
Which two SQL statements produce the; name, department name, and the city of all the employees who earn more than 10000? (Choose Two).
A.     SELECT emp_name, department_name, city FROM employees e JOIN departments d USING (department_id) JOIN locations l USING (location_id) WHERE salary > 10000; 
B.     SELECT emp_name, department_name, city FROM employees e, departments d, locations l JOIN ON (e. department_id = d. department id) AND (d.location_id = l.location_id) AND salary > 10000; 
C.    SELECT emp_name, department_name, city FROM employees e, departments d, locations 1 WHERE salary > 1000; 
D.    SELECT emp_name, department_name, city FROM employees e, departments d, locations l WHERE e.department_id = d.department_id AND d.location_id = l.location_id AND salary > 10000; 
E.     SELECT emp_name, department_name, city FROM employees e NATURAL JOIN departments, locations WHERE salary > 10000; 

28. Which is an iSQL*Plus command?
A.     INSERT
B.     UPDATE
C.    SELECT
D.    DESCRIBE
E.     DELETE
F.     RENAME

29. The EMPLOYEES table has these columns:
LAST_NAME  VARCHAR2 (35)
SALARY  NUMBER (8, 2)
HIRE_DATE  DATE 
Management wants to add a default value to the SALARY column. You plan to alter the table by using this SQL statement:
ALTER TABLE EMPLOYEES MODIFY (SALARY DEFAULT 5000);
Which is true about your ALTER statement?
A.     Column definitions cannot be altered to add DEFAULT values.
B.     A change to the DEFAULT value affects only subsequent insertions to the table.
C.    Column definitions cannot be altered to add DEFAULT values for columns with a NUMBER data type.
D.    All the rows that have a NULL value for the SALARY column will be updated with the value 5000.

30. 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'; 

31. Which SELECT statement should you use to extract the year from the system date and display it in the format "1998"?
A.     SELECT TO_CHAR(SYSDATE, 'yyyy') FROM dual;
B.     SELECT TO_DATE(SYSDATE, 'yyyy') FROM dual;
C.    SELECT DECODE(SUBSTR(SYSDATE, 8), 'YYYY') FROM dual;
D.    SELECT DECODE(SUBSTR(SYSDATE, 8), 'year') FROM dual;
E.     SELECT TO_CHAR(SUBSTR(SYSDATE, 8,2),'yyyy') FROM dual; 

32. Which are DML statements? (Choose all that apply.)
A.     COMMIT
B.     MERGE
C.    UPDATE
D.    DELETE
E.     CREATE
F.     DROP

33. The STUDENT_GRADES table has these columns:
STUDENT_ID   NUMBER (12)
SEMESTER_END  DATE
GPA    NUMBER (4, 3) 
Which statement finds students who have a grade point average (GPA) greater than 3.0 for the calendar year 2001?
A.     SELECT student_id, gpa FROM student_grades WHERE semester_end BETWEEN '01-JAN-2001' AND '31-DEC-2001' OR gpa > 3.0; 
B.     SELECT student_id, gpa FROM student_grades WHERE semester_end BETWEEN '01-JAN-2001' AND '31-DEC-2001' AND gpa > 3.0; 
C.    SELECT student_id, gpa FROM student_grades WHERE semester_end BETWEEN '01-JAN-2001' AND '31-DEC-2001' AND gpa > 3.0; 
D.    SELECT student_id, gpa FROM student_grades WHERE semester_end BETWEEN '01-JAN-2001' AND '31-DEC-2001' AND gpa >= 3.0; 
E.     SELECT student_id, gpa FROM student_grades WHERE semester_end > '01-JAN2001' OR semester_end < '31-DEC-2001' AND gpa >= 3.0;

34. Top N analysis requires _____ and _____. (Choose two.)
A.     the use of rowed
B.     a GROUP BY clause
C.    an ORDER BY clause
D.    only an inline view
E.     an inline view and an outer query 

35. Which three is true regarding the use of outer joins? (Choose three.)
A.     You cannot use IN operator in a condition that involves an outer join.
B.     You use (+) on both sides of the WHERE condition to perform an outer join.
C.    You use (*) on both sides of the WHERE condition to perform an outer join.
D.    You use an outer join to see only the rows that do not meet the join condition.
E.     In the WHERE condition, you use (+) following the name of the column in the table without matching rows, to perform an outer join.
F.     You cannot link a condition that is involved in an outer join to another condition by using the OR operator.

36. 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; 

37. Evaluate this SQL statement:
SELECT ename, sal, 12*sal+100 FROM EMP;
The SAL column stores the monthly salary of the employee. Which change must be made to the above syntax to calculate the annual compensation as "monthly salary plus a monthly bonus of $100, multiplied by 12"?
A.     No change is required to achieve the desired results.
B.     SELECT ename, sal, 12*(sal+100) FROM emp;
C.    SELECT ename, sal, (12*sal)+100 FROM emp;
D.    SELECT ename, sal+100,*12 FROM emp; 

38. You are the DBA for an academic database. You need to create a role that allows a group of users to modify existing rows in the STUDENT_GRADES table. Which set of statements accomplishes this?
A.     CREATE ROLE registrar; GRANT MODIFY ON student_grades TO registrar; GRANT registrar to user1, user2, user3 
B.     CREATE NEW ROLE registrar; GRANT ALL ON student_grades TO registrar; GRANT registrar to user1, user2, user3 
C.    CREATE ROLE registrar; GRANT UPDATE ON student_grades TO registrar; GRANT ROLE registrar to user1, user2, user3 
D.    CREATE ROLE registrar; GRANT UPDATE ON student_grades TO registrar; GRANT registrar to user1, user2, user3; 
E.     CREATE registrar; GRANT CHANGE ON student_grades TO registrar; GRANT registrar; 

39. You need to modify the STUDENTS table to add a primary key on the STUDENT_ID column. The table is currently empty.
Which statement accomplishes this task? 
A.     ALTER TABLE students ADD PRIMARY KEY student_id;
B.     ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student_id);
C.    ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY student_id;
D.    ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id);
E.     ALTER TABLE students MODIFY CONSTRAINT stud_id_pk PRIMARY KEY (student_id);

40. Which describes the default behavior when you create a table?
A.     The table is accessible to all users.
B.     Tables are created in the public schema.
C.    Tables are created in your schema.
D.    Tables are created in the DBA schema.
E.     You must specify the schema when the table is created. 

41. The STUDENT_GRADES table has these columns:
STUDENT_ID   NUMBER (12)
SEMESTER_END  DATE
GPA    NUMBER (4, 3) 
The registrar requested a report listing the students' grade point averages (GPA) sorted from highest grade point average to lowest. Which statement produces a report that displays the student ID and GPA in the sorted order requested by the registrar?
A.     SELECT student_id, gpa FROM student_grades ORDER BY gpa ASC;
B.     SELECT student_id, gpa FROM student_grades SORT ORDER BY gpa ASC;
C.    SELECT student_id, gpa FROM student_grades SORT ORDER BY gpa;
D.    SELECT student_id, gpa FROM student_grades ORDER BY gpa;
E.     SELECT student_id, gpa FROM student_grades SORT ORDER BY gpa DESC;
F.     SELECT student_id, gpa FROM student_grades ORDER BY gpa DESC; 

42. Which four are attributes of single row functions? (Choose four.)
A.     cannot be nested
B.     manipulate data items
C.    act on each row returned
D.    return one result per row
E.     accept only one argument and return only one value
F.     accept arguments which can be a column or an expression 

43. Which statement creates a new user?
A.     CREATE USER Susan;
B.     CREATE OR REPLACE USER Susan;
C.    CREATE NEW USER Susan DEFAULT;
D.    CREATE USER Susan IDENTIFIED BY blue;
E.     CREATE NEW USER Susan IDENTIFIED by blue;
F.     CREATE OR REPLACE USER Susan IDENTIFIED BY blue; 

44. Which two statements complete a transaction? (Choose two.)
A.     DELETE employees;
B.     DESCRIBE employees;
C.    ROLLBACK TO SAVEPOINT C;
D.    GRANT SELECT ON employees TO SCOTT;
E.     ALTER TABLE employees SET UNUSED COLUMN sal;
F.     SELECT MAX(sal) FROM employees WHERE department_id = 20; 


45. You need to create a table named ORDERS that contains four columns: - an ORDER_ID column of number data type - a CUSTOMER_ID column of number data type - an ORDER_STATUS column that contains a character data type - a DATE_ORDERED column to contain the date the order was placed. When a row is inserted into the table, if no value is provided for the status of the order, the value PENDING should be used instead. Which statement accomplishes this?
A.     CREATE TABLE orders (order_id NUMBER(10), customer_id NUMBER(8), order_status NUMBER(10) DEFAULT 'PENDING', date_ordered DATE ); 
B.     CREATE TABLE orders (order_id NUMBER(10), customer_id NUMBER(8), order_status VARCHAR2(10) = 'PENDING', date_ordered DATE ); 
C.    CREATE OR REPLACE TABLE orders (order_id NUMBER(10), customer_id NUMBER(8), order_status VARCHAR2(10) DEFAULT 'PENDING', date_ordered DATE );
D.    CREATE OR REPLACE TABLE orders (order_id NUMBER(10), customer_id NUMBER(8), order_status VARCHAR2(10) = 'PENDING', date_ordered DATE );   
E.     CREATE TABLE orders (order_id NUMBER(10), customer_id NUMBER(8),order_status VARCHAR2(10) DEFAULT 'PENDING', date_ordered DATE ); 
F.     CREATE TABLE orders (order_id NUMBER(10), customer_id NUMBER(8),order_status VARCHAR2(10) DEFAULT 'PENDING', date_ordered VARCHAR2 ); 

46. Examine the data from the EMP table:  
EMP_ID DEPT_ID COMMISSION
1              10           500
2              20           1000
3              10 
4              10           600
5              30           800
6              30           200
7              10
8              20           300
9
The COMMISSION column shows the monthly commission earned by the employee. Which three tasks would require Subqueries or joins in order to perform in a single step? (Choose three)
A.     Deleting the records of employees who do not earn commission.
B.     Increasing the commission of employee 3 by the average commission earned in department 20.
C.    Finding the number of employees who do NOT earn commission and are working for department 20.
D.    Inserting into the table a new employee 10 who works for department 20 and earns a commission that is equal to the commission earned by employee 3.
E.     Creating a table called COMMISSION that has the same structure and data as the columns EMP_ID and COMMISSIONS of the EMP table.
F.     Decreasing the commission by 150 for the employees who are working in department 30 & earning a commission of more than 800.

47. View the image below and examine the data from the EMP table. Evaluate this SQL statement:
SELECT * FROM EMP WHERE commission = (SELECT commission FROM EMP WHERE emp_id = 3); 
What is the result when the query is executed?
A.     ===
B.     ===
C.    The query returns no rows.
D.    The query fails because the outer query is retrieving more than one column.
E.     The query fails because both the inner and outer queries are retrieving data from the same table.

48. Examine the data in the EMPLOYEES and DEPARTMENTS tables. 
EMPLOYEES
LAST_NAME   DEPARTMENT_ID          SALARY
Getz     10    3000
Davis     20    1500
King     20    2200
Davis     30    5000
Kochhar       5000
DEPARTMENTS
DEPARTMENT_ID  DEPARTMENT_NAME
10    Sales
20    Marketing
30    Accounts
40    Administration 
You want to retrieve all employees, whether or not they have matching departments in the departments table. Which query would you use?
A.     SELECT last_name, department_name FROM employees , departments(+);
B.     SELECT last_name, department_name FROM employees JOIN departments (+);
C.    SELECT last_name, department_name FROM employees(+) e JOIN departments d
A.     ON (e.department_id = d.department_id);
D.    SELECT last_name, department_name FROM employees e RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
E.     SELECT last_name, department_name FROM employees(+) , departments ON (e.department_id = d.department_id);
F.     SELECT last_name, department_name FROM employees e LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);  

49. Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID  NUMBER   Primary Key
FIRST_NAME   VARCHAR2 (25)
LAST_NAME   VARCHAR2 (25) 
Which three statements insert a row into the table? (Choose three.)
A.     INSERT INTO employees VALUES ( NULL, 'John', 'Smith');
B.     INSERT INTO employees( first_name, last_name) VALUES( 'John', 'Smith');
C.    INSERT INTO employees VALUES ( '1000', 'John', NULL);
D.    INSERT INTO employees (first_name, last_name, employee_id) VALUES ( 1000, 'John', 'Smith');
E.     INSERT INTO employees (employee_id) VALUES (1000);
F.     INSERT INTO employees (employee_id, first_name, last_name) VALUES ( 1000, 'John', ‘ ');

50. Evaluate these two SQL statements:
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY salary DESC; 
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC; 
What is true about them?
A.     The two statements produce identical results.
B.     The second statement returns a syntax error.
C.    There is no need to specify DESC because the results are sorted in descending order by default.
D.    3The two statements can be made to produce identical results by adding a column alias for the salary column in the second SQL statement.

51. Examine the structure of the EMPLOYEES table: 
EMPLOYEE_ID   NUMBER   Primary Key
FIRST_NAME    VARCHAR2 (25)
LAST_NAME    VARCHAR2 (25)
HIRE_DATE    DATE 
Which UPDATE statement is valid?
A.     UPDATE employees SET first_name = 'John' SET last_name='Smith' WHERE employee_id = 180; 
B.     UPDATE employees SET first_name = 'John', SET last_name ='Smith' WHERE employee_id = 180; 
C.    UPDATE employees SET first_name = 'John' AND last_name ='Smith' WHERE employee_id = 180; 
D.    UPDATE employees SET first_name = 'John', last_name ='Smith' WHERE employee_id = 180; 

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


53. The user Sue issues this SQL statement:                GRANT SELECT ON sue.EMP TO Alice WITH GRANT OPTION;
The user Alice issues this SQL statement:                     GRANT SELECT ON sue.EMP TO Rena WITH GRANT OPTION;
The user Rena issues this SQL statement:                    GRANT SELECT ON sue.EMP TO timber;
The user Sue issues this SQL statement:                       REVOKE select on sue.EMP FROM Alice;
 For which users does the revoke command revoke SELECT privileges on the SUE.EMP table?
A.     Alice only
B.     Alice and Rena
C.    Alice, Rena, and Timber
D.    Sue, Alice, Rena, and Timber 

54. 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 SQL statement do you use?
A.     SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA\_%' ESCAPE '\';
B.     SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_'; 
C.    SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_' ESCAPE "\"; 
D.    SELECT employee_id, last_name, job_id FROM employees WHERE job_id = '%SA_'; 

55. Examine the structure of the EMPLOYEES table:
Column name   Data type   Remarks
EMPLOYEE_ID  NUMBER   NOT NULL,  Primary Key
LAST_NAME   VARCHAR2 (30) 
FIRST_NAME   VARCHAR2 (30)
JOB_ID   NUMBER
SAL    NUMBER
MGR_ID   NUMBER 
References EMPLOYEE_ID column DEPARTMENT_ID NUMBER
You need to create an index called NAME_IDX on the first name and last name fields of the EMPLOYEES table. Which SQL statement would you use to perform this task?
A.     CREATE INDEX NAME_IDX (first_name, last_name);
B.     CREATE INDEX NAME_IDX (first_name AND last_name);
C.    CREATE INDEX NAME_IDX ON (first_name, last_name);
D.    CREATE INDEX NAME_IDX ON employees (first_name AND last_name);
E.     CREATE INDEX NAME_IDX ON employees(first_name, last_name);
F.     CREATE INDEX NAME_IDX FOR employees(first_name, last_name);  

56. The CUSTOMERS table has these columns: 
CUSTOMER_ID   NUMBER (4)   NOT NULL
CUSTOMER_NAME   VARCHAR2 (100)  NOT NULL
CUSTOMER_ADDRESS  VARCHAR2 (150)
CUSTOMER_PHONE   VARCHAR2 (20) 
You need to produce output that states "Dear Customer customer_name”. The customer_name data values come from the CUSTOMER_NAME column in the CUSTOMERS table. Which statement produces this output?
A.     SELECT dear customer, customer_name, FROM customers;
B.     SELECT "Dear Customer", customer_name || ',' FROM customers;
C.    SELECT 'Dear Customer ' || customer_name ',' FROM customers;
D.    SELECT 'Dear Customer ' || customer_name || ',' FROM customers;
E.     SELECT "Dear Customer " || customer_name || "," FROM customers;
F.     SELECT 'Dear Customer ' || customer_name || ',' || FROM customers; 

57. What is true about sequences?
A.     Once created, a sequence belongs to a specific schema.
B.     Once created, a sequence is linked to a specific table.
C.    Once created, a sequence is automatically available to all users.
D.    Only the DBA can control which sequence is used by a certain table.
E.     Once created, a sequence is automatically used in all INSERT and UPDATE statements.

58. Which statement describes the ROWID data type?
A.     binary data up to 4 gigabytes
B.     character data up to 4 gigabytes
C.    raw binary data of variable length up to 2 gigabytes
D.    binary data stored in an external file, up to 4 gigabytes
E.     a hexadecimal string representing the unique address of a row in its table 

59. Which object privileges can be granted on a view?
A.     none
B.     DELETE, INSERT, SELECT
C.    ALTER, DELETE, INSERT, SELECT
D.    DELETE, INSERT, SELECT, UPDATE 

60. Examine the SQL statement that creates ORDERS table:
CREATE TABLE orders (
SER_NO NUMBER UNIQUE,
ORDER_ID NUMBER,
ORDER_DATE DATE NOT NULL,
STATUS VARCHAR2 (10) CHECK (status IN ('CREDIT', 'CASH')),
PROD_ID NUMBER
REFERENCES PRODUCTS (PRODUCT_ID), ORD_TOTAL NUMBER,
PRIMARY KEY (order_id, order_date)); 
For which columns would an index be automatically created when you execute the above SQL statement? (Choose two.)
A.     SER_NO
B.     ORDER_ID
C.    STATUS
D.    PROD_ID
E.     ORD_TOTAL
F.     composite index on ORDER_ID and ORDER_DATE 

61. What is true of using group functions on columns that contain NULL values? 
A.     Group functions on columns ignore NULL values.
B.     Group functions on columns returning dates include NULL values.
C.    Group functions on columns returning numbers include NULL values.
D.    Group functions on columns cannot be accurately used on columns that contain NULL values.
E.     Group functions on columns include NULL values in calculations if you use the keyword INC_NULLS.

62. Which SQL statement returns a numeric value?
A.     SELECT ADD_MONTHS(MAX (hire_date), 6) FROM EMP;
B.     SELECT ROUND(hire_date)FROM EMP;
C.    SELECT sysdate-hire_date FROM EMP;
D.    SELECT TO_NUMBER(hire_date + 7)FROM EMP;

63. 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;

64. In which four clauses can a subquery be used? (Choose four.)
A.     in the INTO clause of an INSERT statement
B.     in the FROM clause of a SELECT statement
C.    in the GROUP BY clause of a SELECT statement
D.    in the WHERE clause of a SELECT statement
E.     in the SET clause of an UPDATE statement
F.     in the VALUES clause of an INSERT statement 

65. Examine this statement:             
SELECT student_id, GPA FROM student_grades WHERE GPA > &&value; 
You run the statement once, and when prompted you enter a value of 2.0. A report is produced. What happens when you run the statement a second time?
A.     An error is returned.
B.     You are prompted to enter a new value.
C.    A report is produced that matches the first report produced.
D.    You are asked whether you want a new value or if you want to run the report based on the previous value.

66. Examine the data of the EMPLOYEES table.
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                         HR_MGR                               5000
106                         Bryan                     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
EMPLOYEES (EMPLOYEE_ID is the primary key.
MGR_ID is the ID of managers and refers to the EMPLOYEE_ID)
Evaluate this SQL statement:  
SELECT e.employee_id "Emp_id", e.emp_name "Employee", e.salary, m.employee_id "Mgr_id", m.emp_name "Manager"
FROM employees e, employees m WHERE e.mgr_id = m.employee_id AND e.salary > 4000; 
What is its output?
A.            Emp_id                                  EMPLOYEE                          SALARY                 Mgr_id  Manager
---------                    -------------                               ----------------           -------------
110                         Bob                                         8000                       Bob
120                         Ravi                                        6500  
110                         Ravi
108                         Jennifer                                 6500
110                         Jennifer
103                         Chris                                      4200
120                         Chris  
105                         Diana                                     5000
108                         Diana
B.            Emp_id                  EMPLOYEE                          SALARY                 Mgr_id  Manager
-------                       -------------                               -----------------         ------------------
120                         Ravi                                        6500
110                         Bob  
108                         Jennifer                                 6500
110                         Bob
103                         Chris                                      4200
120                         Ravi
105                         Diana                                     5000
108                         Jennifer  
C.            Emp_id                 EMPLOYEE                          SALARY                 Mgr_id Manager
-------                       ----------                                   ---------                    -------------
110                         Bob                                         8000
120                         Ravi                                        6500
110                         Bob 
108                         Jennifer                                 6500
110                         Bob
103                         Chris                                      4200
120                         Ravi  
105                         Diana                                     5000
108                         Jennifer

D.            Emp_id                  EMPLOYEE                          SALARY                 Mgr_id Manager
-------                        ----------                                  ---------                    --------------
110                         Bob                                         8000
110                         Bob 
120                         Ravi                                        6500
120                         Ravi 
108                         Jennifer                                 6500
108                         Jennifer 
103                         Chris                                      4200
103                         Chris
105                         Diana                                     5000
105                         Dina 
E. The SQL statement produces an error.

67. What are two reasons to create synonyms? (Choose two.)
A.     You have too many tables.
B.     Your tables are too long.
C.    Your tables have difficult names.
D.    You want to work on your own tables.
E.     You want to use another schema's tables.
F.     You have too many columns in your tables. 

68. What is true about updates through a view?
A.     You cannot update a view with group functions.
B.     When you update a view group functions are automatically computed.
C.    When you update a view only the constraints on the underlying table will be in effect.
D.    When you update a view the constraints on the views always override the constraints on the underlying tables.

69. 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; 

70. View the image below and examine the data from the ORDERS and CUSTOMERS tables. Evaluate this SQL statement:
SELECT cust_id, ord_total
FROM orders
WHERE ord_total > ANY(SELECT ord_total 
  FROM orders
 WHERE cust_id IN (SELECT cust_id
       FROM customers
       WHERE city LIKE 'New York')); 
What is the result when the above query is executed?
A.     **
B.     **
C.    **
D.    **
E.     The query returns no rows.
F.     The query fails because ANY is not a valid operator with a subquery. 

71.  You need to create a table named ORDERS that contains four columns: - an ORDER_ID column of number data type - a CUSTOMER_ID column of number data type - an ORDER_STATUS column that contains a character data type - a DATE_ORDERED
column to contain the date the order was placed. When a row is inserted into the table, if no value is provided when the order was placed, today's date should be used instead.  Which statement accomplishes this?
A.     CREATE TABLE orders (order_id NUMBER(10), customer_id NUMBER(8),order_status VARCHAR2 (10),date_ordered DATE = SYSDATE);
B.     CREATE TABLE orders (order_id NUMBER(10), customer_id NUMBER(8),order_status VARCHAR2 (10),date_ordered DATE DEFAULT SYSDATE); 
C.    CREATE OR REPLACE TABLE orders (order_id NUMBER(10), customer_id NUMBER(8),order_status VARCHAR2 (10),date_ordered DATE DEFAULT SYSDATE); 
D.    CREATE OR REPLACE TABLE orders (order_id NUMBER(10), customer_id NUMBER(8),order_status VARCHAR2 (10),date_ordered DATE = SYSDATE);   
E.     CREATE TABLE orders (order_id NUMBER(10), customer_id NUMBER(8),order_status NUMBER (10),date_ordered DATE = SYSDATE); 
F.     CREATE TABLE orders (order_id NUMBER(10), customer_id NUMBER(8),order_status NUMBER (10),date_ordered DATE DEFAULT SYSDATE); 

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

73. The CUSTOMERS table has these columns:
CUSTOMER_ID                   NUMBER (4)                         NOT NULL
CUSTOMER_NAME           VARCHAR2 (100)                NOT NULL
STREET_ADDRESS           VARCHAR2 (150) 
CITY_ADDRESS                  VARCHAR2 (50)
STATE_ADDRESS              VARCHAR2 (50)
PROVINCE_ADDRESS      VARCHAR2 (50)
COUNTRY_ADDRESS       VARCHAR2 (50)
POSTAL_CODE                                  VARCHAR2 (12)
CUSTOMER_PHONE         VARCHAR2 (20)
A promotional sale is being advertised to the customers in France. Which WHERE clause identifies customers that are located in France?
A.     WHERE lower(country_address) = "France"
B.     WHERE lower(country_address) = 'france'
C.    WHERE lower(country_address) IS 'France'
D.    WHERE lower(country_address) = '%France%'
E.     WHERE lower(country_address) LIKE %France% 

74. Examine the description of the CUSTOMERS table as shown in the previous question. CUSTOMER_ID column is the primary key for the table. Which statement returns the city address and the number of customers in the cities Los Angeles or San Francisco?
A.     SELECT city_address, COUNT(*) FROM customers WHERE city_address IN ('Los Angeles', 'San Francisco'); 
B.     SELECT city_address, COUNT(*) FROM customers WHERE city_address IN ('Los Angeles', 'San Francisco') GROUP BY city_address;
C.    SELECT city_address, COUNT(customer_id) FROM customers WHERE city_address IN ('Los Angeles', 'San Francisco') GROUP BY city_address, customer_id;
D.    SELECT city_address, COUNT(customer_id) FROM customers GROUP BY city_address IN ('Los Angeles', 'San Francisco'); 

75. What does the FORCE option for creating a view do?
A.     creates a view with constraints
B.     creates a view even if the underlying parent table has constraints
C.    creates a view in another schema even if you don't have privileges
D.    creates a view regardless of whether or not the base tables exist 

76. Examine the description of the CUSTOMERS table as shown in the previous question. CUSTOMER_ID column is the primary key for the table. You need to determine how dispersed your customer base is. Which expression finds the number of different countries represented in the CUSTOMERS table?
A.     COUNT(UPPER(country_address))
B.     COUNT(DIFF(UPPER(country_address)))
C.    COUNT(UNIQUE(UPPER(country_address)))
D.    COUNT DISTINCT UPPER(country_address)
E.     COUNT(DISTINCT (UPPER(country_address))) 

77. A data manipulation language statement _____.
A.     completes a transaction on a table
B.     modifies the structure and data in a table
C.    modifies the data but not the structure of a table
D.    modifies the structure but not the data of a table 

78. Which two tasks can you perform using only the TO_CHAR function? (Choose two.) 
A.     convert 10 to 'TEN' 
B.     convert '10' to 10
C.    convert 10 to '10'
D.    convert 'TEN' to 10
E.     convert a date to a character expression
F.     convert a character expression to a date 

79. DBA issues this SQL command: CREATE USER Scott IDENTIFIED by tiger; what privileges do the user Scott has at this point?
A.     no privileges
B.     only the SELECT privilege
C.    only the CONNECT privilege
D.    all the privileges of a default user 

80. View the image below and examine the data in the EMPLOYEES table. 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.

81. You need to produce a report for mailing labels for all customers. The mailing label must have only the customer name and address. The CUSTOMERS table has these columns: 
CUST_ID                               NUMBER (4)   NOT NULL
CUST_NAME                       VARCHAR2 (100)  NOT NULL
CUST_ADDRESS               VARCHAR2 (150)
CUST_PHONE                    VARCHAR2 (20) 
Which SELECT statement accomplishes this task?
A.     SELECT *FROM customers;
B.     SELECT name, address FROM customers;
C.    SELECT id, name, address, phone FROM customers;
D.    SELECT cust_name, cust_address FROM customers;
E.     SELECT cust_id, cust_name, cust_address, cust_phone FROM customers; 

82. Examine the statement: 
                GRANT select, insert, update ON student_grades TO manager WITH GRANT OPTION;
Which two are true? (Choose two.)
A.     MANAGER must be a role.
B.     It allows the MANAGER to pass the specified privileges on to other users.
C.    It allows the MANAGER to create tables that refer to the STUDENT_GRADES table.
D.    It allows the MANAGER to apply all DML statements on the STUDENT_GRADES table.
E.     It allows the MANAGER the ability to select from, insert into, and update the STUDENT_GRADES table.
F.     It allows the MANAGER the ability to select from, delete from, and update the STUDENT_GRADES table.

83. Which best describes an inline view?
A.     a schema object
B.     a subquery that can contain an ORDER BY clause
C.    another name for a view that contains group functions
D.    a subquery that is part of the FROM clause of another query 

84. Examine the structure of the EMPLOYEES and DEPARTMENTS tables: 
EMPLOYEES
EMPLOYEE_ID                    NUMBER
DEPARTMENT_ID              NUMBER
MANAGER_ID                      NUMBER
LAST_NAME                        VARCHAR2 (25)
DEPARTMENTS
DEPARTMENT_ID              NUMBER
MANAGER_ID                      NUMBER
DEPARTMENT_NAME       VARCHAR2 (35)
LOCATION_ID                     NUMBER 
You want to create a report displaying employee last names, department names, and locations. Which query should you use to create an Equijoin?
A.     SELECT last_name, department_name, location_id FROM employees , departments;
B.     SELECT employees.last_name, departments.department_name, departments.location_id FROM employees e, departments D WHERE e.department_id =d.department_id; 
C.    SELECT e.last_name, d.DEPARTMENT_NAME, d.location_id FROM employees e, departments D WHERE manager_id =manager_id; 
D.    SELECT e.last_name, d.DEPARTMENT_NAME, d.location_id FROM employees e, departments D WHERE e.department_id =d.department_id; 

85. 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.     The results are not sorted.
B.     The results are sorted numerically.
C.    The results are sorted alphabetically.
D.    The results are sorted numerically and then alphabetically. 

86. Examine the data in the EMPLOYEES table:
LAST_NAME        DEPARTMENT_ID              SALARY
Getz                        10                                           3000
Davis                      20                                           1500
King                        20                                           2200
Davis                      30                                           5000 
Which three Subqueries work? (Choose three)
A.     SELECT * FROM employees where salary > (SELECT MIN(salary) FROM employees GROUP BY department_id); 
B.     SELECT * FROM employees WHERE salary = (SELECT AVG(salary) FROM employees GROUP BY department_id); 
C.    SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id); 
D.    SELECT department_id FROM employees WHERE SALARY > ALL (SELECT AVG(salary) FROM employees GROUP BY department_id);   
E.     SELECT last_name FROM employees Where salary > ANY (SELECT MAX(salary) FROM employees GROUP BY department_id); 
F.     SELECT department_id FROM employees WHERE salary > ALL (SELECT AVG(salary) FROM employees GROUP BY AVG(SALARY)); 

87. In which two cases would you use an outer join? (Choose two.)
A.     The tables being joined have NOT NULL columns.
B.     The tables being joined have only matched data.
C.    The columns being joined have NULL values.
D.    The tables being joined have only unmatched data.
E.     The tables being joined have both matched and unmatched data.
F.     Only when the tables have a primary key/foreign key relationship. 

88. In which case would you use a FULL OUTER JOIN?
A.     Both tables have NULL values.
B.     You want all unmatched data from one table.
C.    You want all matched data from both tables.
D.    You want all unmatched data from both tables.
E.     One of the tables has more data than the other.
F.     You want all matched and unmatched data from only one table. 

89. Which constraint can be defined only at the column level?
A.     UNIQUE
B.     NOT NULL
C.    CHECK
D.    PRIMARY KEY
E.     FOREIGN KEY 

90. Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID    NUMBER               Primary Key
FIRST_NAME       VARCHAR2 (25)
LAST_NAME        VARCHAR2 (25)
HIRE_DATE          DATE 
You issue these statements:
CREATE table new_emp (employee_id NUMBER, name VARCHAR2 (30));
INSERT INTO new_emp SELECT employee_id , last_name from employees;
Savepoint s1;
UPDATE new_emp set name = UPPER (name);
Savepoint s2;
Delete from new_emp;
Rollback to s2;
Delete from new_emp where employee_id =180;
UPDATE new_emp set name = 'James';
Rollback to s2;
UPDATE new_emp set name = 'James' WHERE employee_id =180;
Rollback; 
At the end of this transaction, what is true?
A.     You have no rows in the table.
B.     You have an employee with the name of James.
C.    You cannot roll back to the same Savepoint more than once.
D.    Your last update fails to update any rows because employee ID 180 was already deleted.

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

92. The user Alice wants to grant all users query privileges on her DEPT table. Which SQL statement accomplishes this?
A.     GRANT select ON dept TO ALL_USERS;
B.     GRANT select ON dept TO ALL;
C.    GRANT QUERY ON dept TO ALL_USERS
D.    GRANT select ON dept TO PUBLIC; 

93. Which view should a user query to display the columns associated with the constraints on a table owned by the user?
A.     USER_CONSTRAINTS
B.     USER_OBJECTS
C.    ALL_CONSTRAINTS
D.    USER_CONS_COLUMNS
E.     USER_COLUMNS 

94. View the image below and examine the data in the EMPLOYEES and DEPARTMENTS tables.
On the EMPLOYEES table,  EMPLOYEE_ID is the primary key.  MGR_ID is the ID of 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.     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.     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.    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.    The statement fails because there is more than one row matching the employee name Smith. 
E.     The statement fails because there is more than one row matching the IT_ADMIN job ID in the EMPLOYEES table.
F.     The statement fails because there is no 'Administration' department in the DEPARTMENTS table 

95. Which two statements are true about WHERE and HAVING clauses? (Choose two.)
A.     A WHERE clause can be used to restrict both rows and groups.
B.     A WHERE clause can be used to restrict rows only.
C.    A HAVING clause can be used to restrict both rows and groups.
D.    A HAVING clause can be used to restrict groups only.
E.     A WHERE clause CANNOT be used in a query if the query uses a HAVING clause.
F.     A HAVING clause CANNOT be used in Subqueries. 

96. Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID                    NUMBER   NOT NULL
EMP_NAME                         VARCHAR2 (30)
JOB_ID                                  VARCHAR2 (20)
SAL                                        NUMBER
MGR_ID                                 NUMBER
DEPARTMENT_ID              NUMBER 
You want to create a SQL script file that contains an INSERT statement. When the script is run, the INSERT statement should insert a row with the specified values into the EMPLOYEES table. The INSERT statement should pass values to the table columns as specified below:
EMPLOYEE_ID: Next value from the sequence
EMP_ID_SEQEMP_NAME and JOB_ID: As specified by the user during run time, through substitution variables
SAL: 2000 MGR_ID: No value
DEPARTMENT_ID: Supplied by the user during run time through substitution variable.
The INSERT statement should fail if the user supplies a value other than 20 or 50. Which INSERT statement meets the above requirements?
A.     INSERT INTO employees VALUES (emp_id_seq. NEXTVAL, '&ename', '&job_Id', 2000, NULL, &did); 
B.     INSERT INTO employees VALUES (emp_id_seq. NEXTVAL, '&ename', '&job_Id', 2000, NULL, &did IN (20,50)); 
C.    INSERT INTO (SELECT * FROM employees WHERE department_id IN (20,50)) VALUES (emp_id_seq. NEXTVAL, '&ename', '&job_id', 2000, NULL, &did); 
D.    INSERT INTO (SELECT * FROM employees WHERE department_id IN (20,50) WITH CHECK OPTION)VALUES (emp_id_seq. NEXTVAL, '&ename', '&job_id', 2000, NULL, &did); 
E.     INSERT INTO (SELECT * FROM employees WHERE (department_id = 20 AND department_id = 50) WITH CHECK OPTION )VALUES (emp_id_seq. NEXTVAL, '&ename', '&job_id', 2000, NULL, &did); 

97. The EMP table contains these columns: 
LAST_NAME                        VARCHAR2 (25)
SALARY                                 NUMBER (6, 2)
DEPARTMENT_ID              NUMBER (6)
You need to display the employees who have not been assigned to any department. You write the SELECT statement:
SELECT LAST_NAME, SALARY, DEPARTMENT_ID FROM EMP WHERE DEPARTMENT_ID = NULL; 
What is true about this SQL statement?
A.     The SQL statement displays the desired results.
B.     The column in the WHERE clause should be changed to display the desired results.
C.    The operator in the WHERE clause should be changed to display the desired results.
D.    The WHERE clause should be changed to use an outer join to display the desired  results.

98. Examine these statements: 
CREATE ROLE registrar;
GRANT UPDATE ON student_grades TO registrar;
GRANT registrar to user1, user2, user3; 
What does this set of SQL statements do?

A.     The set of statements contains an error and does not work.
B.     It creates a role called REGISTRAR, adds the MODIFY privilege on the STUDENT_GRADES object to the role, and gives the REGISTRAR role to three users. 
C.    It creates a role called REGISTRAR, adds the UPDATE privilege on the STUDENT_GRADES object to the role, and gives the REGISTRAR role to three users. 
D.    It creates a role called REGISTRAR, adds the UPDATE privilege on the STUDENT_GRADES object to the role, and creates three users with the role. 
E.     It creates a role called REGISTRAR, adds the UPDATE privilege on three users, and gives the REGISTRAR role to the STUDENT_GRADES object.
F.     It creates a role called STUDENT_GRADES, adds the UPDATE privilege on three users, and gives the UPDATE role to the registrar. 

99. Which two statements are true about constraints? (Choose two.)
A.     The UNIQUE constraint does not permit a null value for the column.
B.     A UNIQUE index gets created for columns with PRIMARY KEY and UNIQUE  constraints.
C.    The PRIMARY KEY and FOREIGN KEY constraints create a UNIQUE index.
D.    The NOT NULL constraint ensures that null values are not permitted for the column.

100. You need to design a student registration database that contains several tables storing academic information.
The STUDENTS table stores information about a student. The STUDENT_GRADES table stores information about the student's grades. Both of the tables have a column named STUDENT_ID. The STUDENT_ID column in the STUDENTS table is a primary key. You need to create a foreign key on the STUDENT_ID column of the STUDENT_GRADES table that points to the STUDENT_ID column of the STUDENTS table. Which statement creates the foreign key?
A.     CREATE TABLE student_grades (student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), CONSTRAINT student_id_fk REFERENCES (student_id) FOREIGN KEY students(student_id)); 
B.     CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), student_id_fk FOREIGN KEY (student_id) REFERENCES students(student_id)); 
C.    CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), CONSTRAINT FOREIGN KEY (student_id) REFERENCES students(student_id)); 
D.    CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa NUMBER(4,3), CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCES students(student_id)); 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.