Sei sulla pagina 1di 21

Review your answers, feedback, and question scores below.

An asterisk (*) indica


tes a correct answer.
Part II of the Semester 2 Final Exam covers Sections 10-14 of Database P
rogramming with SQL.
Section 10
1. For a View created using the WITH CHECK OPTION keywords,
which of the following statements are true? Mark for Review
(1) Points

The view will allow the user to check it against the data dictionary

Prohibits changing rows not returned by the subquery in the view definit
ion. (*)

Prohibits DML actions without administrator CHECK approval

Allows for DELETES from other tables, including ones not listed in subqu
ery

Correct Correct

2. You create a view on the EMPLOYEES and DEPARTMENTS table


s to display salary information per department. What will happen if you issue th
e following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points

A complex view is created that returns the sum of salaries per departmen
t, sorted by department name. (*)

A simple view is created that returns the sum of salaries per department
, sorted by department name.

A complex view is created that returns the sum of salaries per departmen
t, sorted by department id.

Nothing, as the statement constains an error and will fail.

Correct Correct
3. You administer an Oracle database. Jack manages the Sale
s department. He and his employees often find it necessary to query the database
to identify customers and their orders. He has asked you to create a view that
will simplify this procedure for himself and his staff. The view should not acce
pt INSERT, UPDATE or DELETE operations. Which of the following statements should
you issue? Mark for Review
(1) Points

CREATE VIEW sales_view


&nbspAS (SELECT companyname, city, orderid, orderdate, total
&nbspFROM customers, orders
&nbspWHERE custid = custid)
WITH READ ONLY;

CREATE VIEW sales_view


(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
&nbspFROM customers c, orders o
&nbspWHERE c.custid = o.custid)
WITH READ ONLY;

CREATE VIEW sales_view


AS (SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);

CREATE VIEW sales_view


&nbspAS (SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
&nbspFROM customers c, orders o
&nbspWHERE c.custid = o.custid)
WITH READ ONLY;
(*)

Correct Correct

4. Which statement about performing DML operations on a vie


w is true? Mark for Review
(1) Points

You can perform DML operations on simple views. (*)

You cannot perform DML operations on a view that contains the WITH CHECK
OPTION clause.

You can perform DML operations on a view that contains the WITH READ ONL
Y option.
You can perform DML operations on a view that contains columns defined b
y expressions, such as COST + 1.

Correct Correct

5. What is the purpose of including the WITH CHECK OPTION c


lause when creating a view? Mark for Review
(1) Points

To make sure that the parent table(s) actually exist

To keep views form being queried by unauthorized persons

To make sure that data is not duplicated in the view

To make sure no rows are updated through the view that will hinder those
rows from being returned by the view. (*)

Correct Correct

6. You cannot insert data through a view if the view includ


es ______. Mark for Review
(1) Points

A WHERE clause

A join

A column alias

A GROUP BY clause (*)

Correct Correct

7. You need to create a new view on the EMPLOYEES table to


update salary information for employees in Department 50. You need to ensure tha
t DML operations through the view do not change the result set of the view. Whic
h clause should include in the CREATE VIEW statement? Mark for Review
(1) Points

FORCE
OR REPLACE

WITH READ ONLY

WITH CHECK OPTION (*)

Correct Correct

8. A view can be used to keep a history record of old data


from the underlying tables, so even if a row is deleted from a table, you can st
ill select the row through the view. True or False? Mark for Review
(1) Points

True

False (*)

Correct Correct

9. Views must be used to select data from a table. As soon


as a view is created on a table, you can no longer select directly from the tabl
e. True or False? Mark for Review
(1) Points

True

False (*)

Correct Correct

10. Which keyword(s) would you include in a CREATE VIEW stat


ement to create the view regardless of whether or not the base table exists?
Mark for Review
(1) Points

FORCE (*)

NOFORCE

OR REPLACE
WITH READ ONLY

Correct Correct
Section 10
11. Which of the following keywords cannot be used when crea
ting a view? Mark for Review
(1) Points

HAVING

WHERE

ORDER BY

They are all valid keywords when creating views. (*)

Correct Correct

12. Which statement would you use to alter a view? Mark for
Review
(1) Points

ALTER VIEW

MODIFY VIEW

ALTER TABLE

