Selasa, 21 Juni 2016

Database Programming with SQL-Section 15 Quiz


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

1. You must create a view that will display the name, customer identification number, new balance, finance charge, and credit limit 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


DELETE


SELECT (*)


INSERT


UPDATE



Incorrect Incorrect. Refer to Section 15 Lesson 3.


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


The CREATE VIEW statement generates an error.


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


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. (*)



Incorrect Incorrect. Refer to Section 15 Lesson 3.


3. Which of the following is true about ROWNUM? Mark for Review
(1) Points


It is the number assigned to each row returned from a query after it is ordered.


It is the number assigned to each row returned from a query as it is read from the table. (*)


It is the number of rows in a table.


None of the above



Correct Correct


4. Which statement about an inline view is true? Mark for Review
(1) Points


An inline view is a complex view.


An inline view is a schema object.


An inline view can be used to perform DML operations.


An inline view is a subquery in the FROM clause, often named with an alias. (*)



Incorrect Incorrect. Refer to Section 15 Lesson 3.


5. 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 execute this statement:

SELECT ROWNUM "Rank", customer_id, new_balance
FROM (SELECT customer_id, new_balance FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;

What statement is true?

 Mark for Review
(1) Points


The statement will not necessarily return the 25 highest new balance values, as the inline view has no ORDER BY clause. (*)


The statement failed to execute because the ORDER BY clause does NOT use the Top-n column.


The 25 greatest new balance values were displayed from the highest to the lowest.


The statement failed to execute because an inline view was used.



Incorrect Incorrect. Refer to Section 15 Lesson 3.


Page 1 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

6. You administer an Oracle database. Jack manages the Sales 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 accept INSERT, UPDATE, or DELETE operations. Which of the following statements should you issue? Mark for Review
(1) Points


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)
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
    (SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
    FROM customers c, orders o
    WHERE c.custid = o.custid)
WITH READ ONLY;


CREATE VIEW sales_view
   AS (SELECT companyname, city, orderid, orderdate, total
   FROM customers, orders
   WHERE custid = custid)
WITH READ ONLY;



Correct Correct


7. You cannot insert data through a view if the view includes ______. Mark for Review
(1) Points


A column alias


A GROUP BY clause (*)


A join


A WHERE clause



Incorrect Incorrect. Refer to Section 15 Lesson 2.


8. Your manager has just asked you to create a report that illustrates the salary range of all the employees at your company. Which of the following SQL statements will create a view called SALARY_VU based on the employee last names, department names, salaries, and salary grades for all employees? Use the EMPLOYEES, DEPARTMENTS, and JOB_GRADES tables. Label the columns Employee, Department, Salary, and Grade, respectively. Mark for Review
(1) Points


CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary "Salary", j. grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and j.highest_sal);


CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary "Salary", j. grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and j.highest_sal;
(*)



CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary", j. grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and j.highest_sal;


CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary "Salary", j. grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id equals d.department_id AND e.salary BETWEEN j.lowest_sal and j.highest_sal;



Correct Correct


9. You cannot modify data in a view if the view contains ______. Mark for Review
(1) Points


The DISTINCT keyword (*)


A subquery in the FROM clause


The WITH CHECK OPTION clause


A WHERE clause



Correct Correct


10. You can create a view if the view subquery contains an inline view. True or False? Mark for Review
(1) Points


True (*)


False



Correct Correct


Previous Page 2 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

11. 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 still select the row through the view. True or False? Mark for Review
(1) Points


True


False (*)



Incorrect Incorrect. Refer to Section 15 Lesson 1.


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


MODIFY VIEW


CREATE OR REPLACE VIEW (*)


ALTER VIEW


ALTER TABLE



Incorrect Incorrect. Refer to Section 15 Lesson 1.


13. A view can contain a select statement with a subquery. True or False? Mark for Review
(1) Points


True (*)


False



Correct Correct


14. You need to create a view that will display the name, employee identification number, first and last name, salary, and department identification number. The display should be sorted by salary from lowest to highest, then by last name and first name alphabetically. The view definition should be created regardless of the existence of the EMPLOYEES table. No DML may be performed when using this view. Evaluate these statements:
CREATE OR REPLACE NOFORCE VIEW EMP_SALARY_V
AS SELECT employee_id, last_name, first_name, salary, department_id
FROM employees WITH READ ONLY;

