Database Programming With SQL Section 15 Quiz
Database Programming With SQL Section 15 Quiz
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;
DELETE
SELECT (*)
INSERT
UPDATE
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. (*)
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. (*)
Correct Correct
An inline view is a subquery in the FROM clause, often named with an alias. (*)
Incorrect Incorrect. Refer to Section 15 Lesson 3.
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.
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
Correct Correct
7. You cannot insert data through a view if the view includes ______. Mark for Review
(1) Points
A column alias
A WHERE clause
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
9. You cannot modify data in a view if the view contains ______. Mark for Review
(1) Points
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
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 (*)
12. Which statement would you use to alter a view? Mark for Review
(1) Points
MODIFY VIEW
ALTER VIEW
ALTER TABLE
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;
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.
15. Which statement about the CREATE VIEW statement is true? Mark for Review
(1) Points
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
INSERT
UPDATE
DELETE
3. Only one type of view exists. True or False? Mark for Review
(1) Points
True
False (*)
4. You can create a view if the view subquery contains an inline view. True or False? Mark for Review
(1) Points
True (*)
False
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;
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.
Correct Correct
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);
Complex (*)
Simple
Nested
Inline
Correct Correct
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 (*)
10. A view can contain group functions. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
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. (*)
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;
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 (*)
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 (*)
15. Which of these Keywords is typically used with a Top-N Analysis? Mark for Review
(1) Points
Sequence
Number
Rowid
Rownum (*)
Correct Correct
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
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. (*)
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 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.
FORCE
OR REPLACE
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
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
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?
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
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.
12. Which statement about the CREATE VIEW statement is true? Mark for Review
(1) Points
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.
Section 15 Quiz
(Answer all questions in this section)
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. (*)
Which SELECT statement could be used to display the 10 lowest paid clerks that belong to department
70?
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 (*)
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. (*)
The view will allow the user to check it against the data dictionary
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.
8. You cannot modify data in a view if the view contains ______. Mark for Review
(1) Points
A WHERE 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 (*)
10. Which action can be performed by using DML statements? Mark for Review
(1) Points
Disabling an index
Altering a table
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 (*)
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 (*)
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 (*)
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
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
Correct Correct
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
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. (*)
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.
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
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;
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
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?
CREATE VIEW pt_view IN (SELECT first_name, last_name, status, courseid, subject, term
FROM faculty course);
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.
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;
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.
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;
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
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.
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
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;
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
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. (*)
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
FORCE
NOFORCE
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.
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
Correct Correct
7. You cannot insert data through a view if the view includes ______. Mark for Review
(1) Points
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;
SELECT, INSERT
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. (*)
Correct Correct
10. You cannot modify data in a view if the view contains ______. Mark for Review
(1) Points
A WHERE clause
The WITH CHECK OPTION clause
Correct Correct
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. (*)
Correct Correct
12. An inline view is an unnamed select statement found: Mark for Review
(1) Points
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.
A complex view
A hierarchical view
A simple view
Incorrect Incorrect. Refer to Section 15 Lesson 3.
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
Section 15 Quiz
(Answer all questions in this section)
Which of the following statements using the PART_NAME_V view will execute successfully?
UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;
SELECT *
FROM part_name_v;
(*)
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
Simple
Inline
Complex (*)
Nested
Correct Correct
5. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
ALTER TABLE
MODIFY VIEW
Correct Correct
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
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
Disabling an index
Altering a table
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
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
Correct Correct
Section 15 Quiz
(Answer all questions in this section)
11. An inline view is an unnamed select statement found: Mark for Review
(1) Points
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;
REMOVE emp_hist_v;
13. Which of these is not a valid type of View? Mark for Review
(1) Points
COMPLEX
INLINE
SIMPLE
ONLINE (*)
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. (*)
Correct Correct
15. 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. (*)