CREATE OR REPLACE VIEW (*)

Correct Correct

13. Which of the following statements is a valid reason for


using a view? Mark for Review
(1) Points

Views allow access to the data because the view displays all of the colu
mns from the table.
Views provide data independence for infrequent users and application pro
grams. One view can be used to retrieve data from several tables. Views can be u
sed to provide data security. (*)

Views are used when you only want to restrict DML operations using a WIT
H CHECK OPTION.

Views are not valid unless you have more than one user.

Correct Correct

14. Evaluate this view definition:


CREATE OR REPLACE VIEW part_name_v
AS SELECT DISTINCT part_name
FROM parts
WHERE cost >= 45;
Which of the following statements using the PART_NAME_V view will execute succes
sfully?
Mark for Review
(1) Points

SELECT *
FROM part_name_v;
(*)

UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;

DELETE FROM part_name_v


WHERE part_id = 56897;

INSERT INTO part_name_v (part_id, part_name, product_id, cost)


VALUES (857986, 'cylinder', 8790, 3.45);

Correct Correct

15. Evaluate this CREATE VIEW statement:


CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
&nbspFROM faculty f, course c
&nbspWHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points

Nested

Simple

Inline

Complex (*)

Incorrect Incorrect. Refer to Section 10

16. Evaluate this SELECT statement:


SELECT ROWNUM "Rank", customer_id, new_balance
FROM (SELECT customer_id, new_balance FROM customer_finance
ORDER BY new_balance DESC)
WHERE ROWNUM <= 25;
Which type of query is this SELECT statement?
Mark for Review
(1) Points

A Top-n query (*)

A complex view

A simple view

A hierarchical view

Correct Correct

17. Evaluate this CREATE VIEW statement:


CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40)
GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.

You cannot modify data in the SALES table using the SALES_VIEW view. (*)

You can only insert records into the SALES table using the SALES_VIEW vi
ew.

The CREATE VIEW statement generates an error.

Correct Correct

18. You must create a view that when queried will display th
e name, customer identification number, new balance, finance charge and credit l
imit of all customers. You issue this statement:
CREATE OR REPLACE VIEW CUST_CREDIT_V
AS SELECT c.last_name, c.customer_id, a.new_balance, a.finance_charge, a.credit_
limit
FROM customers c, accounts a
WHERE c.account_id = a.account_id WITH READ ONLY;
Which type of SQL command can be issued on the CUST_CREDIT_V view?
Mark for Review
(1) Points

UPDATE

DELETE

INSERT

SELECT (*)

Correct Correct

19. The EMP_HIST_V view is no longer needed. Which statement


should you use to the remove this view? Mark for Review
(1) Points

DROP emp_hist_v;

DELETE emp_hist_v;
REMOVE emp_hist_v;

DROP VIEW emp_hist_v; (*)

Correct Correct

20. The CUSTOMER_FINANCE table contains these columns:


CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You created a Top-n query report that displays the account numbers and new balan
ce of the 800 accounts that have the highest new balance value. The results are
sorted by payments value from highest to lowest. Which SELECT statement clause i
s included in your query?
Mark for Review
(1) Points

Inner query: ORDER BY new_balance DESC (*)

Inner query: WHERE ROWNUM = 800

Outer query: ORDER BY new_balance DESC

Inner query: SELECT customer_id, new_balance ROWNUM

Correct Correct
Part II of the Semester 2 Final Exam covers Sections 10-14 of Database P
rogramming with SQL.
Section 11
21. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points

You created a public synonym on the EMP table owned by user Sam.

You created a private synonym on the EMPLOYEES table that you own.
You created a public synonym on the EMPLOYEES table owned by user Sam.

You created a private synonym on the EMPLOYEES table owned by user Sam.
(*)

Correct Correct

22. Which statement would you use to remove the LAST_NAME_ID


X index on the LAST_NAME column of the EMPLOYEES table? Mark for Review
(1) Points

DROP INDEX last_name_idx;


(*)

DROP INDEX last_name_idx(last_name);

DROP INDEX last_name_idx(employees.last_name);

ALTER TABLE employees


DROP INDEX last_name_idx;

Correct Correct

23. What would you create to make the following statement ex


ecute faster?
SELECT *
FROM employees
WHERE LOWER(last_name) = 'chang';
Mark for Review
(1) Points