SELECT *
FROM emp_salary_v
ORDER BY salary, last_name, first_name;

Which statement is true?

 Mark for Review
(1) Points


When both statements are executed all of the desired results are achieved.


To achieve all of the desired results this ORDER ON clause should be added to the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.


The CREATE VIEW statement will fail if the EMPLOYEES table does not exist. (*)


The statements will NOT return all of the desired results because the WITH CHECK OPTION clause is NOT included in the CREATE VIEW statement.



Incorrect Incorrect. Refer to Section 15 Lesson 1.


15. Which statement about the CREATE VIEW statement is true? Mark for Review
(1) Points


A CREATE VIEW statement CAN contain a join query. (*)


A CREATE VIEW statement CANNOT contain an ORDER BY clause.


A CREATE VIEW statement CANNOT contain a function.


A CREATE VIEW statement CANNOT contain a GROUP BY clause.



Incorrect Incorrect. Refer to Section 15 Lesson 1.


Previous Page 3 of 3 Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

1. Your manager has just asked you to create a report that illustrates the salary range of all the employees at your company. Which of the following SQL statements will create a view called SALARY_VU based on the employee last names, department names, salaries, and salary grades for all employees? Use the EMPLOYEES, DEPARTMENTS, and JOB_GRADES tables. Label the columns Employee, Department, Salary, and Grade, respectively. Mark for Review
(1) Points


CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary "Salary", j. grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and j.highest_sal);


CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary", j. grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and j.highest_sal;


CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary "Salary", j. grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and j.highest_sal;
(*)



CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary "Salary", j. grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id equals d.department_id AND e.salary BETWEEN j.lowest_sal and j.highest_sal;



Incorrect Incorrect. Refer to Section 15 Lesson 2.


2. Which of the following DML operations is not allowed when using a Simple View created with read only? Mark for Review
(1) Points


INSERT


UPDATE


DELETE


All of the above (*)



Incorrect Incorrect. Refer to Section 15 Lesson 2.


3. Only one type of view exists. True or False? Mark for Review
(1) Points


True


False (*)



Incorrect Incorrect. Refer to Section 15 Lesson 2.


4. You can create a view if the view subquery contains an inline view. True or False? Mark for Review
(1) Points


True (*)


False



Incorrect Incorrect. Refer to Section 15 Lesson 2.


5. You create a view on the EMPLOYEES and DEPARTMENTS tables to display salary information per department.
What will happen if you issue the 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 department, 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 department, sorted by department id.


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



Correct Correct


Page 1 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

6. A view can contain a select statement with a subquery. True or False? Mark for Review
(1) Points


True (*)


False



Correct Correct


7. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
    (SELECT first_name, last_name, status, courseid, subject, term
     FROM faculty f, course c
     WHERE f.facultyid = c.facultyid);

Which type of view will this statement create?

 Mark for Review
(1) Points


Complex (*)


Simple


Nested


Inline



Correct Correct


8. What is one advantage of using views? Mark for Review
(1) Points


To be able to store the same data in more than one place


To provide data dependence


To provide restricted data access (*)



Incorrect Incorrect. Refer to Section 15 Lesson 1.


9. 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 still select the row through the view. True or False? Mark for Review
(1) Points


True


False (*)



Incorrect Incorrect. Refer to Section 15 Lesson 1.


10. A view can contain group functions. True or False? Mark for Review
(1) Points


True (*)


False



Correct Correct


Previous Page 2 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

11. Which statement about an inline view is true? Mark for Review
(1) Points


An inline view is a subquery in the FROM clause, often named with an alias. (*)


An inline view is a complex view.


An inline view can be used to perform DML operations.


An inline view is a schema object.



Correct Correct


12. You must create a view that will display the name, customer identification number, new balance, finance charge, and credit limit 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


SELECT (*)


UPDATE


INSERT


DELETE



Correct Correct


13. When you drop a view, the data it contains is also deleted. True or False? Mark for Review
(1) Points


True


False (*)



Incorrect Incorrect. Refer to Section 15 Lesson 3.


14. When you drop a table referenced by a view, the view is automatically dropped as well. True or False? Mark for Review
(1) Points


True


