Final Exam - Database Programming With SQL
Final Exam - Database Programming With SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 1
1. Which SQL statement below will correctly create the EMP table based on the
structure of the EMPLOYEES table? Include only the EMPLOYEE_ID, FIRST_NAME,
LAST_NAME, SALARY, and DEPARTMENT_ID columns. Mark for Review
(1) Points
CREATE TABLE employee
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees;
2. Which of the following SQL statements will create a table called Birthdays
with three columns for storing employee number, name and date of birth? Mark for
Review
(1) Points
CREATE table BIRTHDAYS (EMPNO, EMPNAME, BIRTHDATE);
CREATE table BIRTHDAYS (employee number, name, date of birth);
CREATE TABLE Birthdays (Empno NUMBER, Empname CHAR(20), Birthdate DATE); (*)
CREATE TABLE Birthdays (Empno NUMBER, Empname CHAR(20), Date of Birth DATE);
3. You want to create a table named TRAVEL that is a child of the EMPLOYEES
table. Which of the following statements should you issue? Mark for Review
(1) Points
CREATE TABLE travel (destination_id primary key, departure_date date,
return_date date, emp_id REFERENCES employees (emp_id));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, t.emp_id = e.emp_id);
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, JOIN emp_id number(10) ON employees (emp_id));
Page 1
Final Exam - Database Programming with SQL
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
5. Which statement about table and column names is true? Mark for Review
(1) Points
Table and column names must begin with a letter. (*)
Table and column names can begin with a letter or a number.
Section 8 Lesson 2
(Answer all questions in this section)
6. Which data types stores variable-length character data? Select two. Mark for
Review
(1) Points
(Choose all correct answers)
CHAR
NCHAR
VARCHAR (*)
VARCHAR2 (*)
Page 2
Final Exam - Database Programming with SQL
Incorrect. Refer to Section 8
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
8. You need to store the HIRE_DATE value with a time zone displacement value and
allow data to be returned in the user's local session time zone. Which data type
should you use? Mark for Review
(1) Points
DATETIME
TIMESTAMP
TIMESTAMP WITH TIME ZONE
TIMESTAMP WITH LOCAL TIME ZONE (*)
9. To store time with fractions of seconds, which datatype should be used for a
table column? Mark for Review
(1) Points
DATE
INTERVAL YEAR TO MONTH
TIMESTAMP (*)
INTERVAL DAY TO SECOND
Page 1 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 2
(Answer all questions in this section)
11. The ELEMENTS column is defined as: NUMBER(6,4) How many digits to the right
of the decimal point are allowed for the ELEMENTS column? Mark for Review
(1) Points
zero
two
four (*)
six
12. The SPEED_TIME column should store a fractional second value. Which data type
should you use? Mark for Review
(1) Points
DATE
DATETIME
TIMESTAMP (*)
Page 4
Final Exam - Database Programming with SQL
Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. Your supervisor has asked you to modify the AMOUNT column in the ORDERS
table. He wants the column to be configured to accept a default value of 250. The
table contains data that you need to keep. Which statement should you issue to
accomplish this task? Mark for Review
(1) Points
ALTER TABLE orders CHANGE DATATYPE amount TO DEFAULT 250;
Which statement should you use to increase the LAST_NAME column length to 35 if the
column currently contains 200 records?
Mark for Review
(1) Points
ALTER employee TABLE ALTER COLUMN (last_name VARCHAR2(35));
ALTER TABLE employee RENAME last_name VARCHAR2(35);
ALTER TABLE employee MODIFY (last_name VARCHAR2(35)); (*)
You CANNOT increase the width of the LAST_NAME column.
Page 5
Final Exam - Database Programming with SQL
15. You need to remove all the rows from the SALES_HIST table. You want to
release the storage space, but do not want to remove the table structure. Which
statement should you use? Mark for Review
(1) Points
the DROP TABLE statement
the ALTER TABLE statement
the CREATE TABLE statement
the TRUNCATE TABLE statement (*)
Which statement should you use to decrease the width of the FIRST_NAME column to 10
if the column currently contains 1500 records, but none are longer than 10 bytes or
characters?
Mark for Review
(1) Points
ALTER players TABLE MODIFY COLUMN first_name VARCHAR2(10);
ALTER players TABLE MODIFY COLUMN (first_name VARCHAR2(10));
The TEAMS table is currently empty. You need to allow users to include text
characters in the manager identification values. Which statement should you use to
implement this?
Mark for Review
(1) Points
Page 6
Final Exam - Database Programming with SQL
Incorrect. Refer to Section 8 Lesson 3
19. The previous administrator created a table named CONTACTS, which contains
outdated data. You want to remove the table and its data from the database. Which
statement should you issue? Mark for Review
(1) Points
DROP TABLE (*)
DELETE
TRUNCATE TABLE
ALTER TABLE
20. Which command could you use to quickly remove all data from the rows in a
table without deleting the table itself? Mark for Review
(1) Points
ALTER TABLE
DROP TABLE
MODIFY
TRUNCATE TABLE (*)
Page 2 of 10
Page 7
Final Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 3
(Answer all questions in this section)
21. You want to issue the following command on a database that includes your
company's inventory information:
ALTER TABLE products
SET UNUSED COLUMN color;
What will be the result of issuing this command?
Mark for Review
(1) Points
The column named COLOR in the table named PRODUCTS will be assigned default
values.
The column named COLOR in the table named PRODUCTS will be created.
The column named COLOR in the table named PRODUCTS will be deleted.
The column named COLOR in the table named PRODUCTS will not be returned in
subsequent reads of the table by Oracle, as is has been deleted logically. (*)
23. You need to truncate the EMPLOYEE table. The EMPLOYEE table is not in your
schema. Which privilege must you have to truncate the table? Mark for Review
(1) Points
the DROP ANY TABLE system privilege (*)
Page 8
Final Exam - Database Programming with SQL
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Section 9 Lesson 1
(Answer all questions in this section)
24. Constraints can be added at which two levels? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
Null Field
Table (*)
Row
Dictionary
Column (*)
25. You need to ensure that the LAST_NAME column does not contain null values.
Which type of constraint should you define on the LAST_NAME column? Mark for Review
(1) Points
CHECK
UNIQUE
NOT NULL (*)
PRIMARY KEY
26. Which statement about the NOT NULL constraint is true? Mark for Review
(1) Points
The NOT NULL constraint must be defined at the column level. (*)
The NOT NULL constraint can be defined at either the column level or the table
level.
The NOT NULL constraint requires a column to contain alphanumeric values.
The NOT NULL constraint prevents a column from containing alphanumeric values.
Page 9
Final Exam - Database Programming with SQL
Incorrect. Refer to Section 9
27. You need to ensure that the LAST_NAME column only contains certain character
values. No numbers or special characters are allowed.
Which type of constraint should you define on the LAST_NAME column? Mark for Review
(1) Points
CHECK (*)
UNIQUE
NOT NULL
PRIMARY KEY
29. Which two statements about NOT NULL constraints are true? (Choose two) Mark
for Review
(1) Points
(Choose all correct answers)
The Oracle Server creates a name for an unnamed NOT NULL constraint. (*)
A NOT NULL constraint can be defined at either the table or column level.
The NOT NULL constraint requires that every value in a column be unique.
Columns without the NOT NULL constraint can contain null values by default. (*)
You CANNOT add a NOT NULL constraint to an existing column using the ALTER TABLE
ADD CONSTRAINT statement.using the ALTER TABLE statement.
Section 9 Lesson 2
(Answer all questions in this section)
30. Evaluate the structure of the DONATIONS table.
Page 10
Final Exam - Database Programming with SQL
DONATIONS
PLEDGE_ID NUMBER NOT NULL, Primary Key
DONOR_ID NUMBER Foreign key to DONOR_ID column of DONORS table
PLEDGE_DT DATE
AMOUNT_PLEDGED NUMBER (7,2)
AMOUNT_PAID NUMBER (7,2)
PAYMENT_DT DATE
Which CREATE TABLE statement should you use to create the DONATIONS table?
Mark for Review
(1) Points
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER, amount_paid NUMBER,
payment_dt DATE);
Correct
Page 3 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 9 Lesson 2
(Answer all questions in this section)
31. You need to create a composite primary key constraint on the EMPLOYEE table.
Which statement is true? Mark for Review
(1) Points
Page 11
Final Exam - Database Programming with SQL
The PRIMARY KEY constraint must be defined at the table level. (*)
A PRIMARY KEY constraint must be defined for each column in the composite
primary key.
The PRIMARY KEY constraint must be defined for the first column of the composite
primary key.
The PRIMARY KEY constraint must be defined at the table level and for each
column in the composite primary key.
Correct
32. How many PRIMARY KEY constraints can be created for each table? Mark for
Review
(1) Points
none
one or two
unlimited
33. When creating a referential constraint, which keyword(s) identifies the table
and column in the parent table? Mark for Review
(1) Points
FOREIGN KEY
REFERENCES (*)
ON DELETE CASCADE
34. Which clause could you use to ensure that cost values are greater than 1.00?
Mark for Review
(1) Points
Page 12
Final Exam - Database Programming with SQL
35. What is an attribute of data that is entered into a primary key column? Mark
for Review
(1) Points
Null and non-unique values cannot be entered into a primary key column. (*)
Data that is entered into a primary key column references a column of the same
datatype in another table.
36. Which of the following FOREIGN KEY Constraint keywords identifies the table
and column in the parent table? Mark for Review
(1) Points
RESEMBLES
ON DELETE CASCADE
REFERENTIAL
REFERENCES (*)
37. Which statement about a FOREIGN KEY constraint is true? Mark for Review
(1) Points
A FOREIGN KEY constraint allows the constrained column to contain values that
exist in the primary key column of the parent table. (*)
A FOREIGN KEY column can have a different data type from the primary key column
that it references.
Section 9 Lesson 3
(Answer all questions in this section)
38. You successfully create a table named SALARY in your company's database. Now,
you want to establish a parent/child relationship between the EMPLOYEES table and
the SALARY table by adding a FOREIGN KEY constraint to the SALARY table that
references its matching column in the EMPLOYEES table. You have not added any data
to the SALARY table. Which of the following statements should you issue? Mark for
Page 13
Final Exam - Database Programming with SQL
Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES employees
(employee_id);
(*)
To disable any FOREIGN KEY constraints that are dependent on the PO_NUM column
(*)
To disable the constraint on the PO_NUM column while creating a PRIMARY KEY
index
40. You want to disable the FOREIGN KEY constraint that is defined in the
EMPLOYEES table on the DEPT_ID column. The constraint is referenced by the name
FK_DEPT_ID_01. Which statement should you issue? Mark for Review
(1) Points
ALTER TABLE employees DISABLE 'fk_dept_id_01';
Page 14
Final Exam - Database Programming with SQL
ALTER TABLE employees DISABLE CONSTRAINT 'fk_dept_id_01';
Page 4 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 9 Lesson 3
(Answer all questions in this section)
41. You can view the columns used in a constraint defined for a specific table by
looking at which data dictionary table? Mark for Review
(1) Points
USER_CONS_COLUMNS (*)
CONSTRAINTS_ALL_COLUMNS
SYS_DATA_DICT_COLUMNS
US_CON_SYS
Correct
44. You need to add a PRIMARY KEY constraint on the EMP_ID column of the EMPLOYEE
table. Which ALTER TABLE statement should you use? Mark for Review
(1) Points
ALTER TABLE employee
ADD PRIMARY KEY (emp_id);
ALTER TABLE
ADD CONSTRAINT emp_emp_id_pk PRIMARY KEY employee(emp_id);
(*)
EMPLOYEE_ID NUMBER
EMP_LNAME VARCHAR2(25)
EMP_FNAME VARCHAR2(25)
DEPT_ID NUMBER
JOB_ID NUMBER
MGR_ID NUMBER
SALARY NUMBER(9,2)
HIRE_DATE DATE
Evaluate this statement:
ALTER TABLE employee
ADD CONSTRAINT REFERENTIAL (mgr_id) TO department(mgr_id);
Which statement is true?
Mark for Review
(1) Points
The ALTER TABLE statement creates a referential constraint from the EMPLOYEE
table to the DEPARTMENT table.
The ALTER TABLE statement creates a referential constraint from the DEPARTMENT
table to the EMPLOYEE table.
Page 17
Final Exam - Database Programming with SQL
The ALTER TABLE statement fails because the ADD CONSTRAINT clause contains a
syntax error. (*)
The ALTER TABLE statement succeeds, but does NOT recreate a referential
constraint.
47. Which of the following would always cause an integrity constraint error? Mark
for Review
(1) Points
Using the DELETE command on a row that contains a primary key with a dependent
foreign key. (*)
Section 10 Lesson 1
(Answer all questions in this section)
48. 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
You must create the SALES table before creating the view.
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. (*)
49. 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 (*)
nested
simple
inline
complex (*)
Page 5 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 10 Lesson 1
(Answer all questions in this section)
51. Which keyword(s) would you include in a CREATE VIEW statement to create the
view regardless of whether or not the base table exists? Mark for Review
(1) Points
FORCE (*)
NOFORCE
OR REPLACE
Correct
52. 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. (*)
Page 19
Final Exam - Database Programming with SQL
You can never see all the rows in the table through the view.
The tables you are selecting from can be empty, yet the view still returns the
original data from those tables.
53. Which option would you use to modify a view rather than dropping it and
recreating it? Mark for Review
(1) Points
FORCE
NOFORCE
54. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
55. 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 provide data independence for ad hoc users and application programs. One
view can be used to retrieve data from several tables. Views can be used to provide
data security. (*)
Views are used when you only want to restrict DML operations using a WITH CHECK
OPTION.
Views are not valid unless you have more than one user.
Section 10 Lesson 2
Page 20
Final Exam - Database Programming with SQL
(Answer all questions in this section)
56. 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 definition. (*)
57. You cannot insert data through a view if the view includes ______. Mark for
Review
(1) Points
a WHERE clause
a join
a column alias
a GROUP BY clause (*)
58. 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 companyname, city, orderid, orderdate, total
FROM customers, orders
WHERE custid = custid)
WITH READ ONLY;
Page 21
Final Exam - Database Programming with SQL
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;
(*)
59. Which action can be performed by using DML statements? Mark for Review
(1) Points
Deleting records in a table (*)
Creating PRIMARY KEY constraints
Disabling an index
Altering a table
Correct
60. 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
Page 6 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 10 Lesson 2
(Answer all questions in this section)
61. You cannot create a view if the view subquery contains an inline view. True
or False? Mark for Review
Page 22
Final Exam - Database Programming with SQL
(1) Points
True
False (*)
62. Which statement about performing DML operations on a view is true? Mark for
Review
(1) Points
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 WHERE clause.
You cannot modify data in a view if the view contains a group function. (*)
You can modify data in a view if the view contains a GROUP BY clause.
Section 10 Lesson 3
(Answer all questions in this section)
63. 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;
65. Which statement about an inline view is true? Mark for Review
(1) Points
An inline view is a schema object.
An inline view is a subquery with an alias. (*)
66. 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 AS keyword
Page 24
Final Exam - Database Programming with SQL
a WHERE clause
the IN keyword
a GROUP BY clause (*)
67. 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 parenthesis within the select list of a surrounding query
Enclosed in parenthesis within the from clause of a surrounding query (*)
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq CYCLE;
The sequence will continue to generate values after the maximum sequence value
has been generated. (*)
69. Which of the following best describes the function of the NEXTVAL virtual
column? Mark for Review
(1) Points
The NEXTVAL virtual column displays only the physical locations of the rows in a
table.
The NEXTVAL virtual column displays the order in which Oracle retrieves row data
from a table.
The NEXTVAL virtual column returns the integer that was most recently supplied
Page 25
Final Exam - Database Programming with SQL
by the sequence.
The NEXTVAL virtual column increments a sequence by a predetermined value. (*)
Correct
Page 7 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 11 Lesson 2
(Answer all questions in this section)
71. Which statement would you use to remove the EMP_ID_SEQ sequence? 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;
72. What is the most common use for a Sequence? Mark for Review
(1) Points
Page 26
Final Exam - Database Programming with SQL
To generate primary key values (*)
To improve the performance of some queries
To give an alternative name for an object
To logically represent subsets of data from one or more tables
Section 11 Lesson 3
(Answer all questions in this section)
73. Which of the following best describes the function of an index? Mark for
Review
(1) Points
An index can increase the performance of SQL queries that search large tables.
(*)
An index can reduce the time required to grant multiple privileges to users.
An index can run statement blocks when DML actions occur against a table.
75. What would you create to make the following statement execute faster?
SELECT *
FROM employees
WHERE LOWER(last_name) = 'chang';
Mark for Review
(1) Points
A synonym.
Page 27
Final Exam - Database Programming with SQL
A function_based index. (*)
A composite index.
Nothing; the performance of this statement cannot be improved.
76. Which statement would you use to remove the LAST_NAME_IDX 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;
78. Which one of the following statements about indexes is true? Mark for Review
(1) Points
An index is created automatically when a PRIMARY KEY constraint is created. (*)
Page 28
Final Exam - Database Programming with SQL
An index is never created for a unique constraint.
79. Which of the following SQL statements will display the index name, table
name, and the uniqueness of the index for all indexes on the EMPLOYEES table? Mark
for Review
(1) Points
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
JOB_ID only
DEPT_ID only
Page 8 of 10
Page 29
Final Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 11 Lesson 3
(Answer all questions in this section)
81. What is the correct syntax for creating an index? Mark for Review
(1) Points
CREATE INDEX index_name ON table_name(column_name); (*)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of the
CLIENTS table. You issue this statement:
83. You want to create a composite index on the FIRST_NAME and LAST_NAME columns
of the EMPLOYEES table. Which SQL statement will accomplish this task? Mark for
Review
Page 30
Final Exam - Database Programming with SQL
(1) Points
CREATE INDEX fl_idx ON employees(first_name || last_name);
It allows only the user CHAN to access TESTING using the synonym.
It eliminates the need for all users to qualify TESTING with its schema. (*)
85. 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 query? Mark for
Review
(1) Points
USER_INDEXES
USER_TABLES
USER_OBJECTS
USER_IND_COLUMNS (*)
Section 12 Lesson 2
(Answer all questions in this section)
86. Which of the following are system privileges? (Choose two) Mark for Review
(1) Points
Page 31
Final Exam - Database Programming with SQL
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE PROCEDURE (*)
INDEX
87. User CHANG has been granted SELECT, UPDATE, INSERT and DELETE privileges on
the EMPLOYEES table. You now want to prevent Chang from adding or deleting rows from
the table, while still allowing him to read and modify existing rows. Which
statement should you use to do this? Mark for Review
(1) Points
REVOKE ALL ON employees FROM chang;
REVOKE INSERT, DELETE ON employees FROM chang; (*)
88. User ADAM has successfully logged on to the database in the past, but today
he receives an error message stating that (although he has entered his password
correctly) he cannot log on. What is the most likely cause of the problem? Mark for
Review
(1) Points
One or more object privileges have been REVOKEd from Adam.
ADAM's CREATE SESSION privilege has been revoked. (*)
89. You grant user AMY the CREATE SESSION privilege. Which type of privilege have
you granted to AMY? Mark for Review
(1) Points
A system privilege (*)
An object privilege
A user privilege
An access privilege
Page 32
Final Exam - Database Programming with SQL
Incorrect. Refer to Section 12
90. You are the database administrator. You want to create a new user JONES with
a password of MARK, and allow this user to create his own tables. Which of the
following should you execute? Mark for Review
(1) Points
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE TABLE TO jones;
Page 9 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 12 Lesson 2
(Answer all questions in this section)
91. Which of the following best describes a role in an Oracle database? Mark for
Review
(1) Points
Page 33
Final Exam - Database Programming with SQL
92. User SUSAN creates an EMPLOYEES table, and then creates a view EMP_VIEW which
shows only the FIRST_NAME and LAST_NAME columns of EMPLOYEES. User RUDI needs to be
able to access employees' names but no other data from EMPLOYEES. Which statement
should SUSAN execute to allow this? Mark for Review
(1) Points
SELECT * FROM emp_view FOR rudi;
CREATE SYNONYM emp_view FOR employees;
GRANT SELECT ON emp_view TO rudi; (*)
GRANT SELECT ON emp_view ONLY TO rudi;
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to remove an object privilege granted to a
user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
94. Which of the following best describes the purpose of the REFERENCES object
privilege on a table? Mark for Review
(1) Points
It allows a user's session to read from the table but only so that foreign key
constraints can be checked. (*)
It allows a user to refer to the table in a SELECT statement.
It allows a user to create foreign key constraints on the table.
It allows the user to create new tables which contain the same data as the
referenced table.
95. When granting an object privilege, which option would you include to allow
the grantee to grant the privilege to another user? Mark for Review
(1) Points
WITH GRANT OPTION (*)
Page 34
Final Exam - Database Programming with SQL
WITH ADMIN OPTION
PUBLIC
FORCE
96. User CRAIG creates a view named INVENTORY_V, which is based on the INVENTORY
table. CRAIG wants to make this view available for querying to all database users.
Which of the following actions should CRAIG perform? Mark for Review
(1) Points
He is not required to take any action because, by default, all database users
can automatically access views.
He should assign the SELECT privilege to all database users for the INVENTORY
table.
He should assign the SELECT privilege to all database users for INVENTORY_V
view. (*)
He must grant each user the SELECT privilege on both the INVENTORY table and
INVENTORY_V view.
97. User BOB's schema contains an EMPLOYEES table. BOB executes the following
statement:
GRANT SELECT ON employees TO mary WITH GRANT OPTION;
Which of the following statements can MARY now execute successfully? (Choose two)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT FROM bob.employees; (*)
REVOKE SELECT ON bob.employees FROM bob;
GRANT SELECT ON bob.employees TO PUBLIC; (*)
DROP TABLE bob.employees;
98. Which of the following simplifies the administration of privileges? Mark for
Review
(1) Points
an index
a view
a trigger
Page 35
Final Exam - Database Programming with SQL
a role (*)
Section 14 Lesson 1
(Answer all questions in this section)
99. Which SQL statement is used to remove all the changes made by an uncommitted
transaction? Mark for Review
(1) Points
UNDO;
ROLLBACK; (*)
ROLLBACK TO SAVEPOINT;
REVOKE ;
100. Which of the following best describes the term "read consistency"? Mark for
Review
(1) Points
It ensures that all changes to a table are automatically committed
It prevents other users from querying a table while updates are being executed
on it
It prevents other users from seeing changes to a table until those changes have
been committed (*)
It prevents users from querying tables on which they have not been granted
SELECT privilege
Page 10 of 10
Test: Final Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 1
1. Which of the following SQL statements will create a table called Birthdays
with three columns for storing employee number, name and date of birth? Mark for
Review
(1) Points
Page 36
Final Exam - Database Programming with SQL
CREATE table BIRTHDAYS (EMPNO, EMPNAME, BIRTHDATE);
CREATE TABLE Birthdays (Empno NUMBER, Empname CHAR(20), Date of Birth DATE);
Correct
Correct
3. Which statement about table and column names is true? Mark for Review
(1) Points
Table and column names must begin with a letter. (*)
Table and column names can begin with a letter or a number.
Table and column names cannot include special characters.
If any character other than letters or numbers is used in a table or column
name, the name must be enclosed in double quotation marks.
Correct
Correct
Page 37
Final Exam - Database Programming with SQL
5. Evaluate this CREATE TABLE statement:
CREATE TABLE line_item ( line_item_id NUMBER(9), order_id NUMBER(9), product_id
NUMBER(9));
You are a member of the SYSDBA role, but are not logged in as SYSDBA. You issue this
CREATE TABLE statement.
Which statement is true?
Mark for Review
(1) Points
Correct
Section 8 Lesson 2
(Answer all questions in this section)
6. The SPEED_TIME column should store a fractional second value. Which data type
should you use? Mark for Review
(1) Points
DATE
DATETIME
TIMESTAMP (*)
Correct
7. To store time with fractions of seconds, which datatype should be used for a
table column? Mark for Review
(1) Points
DATE
TIMESTAMP (*)
Correct
8. You are designing a table for the Sales department. You need to include a
column that contains each sales total. Which data type should you specify for this
column? Mark for Review
(1) Points
Page 38
Final Exam - Database Programming with SQL
CHAR
DATE
NUMBER (*)
VARCHAR2
Correct
Correct
Correct
Page 1 of 10
Page 39
Final Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 2
(Answer all questions in this section)
11. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
(sales_id NUMBER,
customer_id NUMBER,
employee_id NUMBER,
sale_date TIMESTAMP WITH LOCAL TIME ZONE,
sale_amount NUMBER(7,2));
Correct
12. Data in the RESPONSE_TIME column needs to be stored in days, hours, minutes
and seconds. Which data type should you use? Mark for Review
(1) Points
DATETIME
TIMESTAMP
INTERVAL YEAR TO MONTH
INTERVAL DAY TO SECOND (*)
Correct
Section 8 Lesson 3
(Answer all questions in this section)
13. Which command could you use to quickly remove all data from the rows in a
table without deleting the table itself? Mark for Review
(1) Points
ALTER TABLE
Page 40
Final Exam - Database Programming with SQL
DROP TABLE
MODIFY
TRUNCATE TABLE (*)
Correct
14. Which statement about decreasing the width of a column is true? Mark for
Review
(1) Points
When a character column contains data, you cannot decrease the width of the
column.
When a character column contains data, you can decrease the width of the column
without any restrictions.
When a character column contains data, you can decrease the width of the column
if the existing data does not violate the new size. (*)
You cannot decrease the width of a character column unless the table in which
the column resides is empty.
Correct
You can issue this statement to retain the structure of the employee table. (*)
Correct
Frees the disk space used by the data in the FAX column
Prevents data in the FAX column from being displayed, by performing a logical
Page 41
Final Exam - Database Programming with SQL
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
Correct
Correct
19. You need to remove all the data in the SCHEDULE table, the structure of the
table, and the indexes associated with the table. Which statement should you use?
Page 42
Final Exam - Database Programming with SQL
Mark for Review
(1) Points
DROP TABLE (*)
TRUNCATE TABLE
ALTER TABLE
DELETE TABLE
Correct
Correct
Page 2 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 3
(Answer all questions in this section)
The TEAMS table is currently empty. You need to allow users to include text
characters in the manager identification values. Which statement should you use to
implement this?
Mark for Review
(1) Points
Correct
23. Comments on tables and columns can be stored for documentation by: Mark for
Review
(1) Points
Correct
Page 44
Final Exam - Database Programming with SQL
Section 9 Lesson 1
(Answer all questions in this section)
24. Which two statements about NOT NULL constraints are true? (Choose two) Mark
for Review
(1) Points
(Choose all correct answers)
The Oracle Server creates a name for an unnamed NOT NULL constraint. (*)
A NOT NULL constraint can be defined at either the table or column level.
The NOT NULL constraint requires that every value in a column be unique.
Columns without the NOT NULL constraint can contain null values by default. (*)
You CANNOT add a NOT NULL constraint to an existing column using the ALTER TABLE
ADD CONSTRAINT statement.using the ALTER TABLE statement.
Correct
25. A table can only have one unique key constraint defined. True or False? Mark
for Review
(1) Points
True
False (*)
Correct
26. Constraints can be added at which two levels? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
Null Field
Table (*)
Row
Dictionary
Column (*)
Correct
27. You need to ensure that the LAST_NAME column only contains certain character
values. No numbers or special characters are allowed.
Which type of constraint should you define on the LAST_NAME column? Mark for Review
(1) Points
CHECK (*)
UNIQUE
Page 45
Final Exam - Database Programming with SQL
NOT NULL
PRIMARY KEY
Correct
28. Which statement about the NOT NULL constraint is true? Mark for Review
(1) Points
The NOT NULL constraint must be defined at the column level. (*)
The NOT NULL constraint can be defined at either the column level or the table
level.
The NOT NULL constraint requires a column to contain alphanumeric values.
The NOT NULL constraint prevents a column from containing alphanumeric values.
Correct
29. You need to ensure that each value in the SEAT_ID column is unique or null.
Which constraint should you define on the SEAT_ID column? Mark for Review
(1) Points
CHECK
UNIQUE (*)
NOT NULL
PRIMARY KEY
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. Which type of constraint by default requires that a column be both unique and
not null? Mark for Review
(1) Points
FOREIGN KEY
PRIMARY KEY (*)
UNIQUE
CHECK
Correct
Page 46
Final Exam - Database Programming with SQL
Page 3 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 9 Lesson 2
(Answer all questions in this section)
31. When creating the EMPLOYEES table, which clause could you use to ensure that
salary values are 1000.00 or more? Mark for Review
(1) Points
Correct
32. When creating a referential constraint, which keyword(s) identifies the table
and column in the parent table? Mark for Review
(1) Points
FOREIGN KEY
REFERENCES (*)
ON DELETE CASCADE
Correct
33. How many PRIMARY KEY constraints can be created for each table? Mark for
Review
(1) Points
none
one or two
unlimited
Page 47
Final Exam - Database Programming with SQL
Correct
34. Which statement about a foreign key constraint is true? Mark for Review
(1) Points
A foreign key value cannot be null.
A foreign key value must be unique.
A foreign key value must match an existing value in the parent table.
A foreign key value must either be null or match an existing value in the parent
table. (*)
Correct
Which CREATE TABLE statement should you use to create the DONATIONS table?
Mark for Review
(1) Points
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER, amount_paid NUMBER,
payment_dt DATE);
Correct
36. Which statement about a FOREIGN KEY constraint is true? Mark for Review
Page 48
Final Exam - Database Programming with SQL
(1) Points
An index is automatically created for a FOREIGN KEY constraint.
A FOREIGN KEY constraint allows the constrained column to contain values that
exist in the primary key column of the parent table. (*)
Correct
37. You need to create the PROJECT_HIST table. The table must meet these
requirements:
The table must contain the EMPLOYEE_ID and TASKED_HOURS columns for numeric data.
The table must contain the START_DATE and END_DATE column for date values.
The table must contain the HOURLY_RATE and PROJECT_COST columns for numeric data
with precision and scale of 5,2 and 10,2 respectively.
The table must have a composite primary key on the EMPLOYEE_ID and START_DATE
columns.
Evaluate this CREATE TABLE statement:
CREATE TABLE project_hist
( employee_id NUMBER,
start_date DATE,
end_date DATE,
tasked_hours NUMBER,
hourly_rate NUMBER(5,2),
project_cost NUMBER(10,2),
CONSTRAINT project_hist_pk PRIMARY KEY(employee_id, start_date));
How many of the requirements does the CREATE TABLE statement satisfy?
Mark for Review
(1) Points
None of the four requirements
All four of the requirements (*)
Only three of the requirements
Only two of the requirements
Correct
Section 9 Lesson 3
(Answer all questions in this section)
38. Which statement should you use to add a FOREIGN KEY constraint to the DEPT_ID
column in the EMPLOYEE table to refer to the ID column in the DEPARTMENT table?
Mark for Review
Page 49
Final Exam - Database Programming with SQL
(1) Points
ALTER TABLE employee
MODIFY COLUMN dept_id_fk FOREIGN KEY (dept_id) REFERENCES department(id);
Correct
Correct
You need to disable the FOREIGN KEY constraint. Which statement should you use?
Mark for Review
(1) Points
ALTER TABLE line_item DISABLE CONSTRAINT product_id_fk; (*)
ALTER TABLE line_item DROP CONSTRAINT product_id_fk;
ALTER TABLE line_item ENABLE CONSTRAINT product_id_fk;
Correct
Page 4 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 9 Lesson 3
(Answer all questions in this section)
41. You need to add a PRIMARY KEY constraint on the EMP_ID column of the EMPLOYEE
table. Which ALTER TABLE statement should you use? Mark for Review
(1) Points
ALTER TABLE employee
ADD PRIMARY KEY (emp_id);
ALTER TABLE
ADD CONSTRAINT emp_emp_id_pk PRIMARY KEY employee(emp_id);
(*)
Correct
42. You can view the columns used in a constraint defined for a specific table by
looking at which data dictionary table? Mark for Review
(1) Points
USER_CONS_COLUMNS (*)
CONSTRAINTS_ALL_COLUMNS
SYS_DATA_DICT_COLUMNS
US_CON_SYS
Correct
43. You disabled the EMPLOYEE_ID_PK PRIMARY KEY constraint on the ID column in
the EMPLOYEE table and imported 100 records. You need to enable the constraint and
verify that the new and existing ID column values do not violate the PRIMARY KEY
constraint. Evaluate this statement:
ALTER TABLE inventory
ENABLE employee_id_pk;
Which statement is true?
Mark for Review
(1) Points
The statement will achieve the desired result.
The statement will execute, but will ensure that the new ID values are unique.
The statement will execute, but will not verify that the existing values are
unique.
The statement will NOT execute because it contains a syntax error. (*)
Correct
44. You need to add a PRIMARY KEY to the DEPARTMENT table. Which statement should
you use? Mark for Review
(1) Points
ALTER TABLE department ADD PRIMARY KEY dept_id_pk (dept_id);
ALTER TABLE department ADD CONSTRAINT dept_id_pk PK (dept_id);
ALTER TABLE department ADD CONSTRAINT dept_id_pk PRIMARY KEY (dept_id); (*)
ALTER TABLE department ADD CONSTRAINT PRIMARY KEY dept_id_pk (dept_id);
Correct
Page 52
Final Exam - Database Programming with SQL
45. You want to disable the FOREIGN KEY constraint that is defined in the
EMPLOYEES table on the DEPT_ID column. The constraint is referenced by the name
FK_DEPT_ID_01. Which statement should you issue? Mark for Review
(1) Points
ALTER TABLE employees DISABLE 'fk_dept_id_01';
ALTER TABLE employees DISABLE CONSTRAINT 'fk_dept_id_01';
ALTER TABLE employees DISABLE fk_dept_id_01;
ALTER TABLE employees DISABLE CONSTRAINT fk_dept_id_01; (*)
Correct
Correct
Correct
Section 10 Lesson 1
(Answer all questions in this section)
48. Evaluate this CREATE VIEW statement:
CREATE VIEW emp_view
AS SELECT SUM(salary) FROM employee;
You can update any data in the EMPLOYEE table using the EMP_VIEW view.
You can delete records from the EMPLOYEE table using the EMP_VIEW view.
You can update only the SALARY column in the EMPLOYEE table using the EMP_VIEW
view.
Correct
Correct
50. 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 a stored procedure.
Page 54
Final Exam - Database Programming with SQL
Create a view. (*)
Create a subquery.
Create a trigger.
Correct
Page 5 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 10 Lesson 1
(Answer all questions in this section)
51. Which option would you use to modify a view rather than dropping it and
recreating it? Mark for Review
(1) Points
FORCE
NOFORCE
CREATE OR REPLACE (*)
WITH ADMIN OPTION
Correct
52. 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 provide data independence for ad hoc users and application programs. One
view can be used to retrieve data from several tables. Views can be used to provide
data security. (*)
Views are used when you only want to restrict DML operations using a WITH CHECK
OPTION.
Views are not valid unless you have more than one user.
Correct
Page 55
Final Exam - Database Programming with SQL
53. In order to query a database using a view, which of the following statements
applies? Mark for Review
(1) Points
Use special VIEWSELECT Keyword
You can retrieve data from a view as you would from any table. (*)
You can never see all the rows in the table through the view.
The tables you are selecting from can be empty, yet the view still returns the
original data from those tables.
Correct
54. Which keyword(s) would you include in a CREATE VIEW statement 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
55. 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
You must create the SALES table before creating the view.
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. (*)
Correct
Section 10 Lesson 2
(Answer all questions in this section)
56. You need to create a new view on the EMPLOYEE table to update salary
information. You need to ensure that DML operations through the view do not change
the result set of the view. Which clause should include in the CREATE VIEW
statement? Mark for Review
(1) Points
FORCE
Page 56
Final Exam - Database Programming with SQL
OR REPLACE
WITH READ ONLY
WITH CHECK OPTION (*)
Correct
57. What is the purpose of including the WITH CHECK OPTION clause 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 that data in rows not visible through the view are changed or to
make sure no rows returned by the view are updated outside the scope of the view.
(*)
Correct
58. You cannot insert data through a view if the view includes ______. Mark for
Review
(1) Points
a WHERE clause
a join
a column alias
a GROUP BY clause (*)
Correct
59. Which of the following is TRUE regarding simple views? Mark for Review
(1) Points
They derive data from many tables, so they typically contain joins.
They contain functions or groups of data
They can perform DML operations through the view (*)
They are not stored in the Data Dictionary
Correct
60. You cannot create a view if the view subquery contains an inline view. True
or False? Mark for Review
(1) Points
Page 57
Final Exam - Database Programming with SQL
True
False (*)
Correct
Page 6 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 10 Lesson 2
(Answer all questions in this section)
61. 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 e, departments d, job_grades
WHERE e.department_id equals d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
Correct
62. 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 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.
You can perform DML operations on a view that contains columns defined by
expressions, such as COST + 1.
Correct
Section 10 Lesson 3
(Answer all questions in this section)
63. 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 balance
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 is 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
64. An "inline view" is an unnamed select statement found: Mark for Review
(1) Points
Page 59
Final Exam - Database Programming with SQL
In the user_views data dictionary view
In a special database column of a users table
Enclosed in parenthesis within the select list of a surrounding query
Enclosed in parenthesis within the from clause of a surrounding query (*)
Correct
65. Which statement about an inline view is true? Mark for Review
(1) Points
An inline view is a schema object.
An inline view is a subquery with an alias. (*)
An inline view is a complex view.
An inline view can be used to perform DML operations.
Correct
The 25 greatest new balance values were displayed from the highest to the
lowest.
The statement failed to execute because the ORDER BY does NOT use the Top-n
column.
Correct
Page 60
Final Exam - Database Programming with SQL
67. 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
Section 11 Lesson 2
(Answer all questions in this section)
68. You created the LOCATION_ID_SEQ sequence to generate sequential values for
the LOCATION_ID column in the MANUFACTURERS table. You issue this statement:
ALTER TABLE manufacturers
MODIFY (location_id NUMBER(6));
Correct
Page 61
Final Exam - Database Programming with SQL
Create a sequence. (*)
Correct
Correct
Page 7 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 11 Lesson 2
(Answer all questions in this section)
71. Which pseudocolumn returns the latest value supplied by a sequence? Mark for
Review
(1) Points
NEXTVAL
CURRVAL (*)
CURRENT
NEXT
Correct
Correct
Section 11 Lesson 3
(Answer all questions in this section)
73. 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
Correct
Correct
Page 63
Final Exam - Database Programming with SQL
75. 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 query? Mark for
Review
(1) Points
USER_INDEXES
USER_TABLES
USER_OBJECTS
USER_IND_COLUMNS (*)
Correct
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of the
CLIENTS table. You issue this statement:
Correct
It allows only the user CHAN to access TESTING using the synonym.
It eliminates the need for all users to qualify TESTING with its schema. (*)
Correct
Page 64
Final Exam - Database Programming with SQL
78. You create a table named CUSTOMERS and define a PRIMARY KEY constraint on the
CUST_ID column. Which actions occur automatically? Mark for Review
(1) Points
A CHECK constraint is defined on the CUST_ID column.
A trigger is created that will prevent NULL values from being accepted in the
CUST_ID column.
A unique index is created on the CUST_ID column. (*)
A sequence is created that will generate a unique value in the CUST_ID column
for each row that is inserted into the CUSTOMERS table.
Correct
79. What is the correct syntax for creating a synonym d_sum for the view
DEPT_SUM_VU? Mark for Review
(1) Points
CREATE SYNONYM d_sum
ON dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
Correct
80. What is the correct syntax for creating an index? Mark for Review
(1) Points
CREATE INDEX index_name ON table_name(column_name); (*)
CREATE INDEX on table_name(column_name);
CREATE index_name INDEX ON table_name.column_name;
CREATE OR REPLACE INDEX index_name ON table_name(column_name);
Correct
Page 8 of 10
Page 65
Final Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 11 Lesson 3
(Answer all questions in this section)
81. 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
83. What would you create to make the following statement execute faster?
SELECT *
FROM employees
WHERE LOWER(last_name) = 'chang';
Mark for Review
(1) Points
A synonym.
A function_based index. (*)
Page 66
Final Exam - Database Programming with SQL
A composite index.
Nothing; the performance of this statement cannot be improved.
Correct
84. You want to create a composite index on the FIRST_NAME and LAST_NAME columns
of the EMPLOYEES table. Which SQL statement will accomplish this task? Mark for
Review
(1) Points
CREATE INDEX fl_idx ON employees(first_name || last_name);
Correct
85. Which of the following SQL statements will display the index name, table
name, and the uniqueness of the index for all indexes on the EMPLOYEES table? Mark
for Review
(1) Points
CREATE index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
Correct
Page 67
Final Exam - Database Programming with SQL
Section 12 Lesson 2
(Answer all questions in this section)
86. You want to grant user BOB the ability to change other users' 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
87. 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
88. You grant user AMY the CREATE SESSION privilege. Which type of privilege have
you granted to AMY? Mark for Review
(1) Points
A system privilege (*)
An object privilege
A user privilege
An access privilege
Correct
89. User JAMES has created a CUSTOMERS table and wants to allow 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;
Page 68
Final Exam - Database Programming with SQL
Correct
90. You are the database administrator. You want to create a new user JONES with
a password of MARK, and allow this user to create his own tables. Which of the
following should you execute? Mark for Review
(1) Points
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE TABLE TO jones;
Correct
Page 9 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 12 Lesson 2
(Answer all questions in this section)
91. Evaluate this statement: ALTER USER bob IDENTIFIED BY jim; Which statement
about the result of executing this statement is true? Mark for Review
(1) Points
Correct
Page 69
Final Exam - Database Programming with SQL
92. Which of the following are object privileges? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
SELECT (*)
SELECT ANY TABLE
CREATE TABLE
INSERT (*)
Correct
Section 12 Lesson 3
(Answer all questions in this section)
93. User CRAIG creates a view named INVENTORY_V, which is based on the INVENTORY
table. CRAIG wants to make this view available for querying to all database users.
Which of the following actions should CRAIG perform? Mark for Review
(1) Points
He is not required to take any action because, by default, all database users
can automatically access views.
He should assign the SELECT privilege to all database users for the INVENTORY
table.
He should assign the SELECT privilege to all database users for INVENTORY_V
view. (*)
He must grant each user the SELECT privilege on both the INVENTORY table and
INVENTORY_V view.
Correct
Correct
95. You need to grant user BOB SELECT privileges on the EMPLOYEE table. You want
to allow BOB to grant this privileges to other users. Which statement should you
use? Mark for Review
Page 70
Final Exam - Database Programming with SQL
(1) Points
GRANT SELECT ON employee TO bob WITH GRANT OPTION; (*)
GRANT SELECT ON employee TO PUBLIC WITH GRANT OPTION;
GRANT SELECT ON employee TO bob
GRANT SELECT ON employee TO bob WITH ADMIN OPTION;
Correct
96. Which of the following best describes the purpose of the REFERENCES object
privilege on a table? Mark for Review
(1) Points
It allows a user's session to read from the table but only so that foreign key
constraints can be checked. (*)
It allows a user to refer to the table in a SELECT statement.
It allows a user to create foreign key constraints on the table.
It allows the user to create new tables which contain the same data as the
referenced table.
Correct
97. When granting an object privilege, which option would you 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
98. Which of the following simplifies the administration of privileges? Mark for
Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
Page 71
Final Exam - Database Programming with SQL
Section 14 Lesson 1
(Answer all questions in this section)
99. Steven King's row in the EMPLOYEES table has EMPLOYEE_ID = 100 and SALARY =
24000. A user issues the following statements in the order shown:
UPDATE employees
SET salary = salary * 2
WHERE employee_id = 100;
COMMIT;
UPDATE employees
SET salary = 30000
WHERE employee_id = 100;
The user's database session now ends abnormally. What is now King's salary in the
table?
Mark for Review
(1) Points
48000 (*)
30000
24000
78000
Correct
100. Table MYTAB contains only one column of datatype CHAR(1). A user executes
the following statements in the order shown.
INSERT INTO mytab VALUES ('A');
INSERT INTO mytab VALUES ('B');
COMMIT;
INSERT INTO mytab VALUES ('C');
ROLLBACK;
Correct
Page 10 of 10
Page 72
Final Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 1
1. Which of the following SQL statements will create a table called Birthdays
with three columns for storing employee number, name and date of birth? Mark for
Review
(1) Points
CREATE TABLE Birthdays (Empno NUMBER, Empname CHAR(20), Birthdate DATE); (*)
CREATE TABLE Birthdays (Empno NUMBER, Empname CHAR(20), Date of Birth DATE);
Correct
With a CREATE TABLE statement, a table will always be created in the current
user's schema.
Correct
3. Which statement about table and column names is true? Mark for Review
(1) Points
Correct
1NUMBER
Page 73
Final Exam - Database Programming with SQL
NUMBER
NUMBER_1$ (*)
1_NUMBER#
Correct
You are a member of the SYSDBA role, but are not logged in as SYSDBA. You issue this
CREATE TABLE statement.
Which statement is true?
Mark for Review
(1) Points
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
Correct
Section 8 Lesson 2
(Answer all questions in this section)
6. The SPEED_TIME column should store a fractional second value. Which data type
should you use? Mark for Review
(1) Points
DATE
DATETIME
TIMESTAMP (*)
INTERVAL DAY TO SECOND
Correct
7. To store time with fractions of seconds, which datatype should be used for a
table column? Mark for Review
(1) Points
DATE
INTERVAL YEAR TO MONTH
TIMESTAMP (*)
Page 74
Final Exam - Database Programming with SQL
INTERVAL DAY TO SECOND
Correct
8. You are designing a table for the Sales department. You need to include a
column that contains each sales total. Which data type should you specify for this
column? Mark for Review
(1) Points
CHAR
DATE
NUMBER (*)
VARCHAR2
Correct
Correct
Correct
Page 1 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 2
(Answer all questions in this section)
11. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
(sales_id NUMBER,
customer_id NUMBER,
employee_id NUMBER,
sale_date TIMESTAMP WITH LOCAL TIME ZONE,
sale_amount NUMBER(7,2));
Which statement about the SALE_DATE column is true?
Mark for Review
(1) Points
Data will be normalized to the client time zone.
Data stored will not include seconds.
Data will be stored using a fractional seconds precision of 5.
Data stored in the column will be returned in the database's local time zone.
(*)
Correct
12. Data in the RESPONSE_TIME column needs to be stored in days, hours, minutes
and seconds. Which data type should you use? Mark for Review
(1) Points
DATETIME
TIMESTAMP
INTERVAL YEAR TO MONTH
INTERVAL DAY TO SECOND (*)
Correct
Page 76
Final Exam - Database Programming with SQL
Section 8 Lesson 3
(Answer all questions in this section)
13. Which command could you use to quickly remove all data from the rows in a
table without deleting the table itself? Mark for Review
(1) Points
ALTER TABLE
DROP TABLE
MODIFY
TRUNCATE TABLE (*)
Correct
14. Which statement about decreasing the width of a column is true? Mark for
Review
(1) Points
When a character column contains data, you cannot decrease the width of the
column.
When a character column contains data, you can decrease the width of the column
without any restrictions.
When a character column contains data, you can decrease the width of the column
if the existing data does not violate the new size. (*)
You cannot decrease the width of a character column unless the table in which
the column resides is empty.
Correct
You can issue this statement to retain the structure of the employee table. (*)
You can reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Correct
Correct
You need to reduce the precision of the AMOUNT_PLEDGED column to 5 with a scale of 2
and ensure that when inserting a row into the DONATIONS table without a value for
the AMOUNT_PLEDGED column, a price of $10.00 will automatically be inserted. The
DONATIONS table currently contains NO records. Which statement is true?
Mark for Review
(1) Points
Both changes can be accomplished with one ALTER TABLE statement. (*)
You must drop and recreate the DONATIONS table to achieve these results.
You must use the ADD OR REPLACE option to achieve these results.
Correct
Which statement should you use to increase the LAST_NAME column length to 35 if the
column currently contains 200 records?
Mark for Review
(1) Points
ALTER employee TABLE ALTER COLUMN (last_name VARCHAR2(35));
ALTER TABLE employee RENAME last_name VARCHAR2(35);
Page 78
Final Exam - Database Programming with SQL
ALTER TABLE employee MODIFY (last_name VARCHAR2(35)); (*)
Correct
19. You need to remove all the data in the SCHEDULE table, the structure of the
table, and the indexes associated with the table. Which statement should you use?
Mark for Review
(1) Points
DROP TABLE (*)
TRUNCATE TABLE
ALTER TABLE
DELETE TABLE
Correct
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is not
empty. (*)
Correct
Page 2 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 3
(Answer all questions in this section)
21. Evaluate this statement:
ALTER TABLE inventory
MODIFY backorder_amount NUMBER(8,2);
Which task will this statement accomplish?
Mark for Review
(1) Points
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8 2)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER
Correct
23. Comments on tables and columns can be stored for documentation by: Mark for
Review
(1) Points
Embedding /* comment */ within the definition of the table.
Using the ALTER TABLE CREATE COMMENT syntax
Page 80
Final Exam - Database Programming with SQL
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. Which two statements about NOT NULL constraints are true? (Choose two) Mark
for Review
(1) Points
(Choose all correct answers)
The Oracle Server creates a name for an unnamed NOT NULL constraint. (*)
A NOT NULL constraint can be defined at either the table or column level.
The NOT NULL constraint requires that every value in a column be unique.
Columns without the NOT NULL constraint can contain null values by default. (*)
You CANNOT add a NOT NULL constraint to an existing column using the ALTER TABLE
ADD CONSTRAINT statement.using the ALTER TABLE statement.
Correct
25. A table can only have one unique key constraint defined. True or False? Mark
for Review
(1) Points
True
False (*)
Correct
26. Constraints can be added at which two levels? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
Null Field
Table (*)
Row
Dictionary
Column (*)
Page 81
Final Exam - Database Programming with SQL
Correct
27. You need to ensure that the LAST_NAME column only contains certain character
values. No numbers or special characters are allowed.
Which type of constraint should you define on the LAST_NAME column? Mark for Review
(1) Points
CHECK (*)
UNIQUE
NOT NULL
PRIMARY KEY
Correct
28. Which statement about the NOT NULL constraint is true? Mark for Review
(1) Points
The NOT NULL constraint must be defined at the column level. (*)
The NOT NULL constraint can be defined at either the column level or the table
level.
The NOT NULL constraint requires a column to contain alphanumeric values.
The NOT NULL constraint prevents a column from containing alphanumeric values.
Correct
29. You need to ensure that each value in the SEAT_ID column is unique or null.
Which constraint should you define on the SEAT_ID column? Mark for Review
(1) Points
CHECK
UNIQUE (*)
NOT NULL
PRIMARY KEY
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. Which type of constraint by default requires that a column be both unique and
not null? Mark for Review
(1) Points
FOREIGN KEY
Page 82
Final Exam - Database Programming with SQL
PRIMARY KEY (*)
UNIQUE
CHECK
Correct
Page 3 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 9 Lesson 2
(Answer all questions in this section)
31. When creating the EMPLOYEES table, which clause could you use to ensure that
salary values are 1000.00 or more? Mark for Review
(1) Points
CONSTRAINT CHECK salary > 1000
CHECK CONSTRAINT (salary > 1000)
CONSTRAINT employee_salary_min CHECK salary > 1000
Correct
32. When creating a referential constraint, which keyword(s) identifies the table
and column in the parent table? Mark for Review
(1) Points
FOREIGN KEY
REFERENCES (*)
ON DELETE CASCADE
ON DELETE SET NULL
Correct
33. How many PRIMARY KEY constraints can be created for each table? Mark for
Page 83
Final Exam - Database Programming with SQL
Review
(1) Points
none
one and only one (*)
one or two
unlimited
Correct
34. Which statement about a foreign key constraint is true? Mark for Review
(1) Points
A foreign key value cannot be null.
A foreign key value must be unique.
A foreign key value must match an existing value in the parent table.
A foreign key value must either be null or match an existing value in the parent
table. (*)
Correct
Correct
36. Which statement about a FOREIGN KEY constraint is true? Mark for Review
(1) Points
An index is automatically created for a FOREIGN KEY constraint.
A FOREIGN KEY constraint allows the constrained column to contain values that
exist in the primary key column of the parent table. (*)
A FOREIGN KEY constraint requires that a list of allowed values be checked
before a value can be added to the constrained column.
A FOREIGN KEY column can have a different data type from the primary key column
that it references.
Correct
37. You need to create the PROJECT_HIST table. The table must meet these
requirements:
The table must contain the EMPLOYEE_ID and TASKED_HOURS columns for numeric data.
The table must contain the START_DATE and END_DATE column for date values.
The table must contain the HOURLY_RATE and PROJECT_COST columns for numeric data
with precision and scale of 5,2 and 10,2 respectively.
The table must have a composite primary key on the EMPLOYEE_ID and START_DATE
columns.
Evaluate this CREATE TABLE statement:
CREATE TABLE project_hist
( employee_id NUMBER,
start_date DATE,
end_date DATE,
tasked_hours NUMBER,
hourly_rate NUMBER(5,2),
project_cost NUMBER(10,2),
CONSTRAINT project_hist_pk PRIMARY KEY(employee_id, start_date));
How many of the requirements does the CREATE TABLE statement satisfy?
Mark for Review
(1) Points
None of the four requirements
All four of the requirements (*)
Only three of the requirements
Only two of the requirements
Page 85
Final Exam - Database Programming with SQL
Correct
Section 9 Lesson 3
(Answer all questions in this section)
38. Which statement should you use to add a FOREIGN KEY constraint to the DEPT_ID
column in the EMPLOYEE table to refer to the ID column in the DEPARTMENT table?
Mark for Review
(1) Points
ALTER TABLE employee
MODIFY COLUMN dept_id_fk FOREIGN KEY (dept_id) REFERENCES department(id);
Correct
SUPPLIER
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
Evaluate this statement:
ALTER TABLE suppliers
DISABLE CONSTRAINT supplier_id_pk CASCADE;
Page 86
Final Exam - Database Programming with SQL
To remove all constraint references to SUPPLIERS table
Correct
Correct
Page 4 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 9 Lesson 3
(Answer all questions in this section)
41. You need to add a PRIMARY KEY constraint on the EMP_ID column of the EMPLOYEE
table. Which ALTER TABLE statement should you use? Mark for Review
(1) Points
ALTER TABLE employee
ADD PRIMARY KEY (emp_id);
Page 87
Final Exam - Database Programming with SQL
ALTER TABLE
ADD CONSTRAINT emp_emp_id_pk PRIMARY KEY employee(emp_id);
(*)
Correct
42. You can view the columns used in a constraint defined for a specific table by
looking at which data dictionary table? Mark for Review
(1) Points
USER_CONS_COLUMNS (*)
CONSTRAINTS_ALL_COLUMNS
SYS_DATA_DICT_COLUMNS
US_CON_SYS
Correct
43. You disabled the EMPLOYEE_ID_PK PRIMARY KEY constraint on the ID column in
the EMPLOYEE table and imported 100 records. You need to enable the constraint and
verify that the new and existing ID column values do not violate the PRIMARY KEY
constraint. Evaluate this statement:
ALTER TABLE inventory
ENABLE employee_id_pk;
Which statement is true?
Mark for Review
(1) Points
The statement will execute, but will ensure that the new ID values are unique.
The statement will execute, but will not verify that the existing values are
unique.
The statement will NOT execute because it contains a syntax error. (*)
Correct
44. You need to add a PRIMARY KEY to the DEPARTMENT table. Which statement should
you use? Mark for Review
(1) Points
ALTER TABLE department ADD CONSTRAINT dept_id_pk PRIMARY KEY (dept_id); (*)
ALTER TABLE department ADD CONSTRAINT PRIMARY KEY dept_id_pk (dept_id);
Correct
45. You want to disable the FOREIGN KEY constraint that is defined in the
EMPLOYEES table on the DEPT_ID column. The constraint is referenced by the name
FK_DEPT_ID_01. Which statement should you issue? Mark for Review
(1) Points
ALTER TABLE employees DISABLE 'fk_dept_id_01';
ALTER TABLE employees DISABLE CONSTRAINT 'fk_dept_id_01';
ALTER TABLE employees DISABLE fk_dept_id_01;
ALTER TABLE employees DISABLE CONSTRAINT fk_dept_id_01; (*)
Correct
Correct
Correct
Section 10 Lesson 1
(Answer all questions in this section)
48. Evaluate this CREATE VIEW statement:
CREATE VIEW emp_view
AS SELECT SUM(salary) FROM employee;
Which statement is true?
Mark for Review
(1) Points
You cannot update data in the EMPLOYEE table using the EMP_VIEW view. (*)
You can update any data in the EMPLOYEE table using the EMP_VIEW view.
You can delete records from the EMPLOYEE table using the EMP_VIEW view.
You can update only the SALARY column in the EMPLOYEE table using the EMP_VIEW
view.
Correct
nested
simple
inline
complex (*)
Correct
Page 90
Final Exam - Database Programming with SQL
50. 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 a stored procedure.
Create a view. (*)
Create a subquery.
Create a trigger.
Correct
Page 5 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 10 Lesson 1
(Answer all questions in this section)
51. Which option would you use to modify a view rather than dropping it and
recreating it? Mark for Review
(1) Points
FORCE
NOFORCE
Correct
52. 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 provide data independence for ad hoc users and application programs. One
Page 91
Final Exam - Database Programming with SQL
view can be used to retrieve data from several tables. Views can be used to provide
data security. (*)
Views are used when you only want to restrict DML operations using a WITH CHECK
OPTION.
Views are not valid unless you have more than one user.
Correct
53. 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. (*)
You can never see all the rows in the table through the view.
The tables you are selecting from can be empty, yet the view still returns the
original data from those tables.
Correct
54. Which keyword(s) would you include in a CREATE VIEW statement to create the
view regardless of whether or not the base table exists? Mark for Review
(1) Points
FORCE (*)
NOFORCE
OR REPLACE
Correct
55. 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
You must create the SALES table before creating the view.
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. (*)
Correct
Page 92
Final Exam - Database Programming with SQL
Section 10 Lesson 2
(Answer all questions in this section)
56. You need to create a new view on the EMPLOYEE table to update salary
information. You need to ensure that DML operations through the view do not change
the result set of the view. Which clause should include in the CREATE VIEW
statement? Mark for Review
(1) Points
FORCE
OR REPLACE
WITH READ ONLY
WITH CHECK OPTION (*)
Correct
57. What is the purpose of including the WITH CHECK OPTION clause 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 that data in rows not visible through the view are changed or to
make sure no rows returned by the view are updated outside the scope of the view.
(*)
Correct
58. You cannot insert data through a view if the view includes ______. Mark for
Review
(1) Points
a WHERE clause
a join
a column alias
a GROUP BY clause (*)
Correct
59. Which of the following is TRUE regarding simple views? Mark for Review
(1) Points
They derive data from many tables, so they typically contain joins.
They contain functions or groups of data
Page 93
Final Exam - Database Programming with SQL
They can perform DML operations through the view (*)
Correct
60. You cannot create a view if the view subquery contains an inline view. True
or False? Mark for Review
(1) Points
True
False (*)
Correct
Page 6 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 10 Lesson 2
(Answer all questions in this section)
61. 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 e, departments d, job_grades
WHERE e.department_id equals d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
Correct
62. Which statement about performing DML operations on a view is true? Mark for
Review
(1) Points
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.
You can perform DML operations on a view that contains columns defined by
expressions, such as COST + 1.
Correct
Section 10 Lesson 3
(Answer all questions in this section)
Page 95
Final Exam - Database Programming with SQL
outer query: ORDER BY new_balance DESC
inner query: SELECT customer_id, new_balance ROWNUM
Correct
64. 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 parenthesis within the select list of a surrounding query
Enclosed in parenthesis within the from clause of a surrounding query (*)
Correct
65. Which statement about an inline view is true? Mark for Review
(1) Points
An inline view is a schema object.
An inline view is a subquery with an alias. (*)
An inline view is a complex view.
An inline view can be used to perform DML operations.
Correct
Page 96
Final Exam - Database Programming with SQL
The 25 greatest new balance values were displayed from the highest to the
lowest.
The statement failed to execute because the ORDER BY does NOT use the Top-n
column.
Correct
A complex view
A simple view
A hierarchical view
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. You created the LOCATION_ID_SEQ sequence to generate sequential values for
the LOCATION_ID column in the MANUFACTURERS table. You issue this statement:
ALTER TABLE manufacturers
MODIFY (location_id NUMBER(6));
Which statement about the LOCATION_ID_SEQ sequence is true?
Mark for Review
(1) Points
The sequence is unchanged. (*)
The sequence is deleted and must be recreated.
The current value of the sequence is reset to zero.
The current value of the sequence is reset to the sequence's START WITH value.
Correct
Do nothing. Oracle automatically generates unique values for columns that are
defined as primary keys.
Create a synonym.
Correct
Correct
Page 7 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 11 Lesson 2
(Answer all questions in this section)
71. Which pseudocolumn returns the latest value supplied by a sequence? Mark for
Review
(1) Points
NEXTVAL
CURRVAL (*)
CURRENT
Page 98
Final Exam - Database Programming with SQL
NEXT
Correct
The minimum value of the LINE_ITEM_ID_SEQ will be the smallest possible integer
value.
Correct
Section 11 Lesson 3
(Answer all questions in this section)
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct
Correct
75. 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 query? Mark for
Review
(1) Points
USER_INDEXES
USER_TABLES
USER_OBJECTS
USER_IND_COLUMNS (*)
Correct
Correct
It eliminates the need for all users to qualify TESTING with its schema. (*)
Correct
78. You create a table named CUSTOMERS and define a PRIMARY KEY constraint on the
CUST_ID column. Which actions occur automatically? Mark for Review
(1) Points
A CHECK constraint is defined on the CUST_ID column.
A trigger is created that will prevent NULL values from being accepted in the
CUST_ID column.
A unique index is created on the CUST_ID column. (*)
A sequence is created that will generate a unique value in the CUST_ID column
for each row that is inserted into the CUSTOMERS table.
Correct
79. What is the correct syntax for creating a synonym d_sum for the view
DEPT_SUM_VU? Mark for Review
(1) Points
CREATE SYNONYM d_sum
ON dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
Correct
80. What is the correct syntax for creating an index? Mark for Review
(1) Points
CREATE INDEX index_name ON table_name(column_name); (*)
CREATE INDEX on table_name(column_name);
Page 101
Final Exam - Database Programming with SQL
CREATE index_name INDEX ON table_name.column_name;
Correct
Page 8 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 11 Lesson 3
(Answer all questions in this section)
Correct
Correct
Page 102
Final Exam - Database Programming with SQL
83. What would you create to make the following statement execute faster?
SELECT *
FROM employees
WHERE LOWER(last_name) = 'chang';
Mark for Review
(1) Points
A synonym.
A function_based index. (*)
A composite index.
Nothing; the performance of this statement cannot be improved.
Correct
84. You want to create a composite index on the FIRST_NAME and LAST_NAME columns
of the EMPLOYEES table. Which SQL statement will accomplish this task? Mark for
Review
(1) Points
CREATE INDEX fl_idx ON employees(first_name || last_name);
Correct
85. Which of the following SQL statements will display the index name, table
name, and the uniqueness of the index for all indexes on the EMPLOYEES table? Mark
for Review
(1) Points
CREATE index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
Page 103
Final Exam - Database Programming with SQL
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. You want to grant user BOB the ability to change other users' 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
87. 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
88. You grant user AMY the CREATE SESSION privilege. Which type of privilege have
you granted to AMY? Mark for Review
(1) Points
A system privilege (*)
An object privilege
A user privilege
An access privilege
Correct
89. User JAMES has created a CUSTOMERS table and wants to allow all other users
Page 104
Final Exam - Database Programming with SQL
to SELECT from it. Which command should JAMES use to do this? Mark for Review
(1) Points
Correct
90. You are the database administrator. You want to create a new user JONES with
a password of MARK, and allow this user to create his own tables. Which of the
following should you execute? Mark for Review
(1) Points
Correct
Page 9 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 12 Lesson 2
(Answer all questions in this section)
91. Evaluate this statement: ALTER USER bob IDENTIFIED BY jim; Which statement
about the result of executing this statement is true? Mark for Review
(1) Points
Page 105
Final Exam - Database Programming with SQL
A new password is assign to user BOB. (*)
A new user JIM is created from user BOB's profile.
The user BOB is assigned the same privileges as user JIM.
The user BOB is renamed and is accessible as user JIM.
Correct
92. Which of the following are object privileges? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
SELECT (*)
SELECT ANY TABLE
CREATE TABLE
INSERT (*)
Correct
Section 12 Lesson 3
(Answer all questions in this section)
93. User CRAIG creates a view named INVENTORY_V, which is based on the INVENTORY
table. CRAIG wants to make this view available for querying to all database users.
Which of the following actions should CRAIG perform? Mark for Review
(1) Points
He is not required to take any action because, by default, all database users
can automatically access views.
He should assign the SELECT privilege to all database users for the INVENTORY
table.
He should assign the SELECT privilege to all database users for INVENTORY_V
view. (*)
He must grant each user the SELECT privilege on both the INVENTORY table and
INVENTORY_V view.
Correct
Page 106
Final Exam - Database Programming with SQL
An ODBC driver
A database link (*)
Correct
95. You need to grant user BOB SELECT privileges on the EMPLOYEE table. You want
to allow BOB to grant this privileges to other users. Which statement should you
use? Mark for Review
(1) Points
GRANT SELECT ON employee TO bob WITH GRANT OPTION; (*)
GRANT SELECT ON employee TO PUBLIC WITH GRANT OPTION;
GRANT SELECT ON employee TO bob
GRANT SELECT ON employee TO bob WITH ADMIN OPTION;
Correct
96. Which of the following best describes the purpose of the REFERENCES object
privilege on a table? Mark for Review
(1) Points
It allows a user's session to read from the table but only so that foreign key
constraints can be checked. (*)
It allows a user to refer to the table in a SELECT statement.
Correct
97. When granting an object privilege, which option would you 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
98. Which of the following simplifies the administration of privileges? Mark for
Review
(1) Points
Page 107
Final Exam - Database Programming with SQL
an index
a view
a trigger
a role (*)
Correct
Section 14 Lesson 1
(Answer all questions in this section)
99. Steven King's row in the EMPLOYEES table has EMPLOYEE_ID = 100 and SALARY =
24000. A user issues the following statements in the order shown:
UPDATE employees
SET salary = salary * 2
WHERE employee_id = 100;
COMMIT;
UPDATE employees
SET salary = 30000
WHERE employee_id = 100;
The user's database session now ends abnormally. What is now King's salary in the
table?
Mark for Review
(1) Points
48000 (*)
30000
24000
78000
Correct
100. Table MYTAB contains only one column of datatype CHAR(1). A user executes
the following statements in the order shown.
INSERT INTO mytab VALUES ('A');
INSERT INTO mytab VALUES ('B');
COMMIT;
INSERT INTO mytab VALUES ('C');
ROLLBACK;
Which rows does the table now contain?
Mark for Review
(1) Points
A, B and C
A and B (*)
C
Page 108
Final Exam - Database Programming with SQL
None of the above
Correct
Page 10 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 1
1. Which CREATE TABLE statement will fail? Mark for Review
(1) Points
CREATE TABLE date_1 (date_1 DATE);
CREATE TABLE date (date_id NUMBER(9)); (*)
CREATE TABLE time (time_id NUMBER(9));
CREATE TABLE time_date (time NUMBER(9));
3. You want to create a table named TRAVEL that is a child of the EMPLOYEES
table. Which of the following statements should you issue? Mark for Review
(1) Points
CREATE TABLE travel (destination_id primary key, departure_date date,
return_date date, emp_id REFERENCES employees (emp_id));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, t.emp_id = e.emp_id);
CREATE TABLE travel (destination_id number primary key, departure_date date,
Page 109
Final Exam - Database Programming with SQL
return_date date, JOIN emp_id number(10) ON employees (emp_id));
4. You want to create a database table that will contain information regarding
products that your company released during 2001. Which name can you assign to the
table that you create? Mark for Review
(1) Points
2001_PRODUCTS
PRODUCTS_2001 (*)
PRODUCTS_(2001)
PRODUCTS--2001
5. Which statement about table and column names is true? Mark for Review
(1) Points
Correct
Section 8 Lesson 2
(Answer all questions in this section)
6. The ELEMENTS column is defined as: NUMBER(6,4) How many digits to the right of
the decimal point are allowed for the ELEMENTS column? Mark for Review
(1) Points
zero
two
four (*)
six
Page 110
Final Exam - Database Programming with SQL
7. You are designing a table for the Human Resources department. This table must
include a column that contains each employee's hire date. Which data type should you
specify for this column? Mark for Review
(1) Points
CHAR
DATE (*)
TIMESTAMP
INTERVAL YEAR TO MONTH
All employee identification values are only 6 digits so the column should be
variable in length.
Today's date should be used if no value is provided for the sale date. (*)
9. To store time with fractions of seconds, which datatype should be used for a
table column? Mark for Review
(1) Points
DATE
TIMESTAMP (*)
10. You are designing a table for the Sales department. You need to include a
column that contains each sales total. Which data type should you specify for this
Page 111
Final Exam - Database Programming with SQL
column? Mark for Review
(1) Points
CHAR
DATE
NUMBER (*)
VARCHAR2
Page 1 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 2
(Answer all questions in this section)
11. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
(sales_id NUMBER,
customer_id NUMBER,
employee_id NUMBER,
sale_date TIMESTAMP WITH LOCAL TIME ZONE,
sale_amount NUMBER(7,2));
Which statement about the SALE_DATE column is true?
Mark for Review
(1) Points
Data stored in the column will be returned in the database's local time zone.
(*)
12. Data in the RESPONSE_TIME column needs to be stored in days, hours, minutes
and seconds. Which data type should you use? Mark for Review
(1) Points
DATETIME
Page 112
Final Exam - Database Programming with SQL
TIMESTAMP
INTERVAL YEAR TO MONTH
INTERVAL DAY TO SECOND (*)
Section 8 Lesson 3
(Answer all questions in this section)
13. You want to issue the following command on a database that includes your
company's inventory information:
ALTER TABLE products
SET UNUSED COLUMN color;
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is not
empty. (*)
Page 113
Final Exam - Database Programming with SQL
Incorrect. Refer to Section 8 Lesson 3
15. Which statement about decreasing the width of a column is true? Mark for
Review
(1) Points
When a character column contains data, you cannot decrease the width of the
column.
When a character column contains data, you can decrease the width of the column
without any restrictions.
When a character column contains data, you can decrease the width of the column
if the existing data does not violate the new size. (*)
You cannot decrease the width of a character column unless the table in which
the column resides is empty.
16. You need to remove all the data in the SCHEDULE table, the structure of the
table, and the indexes associated with the table. Which statement should you use?
Mark for Review
(1) Points
DROP TABLE (*)
TRUNCATE TABLE
ALTER TABLE
DELETE TABLE
Correct
You can produce the same results by issuing the 'DROP TABLE employee' statement.
You can issue this statement to retain the structure of the INVENTORY table. (*)
You can produce the same results by issuing the 'DELETE inventory' statement.
19. You need to change the name of the EMPLOYEE table to the EMP table. Which
statement should you use? Mark for Review
(1) Points
20. You need to remove all the rows from the SALES_HIST table. You want to
release the storage space, but do not want to remove the table structure. Which
statement should you use? Mark for Review
(1) Points
Page 2 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Page 115
Final Exam - Database Programming with SQL
Section 8 Lesson 3
(Answer all questions in this section)
21. Which statement about a column is NOT true? Mark for Review
(1) Points
You can modify the data type of a column if the column contains non-null data.
(*)
You can convert a CHAR data type column to the VARCHAR2 data type.
22. Which command could you use to quickly remove all data from the rows in a
table without deleting the table itself? Mark for Review
(1) Points
ALTER TABLE
DROP TABLE
MODIFY
Both changes can be accomplished with one ALTER TABLE statement. (*)
You must drop and recreate the DONATIONS table to achieve these results.
You must use the ADD OR REPLACE option to achieve these results.
Page 116
Final Exam - Database Programming with SQL
Section 9 Lesson 1
(Answer all questions in this section)
24. Which two statements about NOT NULL constraints are true? (Choose two) Mark
for Review
(1) Points
(Choose all correct answers)
The Oracle Server creates a name for an unnamed NOT NULL constraint. (*)
A NOT NULL constraint can be defined at either the table or column level.
The NOT NULL constraint requires that every value in a column be unique.
Columns without the NOT NULL constraint can contain null values by default. (*)
You CANNOT add a NOT NULL constraint to an existing column using the ALTER TABLE
ADD CONSTRAINT statement.using the ALTER TABLE statement.
25. A table can only have one unique key constraint defined. True or False? Mark
for Review
(1) Points
True
False (*)
Correct
26. You need to ensure that each value in the SEAT_ID column is unique or null.
Which constraint should you define on the SEAT_ID column? Mark for Review
(1) Points
CHECK
UNIQUE (*)
NOT NULL
PRIMARY KEY
Correct
28. Constraints can be added at which two levels? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
Null Field
Table (*)
Row
Dictionary
Column (*)
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Section 9 Lesson 2
(Answer all questions in this section)
30. Which of the following types of constraints enforces uniqueness? Mark for
Review
(1) Points
CHECK
Page 118
Final Exam - Database Programming with SQL
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Page 3 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 9 Lesson 2
(Answer all questions in this section)
31. When creating a referential constraint, which keyword(s) identifies the table
and column in the parent table? Mark for Review
(1) Points
FOREIGN KEY
REFERENCES (*)
ON DELETE CASCADE
ON DELETE SET NULL
32. You need to create a composite primary key constraint on the EMPLOYEE table.
Which statement is true? Mark for Review
(1) Points
The PRIMARY KEY constraint must be defined at the table level. (*)
A PRIMARY KEY constraint must be defined for each column in the composite
primary key.
The PRIMARY KEY constraint must be defined for the first column of the composite
primary key.
The PRIMARY KEY constraint must be defined at the table level and for each
column in the composite primary key.
Correct
Page 119
Final Exam - Database Programming with SQL
33. You need to create the PROJECT_HIST table. The table must meet these
requirements:
The table must contain the EMPLOYEE_ID and TASKED_HOURS columns for numeric data.
The table must contain the START_DATE and END_DATE column for date values.
The table must contain the HOURLY_RATE and PROJECT_COST columns for numeric data
with precision and scale of 5,2 and 10,2 respectively.
The table must have a composite primary key on the EMPLOYEE_ID and START_DATE
columns.
Evaluate this CREATE TABLE statement:
CREATE TABLE project_hist
( employee_id NUMBER,
start_date DATE,
end_date DATE,
tasked_hours NUMBER,
hourly_rate NUMBER(5,2),
project_cost NUMBER(10,2),
CONSTRAINT project_hist_pk PRIMARY KEY(employee_id, start_date));
How many of the requirements does the CREATE TABLE statement satisfy?
Mark for Review
(1) Points
None of the four requirements
All four of the requirements (*)
Only three of the requirements
Only two of the requirements
34. Which clause could you use to ensure that cost values are greater than 1.00?
Mark for Review
(1) Points
CONSTRAINT CHECK cost > 1.00
CONSTRAINT part_cost_ck CHECK (cost > 1.00) (*)
35. How many PRIMARY KEY constraints can be created for each table? Mark for
Review
(1) Points
none
one and only one (*)
Page 120
Final Exam - Database Programming with SQL
one or two
unlimited
36. Which statement about a foreign key constraint is true? Mark for Review
(1) Points
A foreign key value cannot be null.
A foreign key value must be unique.
A foreign key value must match an existing value in the parent table.
A foreign key value must either be null or match an existing value in the parent
table. (*)
Section 9 Lesson 3
(Answer all questions in this section)
38. What actions can be performed on or with Constraints? Mark for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Page 121
Final Exam - Database Programming with SQL
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct
39. You need to remove the EMP_FK_DEPT constraint from the EMPLOYEE table in your
schema. Which statement should you use? Mark for Review
(1) Points
DROP CONSTRAINT EMP_FK_DEPT FROM employee;
DELETE CONSTRAINT EMP_FK_DEPT FROM employee;
ALTER TABLE employee DROP CONSTRAINT EMP_FK_DEPT; (*)
ALTER TABLE employee REMOVE CONSTRAINT EMP_FK_DEPT;
To drop and recreate the PRIMARY KEY constraint on the PO_NUM column
To disable any FOREIGN KEY constraints that are dependent on the PO_NUM column
(*)
To disable the constraint on the PO_NUM column while creating a PRIMARY KEY
index
Page 4 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 9 Lesson 3
(Answer all questions in this section)
41. You can view the columns used in a constraint defined for a specific table by
looking at which data dictionary table? Mark for Review
(1) Points
USER_CONS_COLUMNS (*)
CONSTRAINTS_ALL_COLUMNS
SYS_DATA_DICT_COLUMNS
US_CON_SYS
Correct
42. You want to disable the FOREIGN KEY constraint that is defined in the
EMPLOYEES table on the DEPT_ID column. The constraint is referenced by the name
FK_DEPT_ID_01. Which statement should you issue? Mark for Review
(1) Points
ALTER TABLE employees DISABLE 'fk_dept_id_01';
ALTER TABLE employees DISABLE CONSTRAINT 'fk_dept_id_01';
43. What is the syntax for removing a FOREIGN KEY constraint and all its
dependent constraints? Mark for Review
(1) Points
ALTER TABLE table_name
DROP CONSTRAINT constraint_name CASCADE;
(*)
Page 123
Final Exam - Database Programming with SQL
Correct
45. You need to add a PRIMARY KEY constraint on the EMP_ID column of the EMPLOYEE
table. Which ALTER TABLE statement should you use? Mark for Review
(1) Points
ALTER TABLE employee
ADD PRIMARY KEY (emp_id);
ALTER TABLE
ADD CONSTRAINT emp_emp_id_pk PRIMARY KEY employee(emp_id);
(*)
46. You disabled the EMPLOYEE_ID_PK PRIMARY KEY constraint on the ID column in
the EMPLOYEE table and imported 100 records. You need to enable the constraint and
verify that the new and existing ID column values do not violate the PRIMARY KEY
constraint. Evaluate this statement:
ALTER TABLE inventory
ENABLE employee_id_pk;
Which statement is true?
Mark for Review
(1) Points
The statement will execute, but will ensure that the new ID values are unique.
The statement will execute, but will not verify that the existing values are
unique.
The statement will NOT execute because it contains a syntax error. (*)
47. Which of the following would always cause an integrity constraint error? Mark
for Review
(1) Points
Using the DELETE command on a row that contains a primary key with a dependent
foreign key. (*)
Section 10 Lesson 1
(Answer all questions in this section)
48. Which keyword(s) would you include in a CREATE VIEW statement to create the
view regardless of whether or not the base table exists? Mark for Review
(1) Points
FORCE (*)
NOFORCE
OR REPLACE
Page 125
Final Exam - Database Programming with SQL
WITH READ ONLY
Correct
49. 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
You must create the SALES table before creating the view.
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. (*)
50. In order to query a database using a view, which of the following statements
applies? Mark for Review
(1) Points
Use special VIEWSELECT Keyword
You can retrieve data from a view as you would from any table. (*)
You can never see all the rows in the table through the view.
The tables you are selecting from can be empty, yet the view still returns the
original data from those tables.
Page 5 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 10 Lesson 1
(Answer all questions in this section)
51. 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
Page 126
Final Exam - Database Programming with SQL
the table.
Views provide data independence for ad hoc users and application programs. One
view can be used to retrieve data from several tables. Views can be used to provide
data security. (*)
Views are used when you only want to restrict DML operations using a WITH CHECK
OPTION.
Views are not valid unless you have more than one user.
You cannot update data in the EMPLOYEE table using the EMP_VIEW view. (*)
You can update any data in the EMPLOYEE table using the EMP_VIEW view.
You can delete records from the EMPLOYEE table using the EMP_VIEW view.
You can update only the SALARY column in the EMPLOYEE table using the EMP_VIEW
view.
Correct
nested
simple
inline
complex (*)
Page 128
Final Exam - Database Programming with SQL
UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;
Correct
Section 10 Lesson 2
(Answer all questions in this section)
56. You cannot create a view if the view subquery contains an inline view. True
or False? Mark for Review
(1) Points
True
False (*)
57. Which statement about performing DML operations on a view is true? Mark for
Review
(1) Points
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 WHERE clause.
You cannot modify data in a view if the view contains a group function. (*)
You can modify data in a view if the view contains a GROUP BY clause.
58. 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 companyname, city, orderid, orderdate, total
FROM customers, orders
WHERE custid = custid)
WITH READ ONLY;
Page 129
Final Exam - Database Programming with SQL
59. You cannot insert data through a view if the view includes ______. Mark for
Review
(1) Points
a WHERE clause
a join
a column alias
a GROUP BY clause (*)
60. You need to create a new view on the EMPLOYEE table to update salary
information. You need to ensure that DML operations through the view do not change
the result set of the view. Which clause should include in the CREATE VIEW
statement? Mark for Review
(1) Points
FORCE
OR REPLACE
WITH READ ONLY
WITH CHECK OPTION (*)
Page 6 of 10
Page 130
Final Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 10 Lesson 2
(Answer all questions in this section)
61. 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;
Correct
62. 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 e, departments d, job_grades
WHERE e.department_id equals d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
Section 10 Lesson 3
(Answer all questions in this section)
63. Which of the following describes a top-N query? Mark for Review
(1) Points
A top-N query returns the bottom 15 records from the specified table.
A top-N query returns the top 15 records from the specified table.
A top-N query returns a result set that is sorted according to the specified
column values.
A top-N query returns a limited result set that returns data based on highest or
lowest criteria. (*)
The statement will not necessarily return the 25 highest new balance values. (*)
The 25 greatest new balance values were displayed from the highest to the
lowest.
The statement failed to execute because the ORDER BY does NOT use the Top-n
column.
Correct
66. You must create a view that when queried 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
DELETE
INSERT
Page 133
Final Exam - Database Programming with SQL
SELECT (*)
67. 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; (*)
Section 11 Lesson 2
(Answer all questions in this section)
68. You create a CUSTOMERS table in which CUSTOMER_ID is designated as a primary
key. You want the values that are entered into the CUSTOMER_ID column to be
generated automatically. Which of the following actions should you perform? Mark for
Review
(1) Points
Do nothing. Oracle automatically generates unique values for columns that are
defined as primary keys.
Specify a UNIQUE constraint on the CUSTOMER_ID column.
Create a synonym.
Create a sequence. (*)
69. When used in a CREATE SEQUENCE statement, which keyword specifies that a
range of sequence values will be preloaded into memory? Mark for Review
(1) Points
LOAD
MEMORY
CACHE (*)
NOCACHE
NOCYCLE
Page 134
Final Exam - Database Programming with SQL
70. You created the LOCATION_ID_SEQ sequence to generate sequential values for
the LOCATION_ID column in the MANUFACTURERS table. You issue this statement:
ALTER TABLE manufacturers
MODIFY (location_id NUMBER(6));
The current value of the sequence is reset to the sequence's START WITH value.
Correct
Page 7 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 11 Lesson 2
(Answer all questions in this section)
71. Which statement would you use to modify the EMP_ID_SEQ sequence used to
populate the EMPLOYEE_ID column in the EMPLOYEES table? Mark for Review
(1) Points
ALTER SEQUENCE emp_id_seq.employee_id ;
CREATE SEQUENCE emp_id_seq ;
ALTER TABLE employees ;
ALTER SEQUENCE emp_id_seq ; (*)
Page 135
Final Exam - Database Programming with SQL
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It sets the current value of the PO_ITEM_ID_SEQ sequence to the value of the
PO_ITEMID column.
Section 11 Lesson 3
(Answer all questions in this section)
73. Which of the following best describes the function of an index? Mark for
Review
(1) Points
An index can increase the performance of SQL queries that search large tables.
(*)
An index can reduce the time required to grant multiple privileges to users.
An index can run statement blocks when DML actions occur against a table.
Correct
74. 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 required to specify the
table's schema. Which of the following should Barry create? Mark for Review
(1) Points
A schema
An index
A view
A synonym (*)
Page 136
Final Exam - Database Programming with SQL
It allows only the user CHAN to access TESTING using the synonym.
It eliminates the need for all users to qualify TESTING with its schema. (*)
77. You want to create a composite index on the FIRST_NAME and LAST_NAME columns
of the EMPLOYEES table. Which SQL statement will accomplish this task? Mark for
Review
(1) Points
CREATE INDEX fl_idx ON employees(first_name || last_name);
78. What would you create to make the following statement execute faster?
SELECT *
FROM employees
WHERE LOWER(last_name) = 'chang';
Mark for Review
(1) Points
A synonym.
A function_based index. (*)
A composite index.
Page 137
Final Exam - Database Programming with SQL
Nothing; the performance of this statement cannot be improved.
a CHECK constraint
an index (*)
Page 8 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 11 Lesson 3
(Answer all questions in this section)
81. 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 (*)
Page 138
Final Exam - Database Programming with SQL
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of the
CLIENTS table. You issue this statement:
83. Which statement would you use to remove the LAST_NAME_IDX 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
85. What is the correct syntax for creating an index? Mark for Review
(1) Points
CREATE INDEX index_name ON table_name(column_name); (*)
CREATE INDEX on table_name(column_name);
CREATE index_name INDEX ON table_name.column_name;
CREATE OR REPLACE INDEX index_name ON table_name(column_name);
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. You create a view named EMPLOYEES_VIEW on a subset of the EMPLOYEES table.
User AUDREY needs to use this view to create reports. Only you and Audrey should
have access to this view. Which of the following actions should 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;
87. 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
Page 140
Final Exam - Database Programming with SQL
CREATE TABLE (*)
CREATE OBJECT
88. You want to grant user BOB the ability to change other users' 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
89. You grant user AMY the CREATE SESSION privilege. Which type of privilege have
you granted to AMY? Mark for Review
(1) Points
A system privilege (*)
An object privilege
A user privilege
An access privilege
Correct
90. 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
Page 9 of 10
Page 141
Final Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 12 Lesson 2
(Answer all questions in this section)
91. User Kate wants to create indexes on tables in her schema. What privilege
must be granted to Kate so that she can do this? Mark for Review
(1) Points
CREATE INDEX
CREATE ANY INDEX
ALTER TABLE
None; users do not need extra privileges to create indexes on tables in their
own schema (*)
92. User JAMES has created a CUSTOMERS table and wants to allow 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;
Section 12 Lesson 3
(Answer all questions in this section)
93. 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 (*)
Page 142
Final Exam - Database Programming with SQL
Incorrect. Refer to Section 12
94. Which statement would you use to grant privileges to a role? Mark for Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
95. User BOB's schema contains an EMPLOYEES table. BOB executes the following
statement:
GRANT SELECT ON employees TO mary WITH GRANT OPTION;
Which of the following statements can MARY now execute successfully? (Choose two)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT FROM bob.employees; (*)
REVOKE SELECT ON bob.employees FROM bob;
GRANT SELECT ON bob.employees TO PUBLIC; (*)
DROP TABLE bob.employees;
96. Which keyword would you use to grant an object privilege to all database
users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
97. Which of the following simplifies the administration of privileges? Mark for
Review
(1) Points
an index
Page 143
Final Exam - Database Programming with SQL
a view
a trigger
a role (*)
98. User CRAIG creates a view named INVENTORY_V, which is based on the INVENTORY
table. CRAIG wants to make this view available for querying to all database users.
Which of the following actions should CRAIG perform? Mark for Review
(1) Points
He is not required to take any action because, by default, all database users
can automatically access views.
He should assign the SELECT privilege to all database users for the INVENTORY
table.
He should assign the SELECT privilege to all database users for INVENTORY_V
view. (*)
He must grant each user the SELECT privilege on both the INVENTORY table and
INVENTORY_V view.
Section 14 Lesson 1
(Answer all questions in this section)
99. Table MYTAB contains only one column of datatype CHAR(1). A user executes the
following statements in the order shown.
INSERT INTO mytab VALUES ('A');
INSERT INTO mytab VALUES ('B');
COMMIT;
INSERT INTO mytab VALUES ('C');
ROLLBACK;
Which rows does the table now contain?
Mark for Review
(1) Points
A, B and C
A and B (*)
C
None of the above
100. Which of the following best describes the term "read consistency"? Mark for
Review
(1) Points
Page 144
Final Exam - Database Programming with SQL
It ensures that all changes to a table are automatically committed
It prevents other users from querying a table while updates are being executed
on it
It prevents other users from seeing changes to a table until those changes have
been committed (*)
It prevents users from querying tables on which they have not been granted
SELECT privilege
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 1
1. You want to create a database table that will contain information regarding
products that your company released during 2001. Which name can you assign to the
table that you create? Mark for Review
(1) Points
2001_PRODUCTS
PRODUCTS_2001 (*)
PRODUCTS_(2001)
PRODUCTS--2001
2. You want to create a table named TRAVEL that is a child of the EMPLOYEES
table. Which of the following statements should you issue? Mark for Review
(1) Points
CREATE TABLE travel (destination_id primary key, departure_date date,
return_date date, emp_id REFERENCES employees (emp_id));
3. You are creating the EMPLOYEE table. This table should contain the COMMISSION
column and use a value of 10 percent if no commission value is provided when a
record is inserted. Which line should you include in the CREATE TABLE statement to
Page 145
Final Exam - Database Programming with SQL
accomplish this task? Mark for Review
(1) Points
commission NUMBER(4,2) DEFAULT 0.10 (*)
commission NUMBER(4,2) DEFAULT = 0.10
commission NUMBER(4,2) DEFAULT (0.10)
commission NUMBER(4,2) (DEFAULT, 0.10)
4. Which statement about table and column names is true? Mark for Review
(1) Points
Table and column names must begin with a letter. (*)
Table and column names can begin with a letter or a number.
Table and column names cannot include special characters.
If any character other than letters or numbers is used in a table or column
name, the name must be enclosed in double quotation marks.
Section 8 Lesson 2
(Answer all questions in this section)
6. To store time with fractions of seconds, which datatype should be used for a
table column? Mark for Review
(1) Points
DATE
Page 146
Final Exam - Database Programming with SQL
INTERVAL YEAR TO MONTH
TIMESTAMP (*)
INTERVAL DAY TO SECOND
7. Which data types stores variable-length character data? Select two. Mark for
Review
(1) Points
(Choose all correct answers)
CHAR
NCHAR
VARCHAR (*)
VARCHAR2 (*)
8. You are designing a table for the Human Resources department. This table must
include a column that contains each employee's hire date. Which data type should you
specify for this column? Mark for Review
(1) Points
CHAR
DATE (*)
TIMESTAMP
INTERVAL YEAR TO MONTH
9. You need to store the SEASONAL data in months and years. Which data type
should you use? Mark for Review
(1) Points
DATE
TIMESTAMP
INTERVAL YEAR TO MONTH (*)
INTERVAL DAY TO SECOND
Page 1 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 2
(Answer all questions in this section)
11. Data in the RESPONSE_TIME column needs to be stored in days, hours, minutes
and seconds. Which data type should you use? Mark for Review
(1) Points
DATETIME
TIMESTAMP
INTERVAL YEAR TO MONTH
INTERVAL DAY TO SECOND (*)
Section 8 Lesson 3
(Answer all questions in this section)
13. Your supervisor has asked you to modify the AMOUNT column in the ORDERS
table. He wants the column to be configured to accept a default value of 250. The
table contains data that you need to keep. Which statement should you issue to
accomplish this task? Mark for Review
(1) Points
ALTER TABLE orders CHANGE DATATYPE amount TO DEFAULT 250;
14. Which command could you use to quickly remove all data from the rows in a
table without deleting the table itself? Mark for Review
(1) Points
ALTER TABLE
DROP TABLE
MODIFY
TRUNCATE TABLE (*)
Page 149
Final Exam - Database Programming with SQL
15. You want to issue the following command on a database that includes your
company's inventory information:
ALTER TABLE products
SET UNUSED COLUMN color;
What will be the result of issuing this command?
Mark for Review
(1) Points
The column named COLOR in the table named PRODUCTS will be assigned default
values.
The column named COLOR in the table named PRODUCTS will be created.
The column named COLOR in the table named PRODUCTS will be deleted.
The column named COLOR in the table named PRODUCTS will not be returned in
subsequent reads of the table by Oracle, as is has been deleted logically. (*)
16. The previous administrator created a table named CONTACTS, which contains
outdated data. You want to remove the table and its data from the database. Which
statement should you issue? Mark for Review
(1) Points
DELETE
TRUNCATE TABLE
ALTER TABLE
You need to remove the EMPLOYEE_ID column from the EMPLOYEES table. Which statement
could you use to accomplish this task?
Mark for Review
(1) Points
ALTER TABLE employees MODIFY (employee_id NUMBER(5));
ALTER TABLE employees DELETE employee_id;
ALTER TABLE employees DROP COLUMN employee_id; (*)
DELETE FROM employees WHERE column = employee_id;
Page 150
Final Exam - Database Programming with SQL
You must drop and recreate the DONATIONS table to achieve these results.
You must use the ADD OR REPLACE option to achieve these results.
19. You need to remove all the data in the SCHEDULE table, the structure of the
table, and the indexes associated with the table. Which statement should you use?
Mark for Review
(1) Points
DROP TABLE (*)
TRUNCATE TABLE
ALTER TABLE
DELETE TABLE
The TEAMS table is currently empty. You need to allow users to include text
characters in the manager identification values. Which statement should you use to
implement this?
Mark for Review
(1) Points
ALTER teams MODIFY (mgr_id VARCHAR2(15));
Page 151
Final Exam - Database Programming with SQL
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
Page 2 of 10
Test: Final Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 8 Lesson 3
(Answer all questions in this section)
21. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9) Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DEPARTMENT_ID NUMBER(9)
SALARY NUMBER(8,2)
Which statement will permanently remove all the data in the EMPLOYEES table, but
will retain the table's structure and storage space?
Mark for Review
(1) Points
DROP TABLE employees;
DELETE employees; COMMIT; (*)
TRUNCATE TABLE employees;
ALTER TABLE employees SET UNUSED (employee_id, last_name, first_name,
department_id, salary);
Correct
Page 152
Final Exam - Database Programming with SQL
ALTER players TABLE MODIFY COLUMN first_name VARCHAR2(10);
Section 9 Lesson 1
(Answer all questions in this section)
24. Which two statements about NOT NULL constraints are true? (Choose two) Mark
for Review
(1) Points
The Oracle Server creates a name for an unnamed NOT NULL constraint. (*)
A NOT NULL constraint can be defined at either the table or column level.
The NOT NULL constraint requires that every value in a column be unique.
Columns without the NOT NULL constraint can contain null values by default. (*)
You CANNOT add a NOT NULL constraint to an existing column using the ALTER TABLE
ADD CONSTRAINT statement.using the ALTER TABLE statement.
25. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
10
Page 153
Final Exam - Database Programming with SQL
3
You can have as many NOT NULL constraints as you have columns in your table. (*)
26. Constraints can be added at which two levels? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
Null Field
Table (*)
Row
Dictionary
Column (*)
27. You need to ensure that the LAST_NAME column only contains certain character
values. No numbers or special characters are allowed.
Which type of constraint should you define on the LAST_NAME column? Mark for Review
(1) Points
CHECK (*)
UNIQUE
NOT NULL
PRIMARY KEY
28. You need to ensure that each value in the SEAT_ID column is unique or null.
Which constraint should you define on the SEAT_ID column? Mark for Review
(1) Points
CHECK
UNIQUE (*)
NOT NULL
PRIMARY KEY
29. You need to ensure that the LAST_NAME column does not contain null values.
Which type of constraint should you define on the LAST_NAME column? Mark for Review
Page 154
Final Exam - Database Programming with SQL
(1) Points
CHECK
UNIQUE
NOT NULL (*)
PRIMARY KEY
Section 9 Lesson 2
(Answer all questions in this section)
30. What must exist on the Parent table before Oracle will allow you to create a
FOREIGN KEY constraint from a Child table? Mark for Review
(1) Points
A FOREIGN KEY constraint on the Parent table.exist in the primary key column of
the parent table.
A PRIMARY or UNIQUE KEY constraint must exist on the Parent table. (*)
An index must exist on the Parent table.
A CHECK constraint must exist on the Parent table.
Page 3 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 9 Lesson 2
(Answer all questions in this section)
31. Which statement about a foreign key constraint is true? Mark for Review
(1) Points
A foreign key value cannot be null.
A foreign key value must be unique.
A foreign key value must match an existing value in the parent table.
A foreign key value must either be null or match an existing value in the parent
table. (*)
Correct
Page 155
Final Exam - Database Programming with SQL
32. Which type of constraint by default requires that a column be both unique and
not null? Mark for Review
(1) Points
FOREIGN KEY
PRIMARY KEY (*)
UNIQUE
CHECK
33. You need to enforce a relationship between the LOC_ID column in the FACILITY
table and the same column in the MANUFACTURER table. Which type of constraint should
you define on the LOC_ID column? Mark for Review
(1) Points
UNIQUE
NOT NULL
FOREIGN KEY (*)
PRIMARY KEY
34. You need to create the PROJECT_HIST table. The table must meet these
requirements:
The table must contain the EMPLOYEE_ID and TASKED_HOURS columns for numeric data.
The table must contain the START_DATE and END_DATE column for date values.
The table must contain the HOURLY_RATE and PROJECT_COST columns for numeric data
with precision and scale of 5,2 and 10,2 respectively.
The table must have a composite primary key on the EMPLOYEE_ID and START_DATE
columns.
Evaluate this CREATE TABLE statement:
CREATE TABLE project_hist
( employee_id NUMBER,
start_date DATE,
end_date DATE,
tasked_hours NUMBER,
hourly_rate NUMBER(5,2),
project_cost NUMBER(10,2),
CONSTRAINT project_hist_pk PRIMARY KEY(employee_id, start_date));
How many of the requirements does the CREATE TABLE statement satisfy?
Mark for Review
(1) Points
None of the four requirements
Page 156
Final Exam - Database Programming with SQL
All four of the requirements (*)
Only three of the requirements
Only two of the requirements
35. Which of the following FOREIGN KEY Constraint keywords identifies the table
and column in the parent table? Mark for Review
(1) Points
RESEMBLES
ON DELETE CASCADE
REFERENTIAL
REFERENCES (*)
36. When creating the EMPLOYEES table, which clause could you use to ensure that
salary values are 1000.00 or more? Mark for Review
(1) Points
CONSTRAINT CHECK salary > 1000
CHECK CONSTRAINT (salary > 1000)
CONSTRAINT employee_salary_min CHECK salary > 1000
CONSTRAINT employee_salary_min CHECK (salary >= 1000) (*)
Page 157
Final Exam - Database Programming with SQL
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY NOT NULL, donor_id NUMBER FOREIGN KEY
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE);
Section 9 Lesson 3
(Answer all questions in this section)
38. You need to add a PRIMARY KEY constraint on the EMP_ID column of the EMPLOYEE
table. Which ALTER TABLE statement should you use? Mark for Review
(1) Points
ALTER TABLE employee
ADD PRIMARY KEY (emp_id);
ALTER TABLE
ADD CONSTRAINT emp_emp_id_pk PRIMARY KEY employee(emp_id);
(*)
39. You need to add a NOT NULL constraint to the EMAIL column in the EMPLOYEE
table. Which clause should you use? Mark for Review
(1) Points
ADD
CHANGE
MODIFY (*)
Page 158
Final Exam - Database Programming with SQL
ENABLE
40. What is the syntax for removing a FOREIGN KEY constraint and all its
dependent constraints? Mark for Review
(1) Points
ALTER TABLE table_name
DROP CONSTRAINT constraint_name CASCADE;
(*)
Correct
Page 4 of 10
Test: Final Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 9 Lesson 3
(Answer all questions in this section)
41. When dropping a constraint, which keyword(s) specifies that all the
referential integrity constraints that refer to the primary and unique keys defined
on the dropped columns are dropped as well? Mark for Review
(1) Points
FOREIGN KEY
REFERENCES
CASCADE (*)
ON DELETE SET NULL
42. You successfully create a table named SALARY in your company's database. Now,
you want to establish a parent/child relationship between the EMPLOYEES table and
the SALARY table by adding a FOREIGN KEY constraint to the SALARY table that
Page 159
Final Exam - Database Programming with SQL
references its matching column in the EMPLOYEES table. You have not added any data
to the SALARY table. Which of the following statements should you issue? Mark for
Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES employees
(employee_id);
(*)
Correct
43. You need to add a PRIMARY KEY to the DEPARTMENT table. Which statement should
you use? Mark for Review
(1) Points
ALTER TABLE department ADD PRIMARY KEY dept_id_pk (dept_id);
ALTER TABLE department ADD CONSTRAINT dept_id_pk PK (dept_id);
ALTER TABLE department ADD CONSTRAINT dept_id_pk PRIMARY KEY (dept_id); (*)
ALTER TABLE department ADD CONSTRAINT PRIMARY KEY dept_id_pk (dept_id);
Correct
Page 160
Final Exam - Database Programming with SQL
45. You need to remove the EMP_FK_DEPT constraint from the EMPLOYEE table in your
schema. Which statement should you use? Mark for Review
(1) Points
DROP CONSTRAINT EMP_FK_DEPT FROM employee;
DELETE CONSTRAINT EMP_FK_DEPT FROM employee;
ALTER TABLE employee DROP CONSTRAINT EMP_FK_DEPT; (*)
Page 161
Final Exam - Database Programming with SQL
47. Evaluate this statement
ALTER TABLE employee
ENABLE CONSTRAINT emp_id_pk;
For which task would you issue this statement?
Mark for Review
(1) Points
to add a new constraint to the EMPLOYEE table
to disable an existing constraint on the EMPLOYEE table
Section 10 Lesson 1
(Answer all questions in this section)
48. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
49. 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 a stored procedure.
Create a view. (*)
Create a subquery.
Create a trigger.
50. Which of the following statements is a valid reason for using a view? Mark
for Review
Page 162
Final Exam - Database Programming with SQL
(1) Points
Views allow access to the data because the view displays all of the columns from
the table.
Views provide data independence for ad hoc users and application programs. One
view can be used to retrieve data from several tables. Views can be used to provide
data security. (*)
Views are used when you only want to restrict DML operations using a WITH CHECK
OPTION.
Views are not valid unless you have more than one user.
Page 5 of 10
Test: Final Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 10 Lesson 1
(Answer all questions in this section)
51. Which keyword(s) would you include in a CREATE VIEW statement 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
52. 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
53. You need to create a view that when queried will display the name, employee
identification number, first and last name, salary, and department identification
number. When queried, the display should be sorted by salary from lowest to highest,
Page 163
Final Exam - Database Programming with SQL
then by last name and first name alphabetically. The view definition should be
created regardless of the existence of the EMPLOYEE table. No DML may be performed
when using this view. Evaluate these statements:
CREATE OR REPLACE NOFORCE VIEW EMP_SALARY_V
AS SELECT emp_id, last_name, first_name, salary, dept_id
FROM employee WITH READ ONLY;
SELECT *
FROM emp_salary_v
ORDER BY salary, last_name, first_name;
Correct
SELECT *
FROM part_name_v;
(*)
UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;
Section 10 Lesson 2
(Answer all questions in this section)
56. You cannot insert data through a view if the view includes ______. Mark for
Review
(1) Points
a WHERE clause
a join
a column alias
a GROUP BY clause (*)
57. You need to create a new view on the EMPLOYEE table to update salary
information. You need to ensure that DML operations through the view do not change
the result set of the view. Which clause should include in the CREATE VIEW
statement? Mark for Review
(1) Points
FORCE
OR REPLACE
WITH READ ONLY
WITH CHECK OPTION (*)
58. Which of the following is TRUE regarding simple views? Mark for Review
(1) Points
They derive data from many tables, so they typically contain joins.
Page 165
Final Exam - Database Programming with SQL
They contain functions or groups of data
They can perform DML operations through the view (*)
They are not stored in the Data Dictionary
59. 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 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.
You can perform DML operations on a view that contains columns defined by
expressions, such as COST + 1.
60. Which statement about performing DML operations on a view is true? Mark for
Review
(1) Points
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 WHERE clause.
You cannot modify data in a view if the view contains a group function. (*)
You can modify data in a view if the view contains a GROUP BY clause.
Page 6 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 10 Lesson 2
(Answer all questions in this section)
61. Which action can be performed by using DML statements? Mark for Review
(1) Points
Deleting records in a table (*)
Page 166
Final Exam - Database Programming with SQL
Creating PRIMARY KEY constraints
Disabling an index
Altering a table
62. 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;
Section 10 Lesson 3
(Answer all questions in this section)
63. 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 balance
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 is included
in your query?
Mark for Review
(1) Points
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;
Page 168
Final Exam - Database Programming with SQL
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 view.
The CREATE VIEW statement generates an error.
66. 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 AS keyword
a WHERE clause
the IN keyword
a GROUP BY clause (*)
Section 11 Lesson 2
(Answer all questions in this section)
Page 169
Final Exam - Database Programming with SQL
68. Evaluate this statement:
CREATE SEQUENCE line_item_id_seq
MINVALUE 100 MAXVALUE 130 INCREMENT BY -10 CYCLE;
What will be the first five numbers generated by this sequence?
Mark for Review
(1) Points
The fifth number cannot be generated.
130120110100130
100110120130100
The CREATE SEQUENCE statement will fail because a START WITH value was not
specified. (*)
69. You created the LOCATION_ID_SEQ sequence to generate sequential values for
the LOCATION_ID column in the MANUFACTURERS table. You issue this statement:
ALTER TABLE manufacturers
MODIFY (location_id NUMBER(6));
Which statement about the LOCATION_ID_SEQ sequence is true?
Mark for Review
(1) Points
The sequence is unchanged. (*)
The sequence is deleted and must be recreated.
The current value of the sequence is reset to zero.
The current value of the sequence is reset to the sequence's START WITH value.
70. Which statement would you use to remove the EMP_ID_SEQ sequence? 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;
Page 7 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 11 Lesson 2
(Answer all questions in this section)
71. 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. (*)
72. Which pseudocolumn returns the latest value supplied by a sequence? Mark for
Review
(1) Points
NEXTVAL
CURRVAL (*)
CURRENT
NEXT
Section 11 Lesson 3
(Answer all questions in this section)
73. What would you create to make the following statement execute faster?
SELECT *
FROM employees
WHERE LOWER(last_name) = 'chang';
Mark for Review
(1) Points
A synonym.
A function_based index. (*)
Page 171
Final Exam - Database Programming with SQL
A composite index.
Nothing; the performance of this statement cannot be improved.
74. User Mary's schema contains an EMP table. Mary has Database Administrator
privileges and executes the following statement:
CREATE PUBLIC SYNONYM emp FOR mary.emp;
User Susan now needs to SELECT from Mary's EMP table. Which of the following SQL
statements can she use? (Choose two)
Mark for Review
(1) Points
(Choose all correct answers)
CREATE SYNONYM marys_emp FOR mary(emp);
SELECT * FROM emp; (*)
SELECT * FROM emp.mary;
SELECT * FROM mary.emp; (*)
Page 172
Final Exam - Database Programming with SQL
Create a function_based index on ((salary * 12) > 100000).
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
JOB_ID only
DEPT_ID only
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of the
CLIENTS table. You issue this statement:
79. You create a table named CUSTOMERS and define a PRIMARY KEY constraint on the
CUST_ID column. Which actions occur automatically? Mark for Review
(1) Points
Page 173
Final Exam - Database Programming with SQL
A CHECK constraint is defined on the CUST_ID column.
A trigger is created that will prevent NULL values from being accepted in the
CUST_ID column.
A sequence is created that will generate a unique value in the CUST_ID column
for each row that is inserted into the CUSTOMERS table.
80. Which of the following SQL statements will display the index name, table
name, and the uniqueness of the index for all indexes on the EMPLOYEES table? Mark
for Review
(1) Points
Page 8 of 10
Test: Final Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 11 Lesson 3
(Answer all questions in this section)
81. Which of the following is created automatically by Oracle when a UNIQUE
integrity constraint is created? Mark for Review
(1) Points
a PRIMARY KEY constraint
a CHECK constraint
Page 174
Final Exam - Database Programming with SQL
an index (*)
a FOREIGN KEY constraint
83. What is the correct syntax for creating an index? Mark for Review
(1) Points
CREATE INDEX index_name ON table_name(column_name); (*)
CREATE INDEX on table_name(column_name);
CREATE index_name INDEX ON table_name.column_name;
CREATE OR REPLACE INDEX index_name ON table_name(column_name);
Correct
84. 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 required to specify the
table's schema. Which of the following should Barry create? Mark for Review
(1) Points
A schema
An index
A view
A synonym (*)
Page 175
Final Exam - Database Programming with SQL
Incorrect. Refer to Section 11
Section 12 Lesson 2
(Answer all questions in this section)
86. You are the database administrator. You want to create a new user JONES with
a password of MARK, and allow this user to create his own tables. Which of the
following should you execute? Mark for Review
(1) Points
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE TABLE TO jones;
Page 176
Final Exam - Database Programming with SQL
87. 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
88. Which of the following are system privileges? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE PROCEDURE (*)
INDEX
89. User SUSAN creates an EMPLOYEES table, and then creates a view EMP_VIEW which
shows only the FIRST_NAME and LAST_NAME columns of EMPLOYEES. User RUDI needs to be
able to access employees' names but no other data from EMPLOYEES. Which statement
should SUSAN execute to allow this? Mark for Review
(1) Points
SELECT * FROM emp_view FOR rudi;
CREATE SYNONYM emp_view FOR employees;
GRANT SELECT ON emp_view TO rudi; (*)
GRANT SELECT ON emp_view ONLY TO rudi;
90. Which of the following best describes a role in an Oracle 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.
Page 9 of 10
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 12 Lesson 2
(Answer all questions in this section)
91. You want to grant user BOB the ability to change other users' 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
92. You create a view named EMPLOYEES_VIEW on a subset of the EMPLOYEES table.
User AUDREY needs to use this view to create reports. Only you and Audrey should
have access to this view. Which of the following actions should 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.
Section 12 Lesson 3
(Answer all questions in this section)
93. Which of the following simplifies the administration of privileges? Mark for
Review
(1) Points
an index
Page 178
Final Exam - Database Programming with SQL
a view
a trigger
a role (*)
94. Which data dictionary view shows which system privileges have been granted to
a user? Mark for Review
(1) Points
USER_TAB_PRIVS
USER_SYS_PRIVS (*)
USER_SYSTEM_PRIVS
USER_SYSTEM_PRIVILEGES
95. Which keyword would you use to grant an object privilege to all database
users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
96. User CRAIG creates a view named INVENTORY_V, which is based on the INVENTORY
table. CRAIG wants to make this view available for querying to all database users.
Which of the following actions should CRAIG perform? Mark for Review
(1) Points
He is not required to take any action because, by default, all database users
can automatically access views.
He should assign the SELECT privilege to all database users for the INVENTORY
table.
He should assign the SELECT privilege to all database users for INVENTORY_V
view. (*)
He must grant each user the SELECT privilege on both the INVENTORY table and
INVENTORY_V view.
Page 179
Final Exam - Database Programming with SQL
97. Which statement would you use to grant a role to users? Mark for Review
(1) Points
GRANT (*)
ALTER USER
CREATE USER
ASSIGN
Correct
98. User BOB's schema contains an EMPLOYEES table. BOB executes the following
statement:
GRANT SELECT ON employees TO mary WITH GRANT OPTION;
Which of the following statements can MARY now execute successfully? (Choose two)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT FROM bob.employees; (*)
REVOKE SELECT ON bob.employees FROM bob;
GRANT SELECT ON bob.employees TO PUBLIC; (*)
DROP TABLE bob.employees;
Section 14 Lesson 1
(Answer all questions in this section)
99. User BOB's CUSTOMERS table contains 20 rows. BOB inserts two more rows into
the table but does not COMMIT his changes. User JANE now executes:
SELECT COUNT(*) FROM bob.customers;
Page 180
Final Exam - Database Programming with SQL
100. A transaction makes several successive changes to a table. If required, you
want to be able to rollback the later changes while keeping the earlier changes.
What must you include in your code to do this? Mark for Review
(1) Points
An update statement
A savepoint (*)
An object privilege
A database link
A sequence
Page 10 of 10
Page 181
Final Exam - Database Programming with SQL
Page 182