A synonym.

An index, either a normal or a function_based index. (*)

A composite index.

Nothing; the performance of this statement cannot be improved.

Correct Correct
24. You need to determine the table name and column name(s)
on which the SALES_IDX index is defined. Which data dictionary view would you qu
ery? Mark for Review
(1) Points

USER_INDEXES

USER_TABLES

USER_OBJECTS

USER_IND_COLUMNS (*)

Correct Correct

25. Which statement about an index is true? Mark for


Review
(1) Points

An index can only be created on a single table column.

Creating an index will always improve query performance.

Creating an index reorders the data in the underlying table.

An index created on multiple columns is called a composite or concatenat


ed index. (*)

Correct Correct

26. Barry creates a table named INVENTORY. Pam must be able


to query the table. Barry wants to enable Pam to query the table without being r
equired to specify the table's schema. Which of the following should Barry creat
e? Mark for Review
(1) Points

A schema

An index

A view
A synonym (*)

Correct Correct

27. Unique indexes are automatically created on columns that


have which two types of constraints? Mark for Review
(1) Points

NOT NULL and UNIQUE

UNIQUE and PRIMARY KEY (*)

UNIQUE and FOREIGN KEY

PRIMARY KEY and FOREIGN KEY

Correct Correct

28. The CUSTOMERS table exists in user Mary's schema. Which


statement should you use to create a synonym for all database users on the CUSTO
MERS table? Mark for Review
(1) Points

CREATE PUBLIC SYNONYM cust ON mary.customers;

CREATE PUBLIC SYNONYM cust FOR mary.customers;


(*)

CREATE SYNONYM cust ON mary.customers FOR PUBLIC;

CREATE SYNONYM cust ON mary.customers;


GRANT SELECT ON cust TO PUBLIC;

Correct Correct

29. The EMPLOYEES table contains these columns:


EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DEPARTMENT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCT table
HIRE_DATE DATE DEFAULT SYSDATE
SALARY NUMBER (8,2) NOT NULL
On which column is an index automatically created for the EMPLOYEES table?
Mark for Review
(1) Points

SALARY

LAST_NAME

HIRE_DATE

EMPLOYEE_ID (*)

DEPARTMENT_ID

Correct Correct

30. Evaluate this statement:


CREATE INDEX sales_idx ON oe.sales (status);
Which statement is true?
Mark for Review
(1) Points

The CREATE INDEX creates a function-based index.

The CREATE INDEX statement creates a nonunique index. (*)

The CREATE INDEX statement creates a unique index.

The CREATE INDEX statement fails because of a syntax error.

Correct Correct
Part II of the Semester 2 Final Exam covers Sections 10-14 of Database Programmi
ng with SQL.
Section 11
31. Evaluate this statement:
DROP SEQUENCE line_item_id_seq;
What does this statement accomplish?
Mark for Review
(1) Points

It sets the next value of the sequence to 1.

It sets the next value of the sequence to 0.

It sets the current value of the sequence to 0.

It removes the sequence from the data dictionary. (*)

Incorrect Incorrect. Refer to Section 11

32. Evaluate this CREATE SEQUENCE statement:


CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points

The sequence has no maximum value.

The sequence preallocates values and retains them in memory.

The sequence will continue to generate values after reaching its maximum
value.

The sequence will start with 1. (*)

Incorrect Incorrect. Refer to Section 11

33. Which statement would you use to remove the EMP_ID_SEQ s


equence? Mark for Review
(1) Points

DELETE SEQUENCE emp_id_seq;

DROP SEQUENCE emp_id_seq; (*)

ALTER SEQUENCE emp_id_seq ...;


REMOVE SEQUENCE emp_id_seq;

Correct Correct

34. Sequences can be used to: (Choose three) Mark for


Review
(1) Points
(Choose all correct answers)

Ensure primary key values will be unique and consecutive

Ensure primary key values will be unique even though gaps may exist (*)

Generate a range of numbers and optionally cycle through them again (*)

Set a fixed interval between successively generated numbers. (*)

Guarantee that no primary key values are unused

Correct Correct

35. You create a sequence with the following statement:


CREATE SEQUENCE my_emp_seq;
Which of the following statements about this sequence are true? (Choose two)
Mark for Review
(1) Points
(Choose all correct answers)