False (*)



Incorrect Incorrect. Refer to Section 15 Lesson 3.


15. Which of these Keywords is typically used with a Top-N Analysis? Mark for Review
(1) Points


Sequence


Number


Rowid


Rownum (*)



Correct Correct


Previous Page 3 of 3 Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

1. Which action can be performed by using DML statements? Mark for Review
(1) Points


Altering a table


Creating PRIMARY KEY constraints


Deleting records in a table (*)


Disabling an index



Incorrect Incorrect. Refer to Section 15 Lesson 2.


2. What is the purpose of including the WITH CHECK OPTION clause when creating a view? Mark for Review
(1) Points


To insure that no rows are updated through the view that would prevent those rows from being returned by the view in the future. (*)


To keep views form being queried by unauthorized persons


To make sure that data is not duplicated in the view


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



Correct Correct


3. Which statement about performing DML operations on a view is true? Mark for Review
(1) Points


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


You can perform DML operations on a view that contains columns defined by expressions, such as COST + 1.


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 ONLY option.



Incorrect Incorrect. Refer to Section 15 Lesson 2.


4. You need to create a new view on the EMPLOYEES table to update salary information for employees in Department 50. You need to ensure that DML operations through the view can not change salary values in other departments. Which clause should be included in the CREATE VIEW statement? Mark for Review
(1) Points


WITH READ ONLY


FORCE


OR REPLACE


WITH CHECK OPTION (*)



Incorrect Incorrect. Refer to Section 15 Lesson 2.


5. Examine the view below and choose the operation that CANNOT be performed on it.
CREATE VIEW dj_view (last_name, number_events) AS
SELECT c.last_name, COUNT(e.name)
FROM d_clients c, d_events e
WHERE c.client_number = e.client_number
GROUP BY c.last_name
 Mark for Review
(1) Points


INSERT INTO dj_view VALUES ('Turner', 8); (*)


CREATE OR REPLACE dj_view (last_name, number_events) AS
SELECT c.last_name, COUNT (e.name)
FROM d_clients c, d_events e
WHERE c.client_number=e.client_number
GROUP BY c.last_name;


DROP VIEW dj_view;


SELECT last_name, number_events FROM dj_view;



Incorrect Incorrect. Refer to Section 15 Lesson 2.


Page 1 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

6. Which of these Keywords is typically used with a Top-N Analysis? Mark for Review
(1) Points


Number


Sequence


Rowid


Rownum (*)



Correct Correct


7. An inline view is an unnamed select statement found: Mark for Review
(1) Points


In the user_views data dictionary view.


Enclosed in parentheses within the FROM clause of a surrounding query. (*)


In a special database column of a users table.


Enclosed in parentheses within the select list of a surrounding query.



Correct Correct


8. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
JOB_ID NUMBER
MANAGER_ID NUMBER
SALARY NUMBER(9,2)
COMMISSOIN NUMBER(7,2)
HIRE_DATE DATE

Which SELECT statement could be used to display the 10 lowest paid clerks that belong to department 70?

 Mark for Review
(1) Points


SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary "Salary"
FROM (SELECT last_name, first_name, salary
     FROM employees
     ORDER BY salary)
WHERE ROWNUM <=10 AND job_id LIKE 'CLERK' AND department_id = 70;


SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary "Salary"
FROM (SELECT last_name, first_name, salary, job_id
     FROM employees
     WHERE job_id LIKE 'CLERK' AND department_id = 70
     ORDER BY salary)
WHERE ROWNUM <=10;
(*)



SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary "Salary"
FROM (SELECT last_name, first_name, salary, job_id, dept_id
     FROM employees
     WHERE ROWNUM <=10
     ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;


The only way is to use the data dictionary.



Incorrect Incorrect. Refer to Section 15 Lesson 3.


9. You must create a view that will display the name, customer identification number, new balance, finance charge, and credit limit 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


INSERT


SELECT (*)


DELETE



Correct Correct


10. When you drop a view, the data it contains is also deleted. True or False? Mark for Review
(1) Points


True


False (*)



Correct Correct


Previous Page 2 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

11. You need to create a view on the SALES table, but the SALES table has not yet been created. Which statement is true? Mark for Review
(1) Points


By default, the view will be created even if the SALES table does not exist.


You can create the table and the view at the same time using the FORCE option.


You can use the FORCE option to create the view before the SALES table has been created. (*)


You must create the SALES table before creating the view.



Incorrect Incorrect. Refer to Section 15 Lesson 1.


12. Which statement about the CREATE VIEW statement is true? Mark for Review
(1) Points


A CREATE VIEW statement CANNOT contain an ORDER BY clause.


A CREATE VIEW statement CANNOT contain a function.


A CREATE VIEW statement CAN contain a join query. (*)


A CREATE VIEW statement CANNOT contain a GROUP BY clause.



Correct Correct


13. 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 still select the row through the view. True or False? Mark for Review
(1) Points


True


False (*)



Correct Correct


14. 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 columns from the table.


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


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


Views provide data independence for infrequent users and application programs. One view can be used to retrieve data from several tables. Views can be used to provide data security. (*)



Correct Correct


15. You administer an Oracle database which contains a table named EMPLOYEES. Luke, a database user, must create a report that includes the names and addresses of all employees. You do not want to grant Luke access to the EMPLOYEES table because it contains sensitive data. Which of the following actions should you perform first? Mark for Review
(1) Points


Create an index.


Create a subquery.


Create a view. (*)


Create a report for him.



Incorrect Incorrect. Refer to Section 15 Lesson 1.


Previous Page 3 of 3 Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

1. An inline view is an unnamed select statement found: Mark for Review
(1) Points


In the user_views data dictionary view.


In a special database column of a users table.


Enclosed in parentheses within the select list of a surrounding query.


Enclosed in parentheses within the FROM clause of a surrounding query. (*)



Incorrect Incorrect. Refer to Section 15 Lesson 3.


2. 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. (*)


The CREATE VIEW statement generates an error.


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



Incorrect Incorrect. Refer to Section 15 Lesson 3.


3. How do you remove a view? Mark for Review
(1) Points


DELETE VIEW view_name


REMOVE VIEW view_name


DROP VIEW view_name (*)


You cannot remove a view



Incorrect Incorrect. Refer to Section 15 Lesson 3.


4. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
JOB_ID NUMBER
MANAGER_ID NUMBER
SALARY NUMBER(9,2)
COMMISSOIN NUMBER(7,2)
HIRE_DATE DATE

Which SELECT statement could be used to display the 10 lowest paid clerks that belong to department 70?

 Mark for Review
(1) Points


SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary "Salary"
FROM (SELECT last_name, first_name, salary
     FROM employees
     ORDER BY salary)
WHERE ROWNUM <=10 AND job_id LIKE 'CLERK' AND department_id = 70;


SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary "Salary"
FROM (SELECT last_name, first_name, salary, job_id
     FROM employees
     WHERE job_id LIKE 'CLERK' AND department_id = 70
     ORDER BY salary)
WHERE ROWNUM <=10;
(*)



SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary "Salary"
FROM (SELECT last_name, first_name, salary, job_id, dept_id
     FROM employees
     WHERE ROWNUM <=10
     ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;


The only way is to use the data dictionary.



Incorrect Incorrect. Refer to Section 15 Lesson 3.


5. When you drop a table referenced by a view, the view is automatically dropped as well. True or False? Mark for Review
(1) Points


True


False (*)



Incorrect Incorrect. Refer to Section 15 Lesson 3.


Page 1 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

6. For a View created using the WITH CHECK OPTION keywords, which of the following statements are true? Mark for Review
(1) Points


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


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


Prohibits DML actions without administrator CHECK approval


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



Incorrect Incorrect. Refer to Section 15 Lesson 2.


7. Which statement about performing DML operations on a view is true? Mark for Review
(1) Points


You cannot modify data in a view if the view contains a WHERE clause.


You cannot modify data in a view if the view contains a group function. (*)


You can delete data in a view if the view contains the DISTINCT keyword.


You can modify data in a view if the view contains a GROUP BY clause.



Incorrect Incorrect. Refer to Section 15 Lesson 2.


8. You cannot modify data in a view if the view contains ______. Mark for Review
(1) Points


The DISTINCT keyword (*)


A WHERE clause


A subquery in the FROM clause


The WITH CHECK OPTION clause



Correct Correct


9. Using the pseudocolumn ROWNUM in a view has no implications on the ability to do DML's through the view. True or False? Mark for Review
(1) Points


True


False (*)



Incorrect Incorrect. Refer to Section 15 Lesson 2.


10. Which action can be performed by using DML statements? Mark for Review
(1) Points


Disabling an index


Altering a table


Deleting records in a table (*)


Creating PRIMARY KEY constraints



Incorrect Incorrect. Refer to Section 15 Lesson 2.


Previous Page 2 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

11. Unlike tables, views contain no data of their own. True or False? Mark for Review
(1) Points


True (*)


False



Correct Correct


12. Any select statement can be stored in the database as a view. True or False Mark for Review
(1) Points


True (*)


False



Correct Correct


13. Which keyword(s) would you include in a CREATE VIEW statement to create the view whether or not the base table exists? Mark for Review
(1) Points


FORCE (*)


WITH READ ONLY


NOFORCE


OR REPLACE



Correct Correct


14. 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 table. True or False? Mark for Review
(1) Points


True


False (*)



Incorrect Incorrect. Refer to Section 15 Lesson 1.


15. 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 still select the row through the view. True or False? Mark for Review
(1) Points


True


False (*)



Incorrect Incorrect. Refer to Section 15 Lesson 1.


Previous Page 3 of 3 Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

1. You want to create a view based on the SALESREP table. You plan to grant access to this view to members of the Sales department. You want Sales employees to be able to update the SALESREP table through the view, which you plan to name SALESREP_VIEW. What should not be specified in your CREATE VIEW statement? Mark for Review
(1) Points


The IN keyword


A WHERE clause


A GROUP BY clause (*)


The AS keyword



Incorrect Incorrect. Refer to Section 15 Lesson 3.


2. When you drop a view, the data it contains is also deleted. True or False? Mark for Review
(1) Points


True


False (*)



Correct Correct


3. An inline view is an unnamed select statement found: Mark for Review
(1) Points


In a special database column of a users table.


In the user_views data dictionary view.


Enclosed in parentheses within the FROM clause of a surrounding query. (*)


Enclosed in parentheses within the select list of a surrounding query.



Correct Correct


4. 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 execute this statement:

SELECT ROWNUM "Rank", customer_id, new_balance
FROM (SELECT customer_id, new_balance FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;

What statement is true?

 Mark for Review
(1) Points


The statement failed to execute because an inline view was used.


The statement will not necessarily return the 25 highest new balance values, as the inline view has no ORDER BY clause. (*)


The statement failed to execute because the ORDER BY clause does NOT use the Top-n column.


The 25 greatest new balance values were displayed from the highest to the lowest.



Correct Correct


5. Which of these Keywords is typically used with a Top-N Analysis? Mark for Review
(1) Points


Sequence


Rownum (*)


Rowid


Number



Correct Correct


Page 1 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

6. In order to query a database using a view, which of the following statements applies? Mark for Review
(1) Points


You can retrieve data from a view as you would from any table. (*)


Use special VIEW SELECT keywords.


The tables you are selecting from can be empty, yet the view still returns the original data from those tables.


You can never see all the rows in the table through the view.



Incorrect Incorrect. Refer to Section 15 Lesson 1.


7. Which keyword(s) would you include in a CREATE VIEW statement to create the view whether or not the base table exists? Mark for Review
(1) Points


NOFORCE


WITH READ ONLY


FORCE (*)


OR REPLACE



Correct Correct


8. A view can contain group functions. True or False? Mark for Review
(1) Points


True (*)


False



Correct Correct


9. You need to create a view that will display the name, employee identification number, first and last name, salary, and department identification number. The display should be sorted by salary from lowest to highest, then by last name and first name alphabetically. The view definition should be created regardless of the existence of the EMPLOYEES table. No DML may be performed when using this view. Evaluate these statements:
CREATE OR REPLACE NOFORCE VIEW EMP_SALARY_V
AS SELECT employee_id, last_name, first_name, salary, department_id
FROM employees WITH READ ONLY;

SELECT *
FROM emp_salary_v
ORDER BY salary, last_name, first_name;

Which statement is true?

 Mark for Review
(1) Points


The CREATE VIEW statement will fail if the EMPLOYEES table does not exist. (*)


To achieve all of the desired results this ORDER ON clause should be added to the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.


The statements will NOT return all of the desired results because the WITH CHECK OPTION clause is NOT included in the CREATE VIEW statement.


When both statements are executed all of the desired results are achieved.



Correct Correct


10. The FACULTY table contains these columns:
FACULTYID VARCHAR2(5) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(20)
LAST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
STATUS VARCHAR2(2) NOT NULL

The COURSE table contains these columns:

COURSEID VARCHAR2(5) NOT NULL PRIMARY KEY
SUBJECT VARCHAR2(5)
TERM VARCHAR2(6)
FACULTYID VARCHAR2(5) NOT NULL FOREIGN KEY

You have been asked to compile a report that identifies all adjunct professors who will be teaching classes in the upcoming term. You want to create a view that will simplify the creation of this report. Which CREATE VIEW statements will accomplish this task?

 Mark for Review
(1) Points


CREATE VIEW pt_view IN    (SELECT first_name, last_name, status, courseid, subject, term
FROM faculty course);


CREATE VIEW pt_view AS
   (SELECT first_name, last_name, status, courseid, subject, term
   FROM faculty f, course c
   WHERE f.facultyid = c.facultyid);
(*)



CREATE VIEW pt_view
ON (SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f and course c
WHERE f.facultyid = c.facultyid);


CREATE VIEW
   (SELECT first_name, last_name, status, courseid, subject, term
   FROM faculty, course
   WHERE facultyid = facultyid);



Incorrect Incorrect. Refer to Section 15 Lesson 1.


Previous Page 2 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

11. You create a view on the EMPLOYEES and DEPARTMENTS tables to display salary information per department.
What will happen if you issue the 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 department, 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 department, sorted by department id.


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



Correct Correct


12. You administer an Oracle database. Jack manages the Sales 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 accept INSERT, UPDATE, or DELETE operations. Which of the following statements should you issue? Mark for Review
(1) Points


CREATE VIEW sales_view
    (SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
    FROM customers c, orders o
    WHERE c.custid = o.custid)
WITH READ ONLY;


CREATE VIEW sales_view
   AS (SELECT companyname, city, orderid, orderdate, total
   FROM customers, orders
   WHERE custid = 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)
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);



Correct Correct


13. Which of the following DML operations is not allowed when using a Simple View created with read only? Mark for Review
(1) Points


INSERT


UPDATE


DELETE


All of the above (*)



Correct Correct


14. Which statement about performing DML operations on a view is true? Mark for Review
(1) Points


You can modify data in a view if the view contains a GROUP BY clause.


You can delete data in a view if the view contains the DISTINCT keyword.


You cannot modify data in a view if the view contains a group function. (*)


You cannot modify data in a view if the view contains a WHERE clause.



Incorrect Incorrect. Refer to Section 15 Lesson 2.


15. Which option would you use when creating a view to ensure that no DML operations occur on the view? Mark for Review
(1) Points


FORCE


NOFORCE


WITH READ ONLY (*)


WITH ADMIN OPTION



Incorrect Incorrect. Refer to Section 15 Lesson 2.


Previous Page 3 of 3 Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

1. You need to create a view that will display the name, employee identification number, first and last name, salary, and department identification number. The display should be sorted by salary from lowest to highest, then by last name and first name alphabetically. The view definition should be created regardless of the existence of the EMPLOYEES table. No DML may be performed when using this view. Evaluate these statements:
CREATE OR REPLACE NOFORCE VIEW EMP_SALARY_V
AS SELECT employee_id, last_name, first_name, salary, department_id
FROM employees WITH READ ONLY;

SELECT *
FROM emp_salary_v
ORDER BY salary, last_name, first_name;

Which statement is true?

 Mark for Review
(1) Points


When both statements are executed all of the desired results are achieved.


The statements will NOT return all of the desired results because the WITH CHECK OPTION clause is NOT included in the CREATE VIEW statement.


The CREATE VIEW statement will fail if the EMPLOYEES table does not exist. (*)


To achieve all of the desired results this ORDER ON clause should be added to the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.



Correct Correct


2. Which statement about the CREATE VIEW statement is true? Mark for Review
(1) Points


A CREATE VIEW statement CANNOT contain an ORDER BY clause.


A CREATE VIEW statement CAN contain a join query. (*)


A CREATE VIEW statement CANNOT contain a function.


A CREATE VIEW statement CANNOT contain a GROUP BY clause.



Correct Correct


3. In order to query a database using a view, which of the following statements applies? Mark for Review
(1) Points


You can retrieve data from a view as you would from any table. (*)


Use special VIEW SELECT keywords.


The tables you are selecting from can be empty, yet the view still returns the original data from those tables.


You can never see all the rows in the table through the view.



Correct Correct


4. Which option would you use to modify a view rather than dropping it and recreating it? Mark for Review
(1) Points


WITH ADMIN OPTION


CREATE OR REPLACE (*)


FORCE


NOFORCE



Incorrect Incorrect. Refer to Section 15 Lesson 1.


5. Evaluate this CREATE VIEW statement:
CREATE VIEW emp_view
AS SELECT SUM(salary)
FROM employees;

Which statement is true?

 Mark for Review
(1) Points


You can delete records from the EMPLOYEES table using the EMP_VIEW view.


You cannot update data in the EMPLOYEES table using the EMP_VIEW view. (*)


You can update only the SALARY column in the EMPLOYEES table using the EMP_VIEW view.


You can update any data in the EMPLOYEES table using the EMP_VIEW view.



Incorrect Incorrect. Refer to Section 15 Lesson 1.


Page 1 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

6. Examine the view below and choose the operation that CANNOT be performed on it.
CREATE VIEW dj_view (last_name, number_events) AS
SELECT c.last_name, COUNT(e.name)
FROM d_clients c, d_events e
WHERE c.client_number = e.client_number
GROUP BY c.last_name
 Mark for Review
(1) Points


CREATE OR REPLACE dj_view (last_name, number_events) AS
SELECT c.last_name, COUNT (e.name)
FROM d_clients c, d_events e
WHERE c.client_number=e.client_number
GROUP BY c.last_name;


SELECT last_name, number_events FROM dj_view;


INSERT INTO dj_view VALUES ('Turner', 8); (*)


DROP VIEW dj_view;



Correct Correct


7. You cannot insert data through a view if the view includes ______. Mark for Review
(1) Points


A GROUP BY clause (*)


A join


A WHERE clause


A column alias



Correct Correct


8. Given the following view, which operations would be allowed on the emp_dept view?
CREATE OR REPLACE VIEW emp_dept
AS SELECT SUBSTR(e.first_name,1,1) ||' '||e.last_name emp_name,
    e.salary,
    e.hire_date,
    d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND d.department_id >=50;

 Mark for Review
(1) Points


SELECT, UPDATE of all columns


SELECT, INSERT


SELECT, UPDATE of some columns, DELETE (*)


SELECT, DELETE



Correct Correct


9. What is the purpose of including the WITH CHECK OPTION clause when creating a view? Mark for Review
(1) Points


To insure that no rows are updated through the view that would prevent those rows from being returned by the view in the future. (*)


To keep views form being queried by unauthorized persons


To make sure that data is not duplicated in the view


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



Correct Correct


10. You cannot modify data in a view if the view contains ______. Mark for Review
(1) Points


A subquery in the FROM clause


The DISTINCT keyword (*)


A WHERE clause


The WITH CHECK OPTION clause



Correct Correct


Previous Page 2 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

11. Which of the following is true about ROWNUM? Mark for Review
(1) Points


It is the number assigned to each row returned from a query after it is ordered.


It is the number assigned to each row returned from a query as it is read from the table. (*)


It is the number of rows in a table.


None of the above



Correct Correct


12. An inline view is an unnamed select statement found: Mark for Review
(1) Points


Enclosed in parentheses within the FROM clause of a surrounding query. (*)


Enclosed in parentheses within the select list of a surrounding query.


In the user_views data dictionary view.


In a special database column of a users table.



Correct Correct


13. Which of the following describes a top-N query? Mark for Review
(1) Points


A top-N query returns a result set that is sorted according to the specified column values.


A top-N query returns the bottom 15 records from the specified table.


A top-N query returns a limited result set, returning data based on highest or lowest criteria. (*)


A top-N query returns the top 15 records from the specified table.



Incorrect Incorrect. Refer to Section 15 Lesson 3.


14. 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 complex view


A hierarchical view


A Top-n query (*)


A simple view



Incorrect Incorrect. Refer to Section 15 Lesson 3.


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


The CREATE VIEW statement generates an error.


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


You can modify data in the SALES table using the SALES_VIEW view.



Correct Correct


Previous Page 3 of 3 Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

1. 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 successfully?

 Mark for Review
(1) Points


INSERT INTO part_name_v (part_id, part_name, product_id, cost)
VALUES (857986, ムcylinderメ, 8790, 3.45);


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


DELETE FROM part_name_v
WHERE part_id = 56897;


SELECT *
FROM part_name_v;
(*)




Incorrect Incorrect. Refer to Section 15 Lesson 1.


2. 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 table. True or False? Mark for Review
(1) Points


True


False (*)



Correct Correct


3. What is one advantage of using views? Mark for Review
(1) Points


To be able to store the same data in more than one place


To provide data dependence


To provide restricted data access (*)



Correct Correct


4. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
    (SELECT first_name, last_name, status, courseid, subject, term
     FROM faculty f, course c
     WHERE f.facultyid = c.facultyid);

Which type of view will this statement create?

 Mark for Review
(1) Points


Simple


Inline


Complex (*)


Nested



Correct Correct


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


ALTER VIEW


CREATE OR REPLACE VIEW (*)


ALTER TABLE


MODIFY VIEW



Correct Correct


Page 1 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

6. You administer an Oracle database. Jack manages the Sales 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 accept INSERT, UPDATE, or DELETE operations. Which of the following statements should you issue? Mark for Review
(1) Points


CREATE VIEW sales_view
    (SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
    FROM customers c, orders o
    WHERE 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)
WITH READ ONLY;
(*)



CREATE VIEW sales_view
   AS (SELECT companyname, city, orderid, orderdate, total
   FROM customers, orders
   WHERE custid = 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);



Correct Correct


7. You can create a view if the view subquery contains an inline view. True or False? Mark for Review
(1) Points


True (*)


False



Correct Correct


8. Which action can be performed by using DML statements? Mark for Review
(1) Points


Deleting records in a table (*)


Disabling an index


Altering a table


Creating PRIMARY KEY constraints



Correct Correct


9. You need to create a new view on the EMPLOYEES table to update salary information for employees in Department 50. You need to ensure that DML operations through the view can not change salary values in other departments. Which clause should be included in the CREATE VIEW statement? Mark for Review
(1) Points


WITH CHECK OPTION (*)


WITH READ ONLY


OR REPLACE


FORCE



Correct Correct


10. For a View created using the WITH CHECK OPTION keywords, which of the following statements are true? Mark for Review
(1) Points


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


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


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


Prohibits DML actions without administrator CHECK approval



Correct Correct


Previous Page 2 of 3 Next Summary


Test: Section 15 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 15 Quiz
(Answer all questions in this section)

11. An inline view is an unnamed select statement found: Mark for Review
(1) Points


Enclosed in parentheses within the FROM clause of a surrounding query. (*)


Enclosed in parentheses within the select list of a surrounding query.


In the user_views data dictionary view.


In a special database column of a users table.



Correct Correct


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


DROP VIEW emp_hist_v; (*)


REMOVE emp_hist_v;



Incorrect Incorrect. Refer to Section 15 Lesson 3.


13. Which of these is not a valid type of View? Mark for Review
(1) Points


COMPLEX


INLINE


SIMPLE


ONLINE (*)



Incorrect Incorrect. Refer to Section 15 Lesson 3.


14. 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 execute this statement:

SELECT ROWNUM "Rank", customer_id, new_balance
FROM (SELECT customer_id, new_balance FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;

What statement is true?

 Mark for Review
(1) Points


The statement failed to execute because the ORDER BY clause does NOT use the Top-n column.


The 25 greatest new balance values were displayed from the highest to the lowest.


The statement will not necessarily return the 25 highest new balance values, as the inline view has no ORDER BY clause. (*)


The statement failed to execute because an inline view was used.



Correct Correct


15. Which statement about an inline view is true? Mark for Review
(1) Points


An inline view is a complex view.


An inline view can be used to perform DML operations.


An inline view is a schema object.


An inline view is a subquery in the FROM clause, often named with an alias. (*)



Correct Correct


Previous Page 3 of 3 Summary


Tidak ada komentar:

Posting Komentar