MINVALUE is equal to 1. (*)

MAXVALUE is unlimited.

When the sequence exceeds its maximum value it will continue to generate
numbers starting with MINVALUE.

The sequence will not cache a range of numbers in memory. (*)

Correct Correct
Section 12
36. Which of the following privileges must be assigned to a
user account in order for that user to connect to an Oracle database? Mark for
Review
(1) Points

ALTER SESSION

CREATE SESSION (*)

OPEN SESSION

RESTRICTED SESSION

Correct Correct

37. Which of the following best describes a role in an Oracl


e database? Mark for Review
(1) Points

A role is a type of system privilege.

A role is the part that a user plays in querying the database.

A role is a name for a group of privileges. (*)

A role is an object privilege which allows a user to update a table.

Correct Correct

38. User JAMES has created a CUSTOMERS table and wants to al


low all other users to SELECT from it. Which command should JAMES use to do this
? Mark for Review
(1) Points

GRANT customers(SELECT) TO PUBLIC;

GRANT SELECT ON customers TO ALL;


GRANT SELECT ON customers TO PUBLIC; (*)

CREATE PUBLIC SYNONYM customers FOR james.customers;

Correct Correct

39. You want to grant privileges to user CHAN that will allo
w CHAN to update the data in the EMPLOYEES table. Which type of privileges will
you grant to CHAN? Mark for Review
(1) Points

User privileges

Object privileges (*)

System privileges

Administrator privileges

Correct Correct

40. You create a view named EMPLOYEES_VIEW on a subset of th


e EMPLOYEES table. User AUDREY needs to use this view to create reports. Only yo
u and Audrey should have access to this view. Which of the following actions sho
uld you perform? Mark for Review
(1) Points

Do nothing. As a database user, Audrey's user account has automatically


been granted the SELECT privilege for all database objects.

GRANT SELECT ON employees_view TO public;

GRANT SELECT ON employees_view TO audrey; (*)

GRANT SELECT ON employees AND employees_view TO audrey;

Correct Correct
Part II of the Semester 2 Final Exam covers Sections 10-14 of Database Programmi
ng with SQL.
Section 12
41. You want to grant user BOB the ability to change other u
sers' passwords. Which privilege should you grant to BOB? Mark for Review
(1) Points

The ALTER USER privilege (*)

The CREATE USER privilege

The DROP USER privilege

The CREATE PROFILE privilege

Correct Correct

42. The database administrator wants to allow user Marco to


create new tables in his own schema. Which privilege should be granted to Marco?
Mark for Review
(1) Points

CREATE ANY TABLE

SELECT

CREATE TABLE (*)

CREATE OBJECT

Correct Correct

43. Which statement would you use to remove an object privil


ege granted to a user? Mark for Review
(1) Points

ALTER USER

REVOKE (*)

REMOVE

DROP
Correct Correct

44. When granting an object privilege, which option would yo


u include to allow the grantee to grant the privilege to another user? Mark for
Review
(1) Points

WITH GRANT OPTION (*)

WITH ADMIN OPTION

PUBLIC

FORCE

Correct Correct

45. Which statement would you use to grant a role to users?


Mark for Review
(1) Points

GRANT (*)

ALTER USER

CREATE USER

ASSIGN

Correct Correct

46. Which statement would you use to add privileges to a rol


e? Mark for Review
(1) Points

CREATE ROLE

ALTER ROLE

GRANT (*)
ASSIGN

Correct Correct

47. Which of the following simplifies the administration of


privileges? Mark for Review
(1) Points

An index

A view

A trigger

A role (*)

Correct Correct

48. To join a table in your database to a table on a second


(remote) Oracle database, you need to use: Mark for Review
(1) Points

A remote procedure call

An Oracle gateway product

An ODBC driver

A database link (*)

Correct Correct

Section 14
49. Which SQL statement is used to remove all the changes ma
de by an uncommitted transaction? Mark for Review
(1) Points

UNDO;
ROLLBACK; (*)

ROLLBACK TO SAVEPOINT;

REVOKE ...;

Correct Correct

50. If a database crashes, all uncommitted changes are autom


atically rolled back. True or False? Mark for Review
(1) Points

True (*)

False

Correct Correct

Potrebbero piacerti anche