Skip navigation elements to page contents
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. You need to return a portion of each employee's last name,
beginning with the first character up to the fifth character. Which character
function should you use? Mark for Review
(1) Points
INSTR
TRUNC
SUBSTR (*)
CONCAT
Correct Correct
2. You need to display each employee's name in all uppercase
letters. Which function should you use? Mark for Review
(1) Points
CASE
UCASE
UPPER (*)
TOUPPER
Correct Correct
3. You need to display the number of characters in each customer's
last name. Which function should you use? Mark for Review
(1) Points
LENGTH (*)
LPAD
COUNT
SUBSTR
Correct Correct
4. Which SQL function can be used to remove heading or trailing
characters (or both) from a character string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
Correct Correct
5. What will the following SQL statemtent display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value,
size of 15 and the column labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left
of the decimal and the column labeled SALARY.
The last name and salary for all employees with the format of the salary 15
characters long, left-padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where
expected."
Correct Correct
6. The PRICE table contains this data:
PRODUCT_ID MANUFACTURER_ID
86950 59604
You query the database and return the value 95. Which script did you use?
Mark for Review
(1) Points
SELECT SUBSTR(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
(*)
SELECT LENGTH(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
SELECT SUBSTR(product_id, -1, 3)
FROM price
WHERE manufacturer_id = 59604;
SELECT TRIM(product_id, -3, 2)
FROM price
WHERE manufacturer_id = 59604;
Correct Correct
7. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 12.00
You query the database and return the value 79. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
(*)
Correct Correct
Section 1 Lesson 2
(Answer all questions in this section)
8. You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
Mark for Review
(1) Points
1200
1282
1282.25
1300 (*)
Correct Correct
9. Which comparison operator retrieves a list of values? Mark
for Review
(1) Points
IN (*)
LIKE
BETWEEN...IN...
IS NULL
Incorrect Incorrect. Refer to Section 1 Lesson 1
10. Which script displays '01-MAY-04' when the HIRE_DATE value is
'20-MAY-04'? Mark for Review
(1) Points
SELECT TRUNC(hire_date, 'MONTH')
FROM employee;
(*)
SELECT ROUND(hire_date, 'MONTH')
FROM employee;
SELECT ROUND(hire_date, 'MON')
FROM employee;
SELECT TRUNC(hire_date, 'MI')
FROM employee;
Correct Correct
Page 1 of 10 Next Summary
Skip navigation elements to page contents
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1 Lesson 3
(Answer all questions in this section)
11. Which SELECT statement will NOT return a date value? Mark for
Review
(1) Points
SELECT (30 + hire_date) + 1440/24
FROM employees;
SELECT (SYSDATE - hire_date) + 10*8
FROM employees;
(*)
SELECT SYSDATE - TO_DATE('25-JUN-02') + hire_date
FROM employees;
SELECT (hire_date - SYSDATE) + TO_DATE('25-JUN-02')
FROM employees;
Correct Correct
12. Evaluate this SELECT statement:
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
Mark for Review
(1) Points
the current date plus 30 hours
the current date plus 30 days (*)
the current date plus 30 months
No value is returned because the SELECT statement generates an error.
Incorrect Incorrect. Refer to Section 1
13. Which SELECT statement will return a numeric value? Mark for
Review
(1) Points
SELECT SYSDATE + 600 / 24
FROM employee;f
f
SELECT ROUND(hire_date, DAY)
FROM employee;
SELECT (SYSDATE - hire_date) / 7
FROM employee;
(*)
SELECT SYSDATE - 7
FROM employee;
Correct Correct
14. You need to subtract three months from the current date. Which
function should you use? Mark for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Incorrect Incorrect. Refer to Section 1
15. You need to display the current year as a character value (for
example: Two Thousand and One). Which element would you use? Mark for Review
(1) Points
RR
YY
YYYY
YEAR (*)
Correct Correct
Section 2 Lesson 1
(Answer all questions in this section)
16. Which best describes the TO_CHAR function? Mark for Review
(1) Points
The TO_CHAR function can be used to specify meaningful column names in an SQL
statement's result set.
The TO_CHAR function can be used to remove text from column data that will be
returned by the database.
The TO_CHAR function can be used to display dates and numbers according to
formatting conventions that are supported by Oracle. (*)
The TO_CHAR function can only be used on DATE columns.
Correct Correct
17. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script
should you use to display the salaries in format: "$45,000.00"?
Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees;
(*)
Correct Correct
18. Which SQL Statement should you use to display the prices in this
format: "$00.30"? Mark for Review
(1) Points
SELECT TO_CHAR(price, '$99,900.99') FROM product; (*)
SELECT TO_CHAR(price, "$99,900.99") FROM product;
SELECT TO_CHAR(price, '$99,990.99') FROM product;
SELECT TO_NUMBER(price, '$99,900.99') FROM product;
Correct Correct
19. Which arithmetic operation will return a numeric value? Mark
for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
SYSDATE + 30 / 24
Correct Correct
20. Which functions allow you to perform explicit data type
conversions? Mark for Review
(1) Points
ROUND, TRUNC, ADD_MONTHS
LENGTH, SUBSTR, LPAD, TRIM
TO_CHAR, TO_DATE, TO_NUMBER (*)
NVL, NVL2, NULLIF
Correct Correct
Previous Page 2 of 10 Next Summary
Skip navigation elements to page contents
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 2 Lesson 1
(Answer all questions in this section)
21. You have been asked to create a report that lists all customers
who have placed orders of at least $2,500. The report's date should be displayed in
the Day, Date Month, Year format (For example, Tuesday, 13 April, 2004 ). Which
statement should you issue? Mark for Review
(1) Points
SELECT companyname, TO_CHAR (sysdate, 'fmdd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (date, 'day, dd month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (sysdate, 'dd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_CHAR (sysdate, 'fmDay, dd Month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
(*)
Correct Correct
Section 2 Lesson 2
(Answer all questions in this section)
22. Which of the following General Functions will return the first
non-null expression in the expression list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
COALESCE (*)
Correct Correct
23. The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
SELECT NVL(10 / price, '0')
FROM PRODUCT;
What would happen if the PRICE column contains null values?
Mark for Review
(1) Points
The statement would fail because values cannot be divided by 0.
A value of 0 would be displayed. (*)
A value of 10 would be displayed.
The statement would fail because values cannot be divided by null.
Correct Correct
24. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace
null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace
null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null
values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace
null values.
Incorrect Incorrect. Refer to Section 2
Section 3 Lesson 2
(Answer all questions in this section)
25. Which statement about the join syntax of a SELECT statement is
true? Mark for Review
(1) Points
The ON keyword must be included.
The JOIN keyword must be included.
The FROM clause represents the join criteria.
The WHERE clause represents the join criteria. (*)
Correct Correct
26. Your company stores its business information in an Oracle9i
database. The EMPLOYEES table includes the following columns:
EMP_ID NUMBER(5) NOT NULL PRIMARY KEY
FNAME VARCHAR2(25)
LNAME VARCHAR2(25)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(25)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
DEPT_ID NUMBER(5) NOT NULL FOREIGN KEY
The BONUS table includes the following columns:
BONUS_ID NUMBER(5) NOT NULL PRIMARY KEY
ANNUAL_SALARY NUMBER(10)
BONUS_PCT NUMBER(3, 2)
EMP_ID VARCHAR2(5) NOT NULL FOREIGN KEY
You want to determine the amount of each employee's bonus. Which of the following
queries should you issue?
Mark for Review
(1) Points
SELECT e.fname, e.lname, b.annual_salary * b. bonus_pct
FROM employees e, bonus b
WHERE e.emp_id = b.emp_id;
(*)
SELECT e.fname, e.lname, b.annual_salary, b. bonus_pct
FROM employees e, bonus b
WHERE e.emp_id = b.emp_id;
SELECT e.fname, e.lname, b.annual_salary, b. bonus_pct
FROM employees, bonus
WHERE e.emp_id = b.emp_id;
SELECT fname, lname, annual_salary * bonus_pct
FROM employees, bonus NATURAL JOIN;
Correct Correct
27. The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
Which result will this statement provide?
Mark for Review
(1) Points
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID
values (*)
A report containing each patient's id value and their doctor's id value
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
A syntax error
Correct Correct
28. You have been asked to create a report that lists all corporate
customers and all orders that they have placed. The customers should be listed
alphabetically beginning with the letter 'A', and their corresponding order totals
should be sorted from the highest amount to the lowest amount.
Which of the following statements should you issue? Mark for Review
(1) Points
SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount
FROM customers c, orders o
WHERE c.custid = o.custid
ORDER BY amount DESC, companyname;
SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount
FROM customers c, orders o
WHERE c.custid = o.custid
ORDER BY companyname, amount DESC;
(*)
SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount
FROM customers c, orders o
WHERE c.custid = o.custid
ORDER BY companyname, amount;
SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount
Q FROM customers c, orders o
WHERE c.custid = o.custid
ORDER BY companyname ASC, amount ASC;
Correct Correct
29. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
Correct Correct
30. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total
sales?
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
Correct Correct
Previous Page 3 of 10 Next Summary
Skip navigation elements to page contents
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 3 Lesson 4
(Answer all questions in this section)
31. Which of the following best describes the function of an outer
join? Mark for Review
(1) Points
An outer join will return only those rows that do not meet the join criteria.
An outer join will return only data from the far left column in one table and
the far right column in the other table.
An outer join will return data only if both tables contain an identical pair
of columns.
An outer join will return all rows that meet the join criteria and will
return NULL values from one table if no rows from the other table satisfy the join
criteria. (*)
Incorrect Incorrect. Refer to Section 3
32. Which two operators can be used in an outer join condition using
the outer join operator (+)? Mark for Review
(1) Points
AND and = (*)
OR and =
BETWEEN...AND... and IN
IN and =
Correct Correct
33. Which operator would you use after one of the column names in the
WHERE clause when creating an outer join? Mark for Review
(1) Points
(+) (*)
Correct Correct
Section 4 Lesson 2
(Answer all questions in this section)
34. A join between tables where the result set includes matching
values from both tables but does NOT return any unmatched rows could be called
which of the following? (Choose three) Mark for Review
(1) Points
(Choose all correct answers)
Equijoin (*)
Self join (*)
Nonequijoin
Simple join (*)
full outer join
Correct Correct
35. The following SQL statement will produce what output?
SELECT last_name, department_name
FROM employees
CROSS JOIN departments;
Mark for Review
(1) Points
The missing rows from the join condition.
The last_name and department name from the employee table.
A Cartesian product between the two tables. (*)
A cross referenced result omitting similar fields from the two tables.
Correct Correct
36. You need to join all the rows in the EMPLOYEE table to all the
rows in the EMP_REFERENCE table. Which type of join should you create? Mark
for Review
(1) Points
An equijoin
A cross join (*)
An inner join
A full outer join
Correct Correct
Section 4 Lesson 3
(Answer all questions in this section)
37. For which condition would you use an equijoin query with the
USING keyword? Mark for Review
(1) Points
You need to perform a join of the CUSTOMER and ORDER tables but limit the
number of columns in the join condition. (*)
The ORDER table contains a column that has a referential constraint to a
column in the PRODUCT table.
The CUSTOMER and ORDER tables have no columns with identical names.
The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The
CUST_ID column in the ORDER table contains null values that need to be displayed.
Correct Correct
38. You created the CUSTOMERS and ORDERS tables by issuing these
CREATE TABLE statements in sequence:
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information about
orders placed by customers who reside in Nashville . Which query should you issue
to achieve the desired results?
Mark for Review
(1) Points
SELECT custid, companyname
FROM customers
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
(*)
SELECT orderid, orderdate, total
FROM orders
WHERE city = 'Nashville';
Correct Correct
39. The primary advantage of using JOIN ON is: Mark for Review
(1) Points
The join happens automatically based on matching column names and data types
It will display rows that do not meet the join condition
It permits columns with different names to be joined (*)
It permits columns that don't have matching data types to be joined
Correct Correct
40. Evaluate this SELECT statement:
SELECT a.lname || ', ' || a.fname as "Patient", b.lname || ', ' || b.fname as
"Physician", c.admission
FROM patient a
JOIN physician b
ON (b.physician_id = c.physician_id);
JOIN admission c
ON (a.patient_id = c.patient_id);
Which clause generates an error?
Mark for Review
(1) Points
JOIN physician b
ON (b.physician_id = c.physician_id); (*)
JOIN admission c
ON (a.patient_id = c.patient_id)
Correct Correct
Previous Page 4 of 10 Next Summary
Skip navigation elements to page contents
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. Which query will retrieve all the rows in the EMPLOYEES table,
even if there is no match in the DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
Incorrect Incorrect. Refer to Section 4
42. Which type of join returns rows from one table that have NO
direct match in the other table? Mark for Review
(1) Points
equijoin
self join
outer join (*)
natural join
Correct Correct
43. Which query represents the correct syntax for a left outer join?
Mark for Review
(1) Points
SELECT companyname, orderdate, total
FROM customers c
LEFT JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
OUTER JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER JOIN orders o
ON c.cust_id = o.cust_id;
(*)
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER orders o
ON c.cust_id = o.cust_id;
Correct Correct
Section 5 Lesson 1
(Answer all questions in this section)
44. Evaluate this SELECT statement:
SELECT MAX(salary), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The highest salary for all employees.
The highest salary in each department. (*)
The employees with the highest salaries.
The employee with the highest salary for each department.
Correct Correct
45. Group functions can be nested to a depth of? Mark for Review
(1) Points
three
four
two (*)
Group functions cannot be nested.
Correct Correct
46. What will the following SQL Statement do?
SELECT job_id, COUNT(*)
FROM employees
GROUP BY job_id;
Mark for Review
(1) Points
Displays all the employees and groups them by job.
Displays each job id and the number of people assigned to that job id. (*)
Displays only the number of job_ids.
Displays all the jobs with as many people as there are jobs.
Correct Correct
47. Which statement about group functions is true? Mark for Review
(1) Points
Group functions ignore null values. (*)
Group functions can only be used in a SELECT list.
Group functions can be used in a WHERE clause.
A query that includes a group function in the SELECT list must include a
GROUP BY clause.
Correct Correct
Section 5 Lesson 2
(Answer all questions in this section)
48. The TRUCKS table contains these columns:
TRUCKS
TYPE VARCHAR2(30)
YEAR DATE
MODEL VARCHAR2(20)
PRICE NUMBER(10)
Which SELECT statement will return the average price for the 4x4 model?
Mark for Review
(1) Points
SELECT AVG (price) FROM trucks WHERE model = '4x4'; (*)
SELECT AVG (price) FROM trucks WHERE model IS '4x4';
SELECT AVG(price) FROM trucks WHERE model IS 4x4;
SELECT AVG(price), model FROM trucks WHERE model IS '4x4';
Correct Correct
49. Which aggregate function can be used on a column of the DATE data
type? Mark for Review
(1) Points
AVG
MAX (*)
STDDEV
SUM
Correct Correct
50. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
NAME VARCHAR2(30)
LOCATION_ID NUMBER
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
(Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT location_id, MIN(AVG(order_amount)) (*)
Incorrect Incorrect. Refer to Section 5
Previous Page 5 of 10 Next Summary
Skip navigation elements to page contents
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE
Evaluate this SQL statement:
SELECT id_number, name, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Incorrect Incorrect. Refer to Section 6
62. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)
Which SELECT statement could you use to display the number of times each customer
made a payment between January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
(*)
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
Incorrect Incorrect. Refer to Section 6
63. The EMPLOYEES table contains the following columns:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
You want to create a report that includes each employee's last name, employee
identification number, date of hire and salary. The report should include only
those employees who have been with the company for more than one year and whose
salary exceeds $40,000.
Which of the following SELECT statements will accomplish this task?
Mark for Review
(1) Points
SELECT emp_id, lname, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT emp_id, lname, hire_date, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT emp_id, lname, hire_date, salary
FROM employees
WHERE salary > 40000
AND (sysdate-hire_date) / 365 > 1;
(*)
SELECT emp_id, lname, salary
FROM employees
WHERE salary > 40000
AND hire_date IN (sysdate-hire_date) / 365 > 1);
Correct Correct
64. Evaluate this statement:
SELECT department_id, AVG(salary)
FROM employees
WHERE job_id <> 69879
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000
ORDER BY department_id;
Which clauses restricts the result? Choose two.
Mark for Review
(1) Points
(Choose all correct answers)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Incorrect Incorrect. Refer to Section 6
65. Which statement about the GROUP BY clause is true? Mark for
Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause,
you use should a WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
Incorrect Incorrect. Refer to Section 6
66. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
Mark for Review
(1) Points
SELECT
FROM
WHERE
GROUP BY (*)
Correct Correct
67. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, mgr_id
FROM employee
GROUP BY dept_id, mgr_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a
group function?
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
WHERE salary > 100000
HAVING salary > 100000
Correct Correct
Section 6 Lesson 2
(Answer all questions in this section)
68. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use
subqueries? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id =
45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity >
0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity
> 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY
teacher_id);
Correct Correct
69. Using a subquery in which clause will return a syntax error?
Mark for Review
(1) Points
WHERE
FROM
HAVING
There are no places you cannot place subqueries. (*)
Incorrect Incorrect. Refer to Section 6
70. If you use the equality operator (=) with a subquery, how many
values can the subquery return? Mark for Review
(1) Points
only 1 (*)
up to 2
up to 5
unlimited
Correct Correct
Previous Page 7 of 10 Next Summary
Skip navigation elements to page contents
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE
Evaluate this SQL statement:
SELECT id_number, name, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Incorrect Incorrect. Refer to Section 6
62. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)
Which SELECT statement could you use to display the number of times each customer
made a payment between January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
(*)
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
Incorrect Incorrect. Refer to Section 6
63. The EMPLOYEES table contains the following columns:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
You want to create a report that includes each employee's last name, employee
identification number, date of hire and salary. The report should include only
those employees who have been with the company for more than one year and whose
salary exceeds $40,000.
Which of the following SELECT statements will accomplish this task?
Mark for Review
(1) Points
SELECT emp_id, lname, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT emp_id, lname, hire_date, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT emp_id, lname, hire_date, salary
FROM employees
WHERE salary > 40000
AND (sysdate-hire_date) / 365 > 1;
(*)
SELECT emp_id, lname, salary
FROM employees
WHERE salary > 40000
AND hire_date IN (sysdate-hire_date) / 365 > 1);
Correct Correct
64. Evaluate this statement:
SELECT department_id, AVG(salary)
FROM employees
WHERE job_id <> 69879
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000
ORDER BY department_id;
Which clauses restricts the result? Choose two.
Mark for Review
(1) Points
(Choose all correct answers)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Incorrect Incorrect. Refer to Section 6
65. Which statement about the GROUP BY clause is true? Mark for
Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause,
you use should a WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
Incorrect Incorrect. Refer to Section 6
66. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
Mark for Review
(1) Points
SELECT
FROM
WHERE
GROUP BY (*)
Correct Correct
67. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, mgr_id
FROM employee
GROUP BY dept_id, mgr_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a
group function?
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
WHERE salary > 100000
HAVING salary > 100000
Correct Correct
Section 6 Lesson 2
(Answer all questions in this section)
68. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use
subqueries? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id =
45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity >
0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity
> 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY
teacher_id);
Correct Correct
69. Using a subquery in which clause will return a syntax error?
Mark for Review
(1) Points
WHERE
FROM
HAVING
There are no places you cannot place subqueries. (*)
Incorrect Incorrect. Refer to Section 6
70. If you use the equality operator (=) with a subquery, how many
values can the subquery return? Mark for Review
(1) Points
only 1 (*)
up to 2
up to 5
unlimited
Correct Correct
Previous Page 7 of 10 Next Summary
Skip navigation elements to page contents
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 2
(Answer all questions in this section)
71. Which operator can be used with a multiple-row subquery? Mark
for Review
(1) Points
IN (*)
<>
LIKE
Correct Correct
72. Which of the following is TRUE regarding the order of subquery
execution? Mark for Review
(1) Points
The outer query is executed first
The subquery executes once after the main query
The subquery executes once before the main query (*)
The result of the main query is used with the subquery
Correct Correct
Section 6 Lesson 3
(Answer all questions in this section)
73. Examine the structure of the EMPLOYEE, DEPARTMENT, and ORDERS
tables.
EMPLOYEE
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
DEPARTMENT
DEPARTMENT_ID NUMBER(9)
DEPARTMENT_NAME VARCHAR2(25)
CREATION_DATE DATE
ORDERS
ORDER_ID NUMBER(9)
EMPLOYEE_ID NUMBER(9)
DATE DATE
CUSTOMER_ID NUMBER(9)
You want to display all employees who had an order after the Sales department was
established. Which of the following constructs would you use?
Mark for Review
(1) Points
a group function
a single-row subquery (*)
the HAVING clause
a MERGE statement
Correct Correct
74. Which statement about the <> operator is true? Mark for Review
(1) Points
The <> operator is NOT a valid SQL operator.
The <> operator CANNOT be used in a single-row subquery.
The <> operator returns the same result as the ANY operator in a subquery.
The <> operator can be used when a single-row subquery returns only one row.
(*)
Correct Correct
75. If a single-row subquery returns a null value and uses the
equality comparison operator, what will the outer query return? Mark for Review
(1) Points
no rows (*)
all the rows in the table
a null value
an error
Correct Correct
Section 6 Lesson 4
(Answer all questions in this section)
76. Which statement about the ANY operator when used with a multiple-
row subquery is true? Mark for Review
(1) Points
The ANY operator compares every value returned by the subquery. (*)
The ANY operator can be used with the DISTINCT keyword.
The ANY operator is a synonym for the ALL operator.
The ANY operator can be used with the LIKE and IN operators.
Correct Correct
77. Which of the following best describes the meaning of the ANY
operator? Mark for Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
Equal to each value in the list
Incorrect Incorrect. Refer to Section 6
78. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT payment_date, customer_id, payment_amount
FROM payment
WHERE payment_id =
(SELECT payment_id
 FROM payment
 WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?
Mark for Review
(1) Points
Remove the subquery WHERE clause.
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Include the PAYMENT_ID column in the select list of the outer query.
Remove the single quotes around the date value in the inner query WHERE
clause.
Incorrect Incorrect. Refer to Section 6
79. Which best describes a multiple-row subquery? Mark for Review
(1) Points
A query that returns only one row from the inner SELECT statement
A query that returns one or more rows from the inner SELECT statement (*)
A query that returns only one column value from the inner SELECT statement
A query that returns one or more column values from the inner SELECT
statement
Correct Correct
80. Which operator or keyword cannot be used with a multiple-row
subquery? Mark for Review
(1) Points
ALL
ANY
= (*)
>
Correct Correct
Previous Page 8 of 10 Next Summary
Skip navigation elements to page contents
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. Which statement about single-row and multiple-row subqueries is
true? Mark for Review
(1) Points
Multiple-row subqueries cannot be used with the LIKE operator. (*)
Single-row operators can be used with both single-row and multiple-row
subqueries.
Multiple-row subqueries can be used with both single-row and multiple-row
operators.
Multiple-row subqueries can only be used in SELECT statements.
Correct Correct
82. Evaluate this SELECT statement:
SELECT student_id, last_name, first_name
FROM student
WHERE major_id NOT IN
(SELECT major_id
 FROM majors
 WHERE department_head_id = 30 AND title = 'ADJUNCT');
What would happen if the inner query returned a NULL value row?
Mark for Review
(1) Points
A syntax error would be returned.
No rows would be returned from the STUDENT table. (*)
All the rows in the STUDENT table would be displayed.
Only the rows with STUDENT_ID values equal to NULL would be displayed.
Correct Correct
83. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is
used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Correct Correct
84. You are looking for Executive information using a subquery. What
will the following SQL statement display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id
 FROM departments
 WHERE department_name = 'Executive');
Mark for Review
(1) Points
The department ID, department name and last name for every employee in the
Executive department.
The department ID, last name, department name for every Executive in the
employees table.
The department ID, last name, job ID from departments for Executive
employees.
The department ID, last name, job ID for every employee in the Executive
department. (*)
Correct Correct
85. Examine the structures of the PARTS and MANUFACTURERS tables:
PARTS:
PARTS_ID VARCHAR2(25)
PK PARTS_NAME VARCHAR2(50)
MANUFACTURERS_ID NUMBER
COST NUMBER(5,2)
PRICE NUMBER(5,2)
MANUFACTURERS:
ID NUMBER
PK NAME VARCHAR2(30)
LOCATION VARCHAR2(20)
Which SQL statement correctly uses a subquery?
Mark for Review
(1) Points
UPDATE parts SET price = price * 1.15
WHERE manufacturers_id =
(SELECT id
 FROM manufacturers
 WHERE UPPER(location) IN('ATLANTA ', 'BOSTON ', 'DALLAS '));
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id !=
(SELECT id
 FROM manufacturers
 WHERE LOWER(name) = 'cost plus');
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id IN
(SELECT id
 FROM manufacturers m
 JOIN part p ON (m.id = p.manufacturers_id));
(*)
SELECT parts_name
FROM
(SELECT AVG(cost)
 FROM manufacturers)
 WHERE cost > AVG(cost);
Correct Correct
86. You need to create a SELECT statement that contains a multiple-
row subquery, which comparison operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
Correct Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. Using the INSERT statement, and assuming that a column can accept
null values, how can you implicitly insert a null value in a column? Mark for
Review
(1) Points
Use the NULL keyword.
Use the ON clause
Omit the column in the column list. (*)
It is not possible to implicitly insert a null value in a column.
Correct Correct
88. Which statement about the VALUES clause of an INSERT statement is
true? Mark for Review
(1) Points
If no column list is specified, then the values must be in the order the
columns are specified in the table. (*)
The VALUES clause in an INSERT statement is optional.
Character, date, and numeric data must be enclosed within single quotes in
the VALUES clause.
To specify a null value in the VALUES clause, use an empty string (' ').
Correct Correct
89. The STUDENTS table contains these columns:
STU_ID NUMBER(9) NOT NULL
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
DOB DATE
STU_TYPE_ID VARCHAR2(1) NOT NULL
ENROLL_DATE DATE
You create another table, named FT_STUDENTS, with an identical structure.You want
to insert all full-time students, who have a STU_TYPE_ID value of "F", into the new
table. You execute this INSERT statement:
INSERT INTO ft_students
(SELECT stu_id, last_name, first_name, dob, stu_type_id, enroll_date
FROM students
WHERE UPPER(stu_type_id) = 'F');
What is the result of executing this INSERT statement?
Mark for Review
(1) Points
All full-time students are inserted into the FT_STUDENTS table. (*)
An error occurs because the FT_STUDENTS table already exists.
An error occurs because you CANNOT use a subquery in an INSERT statement.
An error occurs because the INSERT statement does NOT contain a VALUES
clause.
Correct Correct
90. You have been instructed to add a new customer to the CUSTOMERS
table. Because the new customer has not had a credit check, you should not add an
amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
Mark for Review
(1) Points
(Choose all correct answers)
INSERT INTO customers (cust_id, company, poc, location)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0,
'tflanders', 'samerica');
INSERT INTO customers
VALUES (200, InterCargo, 0, tflanders, samerica);
Correct Correct
Previous Page 9 of 10 Next Summary
Skip navigation elements to page contents
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. Which statement about single-row and multiple-row subqueries is
true? Mark for Review
(1) Points
Multiple-row subqueries cannot be used with the LIKE operator. (*)
Single-row operators can be used with both single-row and multiple-row
subqueries.
Multiple-row subqueries can be used with both single-row and multiple-row
operators.
Multiple-row subqueries can only be used in SELECT statements.
Correct Correct
82. Evaluate this SELECT statement:
SELECT student_id, last_name, first_name
FROM student
WHERE major_id NOT IN
(SELECT major_id
 FROM majors
 WHERE department_head_id = 30 AND title = 'ADJUNCT');
What would happen if the inner query returned a NULL value row?
Mark for Review
(1) Points
A syntax error would be returned.
No rows would be returned from the STUDENT table. (*)
All the rows in the STUDENT table would be displayed.
Only the rows with STUDENT_ID values equal to NULL would be displayed.
Correct Correct
83. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is
used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Correct Correct
84. You are looking for Executive information using a subquery. What
will the following SQL statement display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id
 FROM departments
 WHERE department_name = 'Executive');
Mark for Review
(1) Points
The department ID, department name and last name for every employee in the
Executive department.
The department ID, last name, department name for every Executive in the
employees table.
The department ID, last name, job ID from departments for Executive
employees.
The department ID, last name, job ID for every employee in the Executive
department. (*)
Correct Correct
85. Examine the structures of the PARTS and MANUFACTURERS tables:
PARTS:
PARTS_ID VARCHAR2(25)
PK PARTS_NAME VARCHAR2(50)
MANUFACTURERS_ID NUMBER
COST NUMBER(5,2)
PRICE NUMBER(5,2)
MANUFACTURERS:
ID NUMBER
PK NAME VARCHAR2(30)
LOCATION VARCHAR2(20)
Which SQL statement correctly uses a subquery?
Mark for Review
(1) Points
UPDATE parts SET price = price * 1.15
WHERE manufacturers_id =
(SELECT id
 FROM manufacturers
 WHERE UPPER(location) IN('ATLANTA ', 'BOSTON ', 'DALLAS '));
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id !=
(SELECT id
 FROM manufacturers
 WHERE LOWER(name) = 'cost plus');
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id IN
(SELECT id
 FROM manufacturers m
 JOIN part p ON (m.id = p.manufacturers_id));
(*)
SELECT parts_name
FROM
(SELECT AVG(cost)
 FROM manufacturers)
 WHERE cost > AVG(cost);
Correct Correct
86. You need to create a SELECT statement that contains a multiple-
row subquery, which comparison operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
Correct Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. Using the INSERT statement, and assuming that a column can accept
null values, how can you implicitly insert a null value in a column? Mark for
Review
(1) Points
Use the NULL keyword.
Use the ON clause
Omit the column in the column list. (*)
It is not possible to implicitly insert a null value in a column.
Correct Correct
88. Which statement about the VALUES clause of an INSERT statement is
true? Mark for Review
(1) Points
If no column list is specified, then the values must be in the order the
columns are specified in the table. (*)
The VALUES clause in an INSERT statement is optional.
Character, date, and numeric data must be enclosed within single quotes in
the VALUES clause.
To specify a null value in the VALUES clause, use an empty string (' ').
Correct Correct
89. The STUDENTS table contains these columns:
STU_ID NUMBER(9) NOT NULL
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
DOB DATE
STU_TYPE_ID VARCHAR2(1) NOT NULL
ENROLL_DATE DATE
You create another table, named FT_STUDENTS, with an identical structure.You want
to insert all full-time students, who have a STU_TYPE_ID value of "F", into the new
table. You execute this INSERT statement:
INSERT INTO ft_students
(SELECT stu_id, last_name, first_name, dob, stu_type_id, enroll_date
FROM students
WHERE UPPER(stu_type_id) = 'F');
What is the result of executing this INSERT statement?
Mark for Review
(1) Points
All full-time students are inserted into the FT_STUDENTS table. (*)
An error occurs because the FT_STUDENTS table already exists.
An error occurs because you CANNOT use a subquery in an INSERT statement.
An error occurs because the INSERT statement does NOT contain a VALUES
clause.
Correct Correct
90. You have been instructed to add a new customer to the CUSTOMERS
table. Because the new customer has not had a credit check, you should not add an
amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
Mark for Review
(1) Points
(Choose all correct answers)
INSERT INTO customers (cust_id, company, poc, location)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0,
'tflanders', 'samerica');
INSERT INTO customers
VALUES (200, InterCargo, 0, tflanders, samerica);
Correct Correct
Previous Page 9 of 10 Next Summary
Skip navigation elements to page contents
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 7 Lesson 2
(Answer all questions in this section)
91. The EMPLOYEES table contains the following columns:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You need to increase the salary for all employees in department 10 by 10 percent.
You also need to increase the bonus for all employees in department 10 by 15
percent. Which statement should you use?
Mark for Review
(1) Points
UPDATE employees
SET salary = salary * 1.10, bonus = bonus * 1.15
WHERE dept = 10;
(*)
UPDATE employees
SET salary = salary * 1.10 AND bonus = bonus * 1.15
WHERE dept = 10;
UPDATE employees
SET (salary = salary * 1.10) SET (bonus = bonus * 1.15)
WHERE dept = 10;
UPDATE employees
SET salary = salary * .10, bonus = bonus * .15
WHERE dept = 10;
Correct Correct
92. One of the sales representatives, Janet Roper, has informed you
that she was recently married, and she has requested that you update her name in
the employee database. Her new last name is Cooper. Janet is the only person with
the last name of Roper that is employed by the company. The EMPLOYEES table
contains these columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
Correct Correct
93. What keyword in an UPDATE statement speficies the columns you
want to change? Mark for Review
(1) Points
SELECT
WHERE
SET (*)
HAVING
Correct Correct
94. You need to update the area code of employees that live in
Atlanta . Evaluate this partial UPDATE statement:
UPDATE employee
SET area_code = 770
Which of the following should you include in your UPDATE statement to achieve the
desired results?
Mark for Review
(1) Points
UPDATE city = Atlanta;
SET city = 'Atlanta';
WHERE city = 'Atlanta'; (*)
LIKE 'At%';
Correct Correct
95. Examine the structures of the PLAYERS, MANAGERS, and TEAMS
tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
Mark for Review
(1) Points
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner
(*)
To display each player, their manager, and their team name for all teams with
a id value greater than 5000
Incorrect Incorrect. Refer to Section 7
96. What would happen if you issued a DELETE statement without a
WHERE clause? Mark for Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
Correct Correct
97. You want to enter a new record into the CUSTOMERS table. Which
two commands can be used to create new rows? Mark for Review
(1) Points
INSERT, CREATE
MERGE, CREATE
INSERT, MERGE (*)
INSERT, UPDATE
Correct Correct
98. When the WHERE clause is missing in a DELETE statement, what is
the result? Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Correct Correct
99. You need to remove a row from the EMPLOYEE table. Which statement
would you use? Mark for Review
(1) Points
UPDATE with a WHERE clause
INSERT with a WHERE clause
DELETE with a WHERE clause (*)
MERGE with a WHERE clause
Correct Correct
100. Which of the following represents the correct syntax for an
INSERT statement? Mark for Review
(1) Points
INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN
37777;
INSERT INTO customers VALUES '3178' 'J.' 'Smith' '123 Main Street'
'Nashville' 'TN' '37777';
INSERT INTO customers VALUES ('3178', 'J.', 'Smith', '123 Main Street',
'Nashville', 'TN', '37777'); (*)
INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN,
37777;
Correct Correct
Previous Page 10 of 10 Summary
Test: Mid Term Exam Semester 2 - Part II
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Part II of the Semester 2 Mid Term Exam covers Sections 5-7 of Database
Programming with SQL curriculum.
Section 5
1. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
You issue this SELECT statement:
SELECT COUNT(category)
FROM styles;
Which value is displayed?
Mark for Review
(1) Points
7 (*)
The statement will NOT execute successfully.
Correct
2. Which statement about the COUNT function is true? Mark for Review
(1) Points
The COUNT function ignores duplicates by default.
The COUNT function always ignores null values by default. (*)
The COUNT function can be used to find the maximum value in each column.
The COUNT function can be used to determine the number of unique, non-null
values in a column.
Correct
3. Evaluate this SELECT statement:
SELECT COUNT(*)
FROM employees
WHERE salary > 30000;
Which results will the query display?
Mark for Review
(1) Points
The number of employees that have a salary less than 30000.
The total of the SALARY column for all employees that have a salary greater
than 30000.
The number of rows in the EMPLOYEES table that have a salary greater than
30000. (*)
The query generates an error and returns no results.
Correct
4. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater than $50,000?
Which SELECT would you use?
Mark for Review
(1) Points
SELECT * FROM employees
WHERE salary > 50000;
SELECT * FROM employees
WHERE salary < 50000;
SELECT COUNT(*)
FROM employees
WHERE salary < 50000;
SELECT COUNT(*)
FROM employees
WHERE salary > 50000;
(*)
SELECT COUNT(*)
FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
Correct
5. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
FROM products;
What happens when this statement is issued?
Mark for Review
(1) Points
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are averaged
together.
An error occurs. (*)
Correct
6. The TRUCKS table contains these columns:
TRUCKS:
TYPE VARCHAR2(30)
YEAR DATE
MODEL VARCHAR2(20)
PRICE NUMBER(10)
Which SELECT statement will return the average price for the 4x4 model?
Mark for Review
(1) Points
SELECT AVG(price)
FROM trucks
WHERE model = '4x4';
(*)
SELECT AVG(price)
FROM trucks
WHERE model IS '4x4';
SELECT AVG(price)
FROM trucks
WHERE model IS 4x4;
SELECT AVG(price), model
FROM trucks
WHERE model IS '4x4';
Correct
7. Which group function would you use to display the total of all salary values
in the EMPLOYEES table? Mark for Review
(1) Points
SUM (*)
AVG
COUNT
MAX
Correct
8. The AVG, SUM, VARIANCE, and STDDEV functions can be used with which of the
following? Mark for Review
(1) Points
Only numeric data types (*)
Integers only
Any data type
All except numeric
Correct
9. You need to compute the total salary for all employees in department 10.
Which group function will you use? Mark for Review
(1) Points
MAX
SUM (*)
VARIANCE
COUNT
Correct
Section 6
10. Which best describes a single-row subquery? Mark for Review
(1) Points
A query that returns only one row from the inner SELECT statement (*)
A query that returns one or more rows from the inner SELECT statement
A query that returns only one column value from the inner SELECT statement
A query that returns one or more column values from the inner SELECT statement
Correct
Section 6
11. Which comparison operator is best used with a single-row subquery? Mark for
Review
(1) Points
ANY
ALL
<> (*)
IN
Correct
12. If a single-row subquery returns a null value and uses the equality
comparison operator, what will the outer query return? Mark for Review
(1) Points
No rows (*)
All the rows in the table
A null value
An error
Correct
13. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than
$30,000 and more than $50,000.
All employees who work in a department with employees who earn more than
$30,000, but less than $50,000. (*)
Correct
14. Evaluate this SELECT statement:
SELECT player_id, name
FROM players
WHERE team_id IN
(SELECT team_id
FROM teams
WHERE team_id > 300 AND salary_cap > 400000);
What would happen if the inner query returned a NULL value?
Mark for Review
(1) Points
No rows would be returned by the outer query. (*)
A syntax error in the outer query would be returned.
A syntax error in the inner query would be returned.
All the rows in the PLAYER table would be returned by the outer query.
Incorrect. Refer to Section 6
15. Evaluate this SELECT statement that includes a subquery:
SELECT last_name, first_name
FROM customer
WHERE area_code IN
(SELECT area_code
FROM sales
WHERE salesperson_id = 20);
Which statement is true about the given subquery?
Mark for Review
(1) Points
The outer query executes before the nested subquery.
The results of the inner query are returned to the outer query. (*)
An error occurs if the either the inner or outer queries do not return a value.
Both the inner and outer queries must return a value, or an error occurs.
Incorrect. Refer to Section 6
16. Which comparison operator would you use to compare a value to every value
returned by a subquery? Mark for Review
(1) Points
SOME
ANY
ALL (*)
IN
Correct
17. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT customer_id, payment_type
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
Mark for Review
(1) Points
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
Change the comparison operator to a single-row operator.
Incorrect. Refer to Section 6
18. Which of the following best describes the meaning of the ANY operator? Mark
for Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to the first value returned by the subquery
Equal to each value in the list
Correct
19. Which statement about single-row and multiple-row subqueries is true? Mark
for Review
(1) Points
Multiple-row subqueries cannot be used with the LIKE operator. (*)
Single-row operators can be used with both single-row and multiple-row
subqueries.
Multiple-row subqueries can be used with both single-row and multiple-row
operators.
Multiple-row subqueries can only be used in SELECT statements.
Correct
20. Which operator or keyword cannot be used with a multiple-row subquery? Mark
for Review
(1) Points
ALL
ANY
= (*)
>
Incorrect. Refer to Section 6
Section 6
21. Which of the following statements contains a comparison operator that is
used to restrict rows based on a list of values returned from an inner query? Mark
for Review
(1) Points
SELECT description
FROM d_types
WHERE code
IN (SELECT type_code FROM d_songs);
SELECT description
FROM d_types
WHERE code = ANY (SELECT type_code FROM d_songs);
SELECT description
FROM d_types
WHERE code <> ALL (SELECT type_code FROM d_songs);
All of the above. (*)
Correct
22. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT payment_date, customer_id, payment_amount FROM payment
WHERE payment_id =
(SELECT payment_id FROM payment
WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?
Mark for Review
(1) Points
Remove the subquery WHERE clause.
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Include the PAYMENT_ID column in the select list of the outer query.
Remove the single quotes around the date value in the inner query WHERE clause.
Incorrect. Refer to Section 6
23. You are looking for Executive information using a subquery. What will the
following SQL statement display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id FROM departments WHERE department_name = 'Executive');
Mark for Review
(1) Points
The department ID, department name and last name for every employee in the
Executive department.
The department ID, last name, department name for every Executive in the
employees table.
The department ID, last name, job ID from departments for Executive employees.
The department ID, last name, job ID for every employee in the Executive
department. (*)
Correct
24. You need to display all the players whose salaries are greater than or equal
to John Brown's salary. Which comparison operator should you use? Mark for Review
(1) Points
>
<=
>= (*)
Correct
25. If you use the equality operator (=) with a subquery, how many values can
the subquery return? Mark for Review
(1) Points
Only 1 (*)
Up to 2
Up to 5
Unlimited
Correct
26. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use
subqueries? (Choose two)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id =
45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity >
0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity
> 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY
teacher_id);
Correct
27. Which statement about subqueries is true? Mark for Review
(1) Points
Subqueries should be enclosed in double quotation marks.
Subqueries cannot contain group functions.
Subqueries are often used in a WHERE clause to return values for an unknown
conditional value. (*)
Subqueries generally execute last, after the main or outer query executes.
Incorrect. Refer to Section 6
28. Examine the structures of the CUSTOMER and ORDER_HISTORY tables:
CUSTOMER
CUSTOMER_ID NUMBER(5)
NAME VARCHAR2(25)
CREDIT_LIMIT NUMBER(8,2)
OPEN_DATE DATE
ORDER_HISTORY
ORDER_ID NUMBER(5)
CUSTOMER_ID NUMBER(5)
ORDER_DATE DATE
TOTAL NUMBER(8,2)
Which of the following scenarios would require a subquery to return the desired
results?
Mark for Review
(1) Points
You need to display the date each customer account was opened.
You need to display each date that a customer placed an order.
You need to display all the orders that were placed on a certain date.
You need to display all the orders that were placed on the same day as order
number 25950. (*)
Incorrect. Refer to Section 6
29. The MANUFACTURER table contains these columns:
MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
LOCATION_ID NUMBER
You need to display the number of unique types of manufacturers at each location.
Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
(*)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
Incorrect. Refer to Section 6
30. Evaluate this statement:
SELECT department_id, AVG(salary)
FROM employees
WHERE job_id <> 69879
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000
ORDER BY department_id;
Which clauses restricts the result? (Choose two)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Incorrect. Refer to Section 6
Section 6
31. Evaluate this SELECT statement:
SELECT COUNT(emp_id), mgr_id, dept_id
FROM employees
WHERE status = 'I'
GROUP BY dept_id
HAVING salary > 30000
ORDER BY 2;
Why does this statement return a syntax error?
Mark for Review
(1) Points
MGR_ID must be included in the GROUP BY clause. (*)
The HAVING clause must specify an aggregate function.
A single query cannot contain a WHERE clause and a HAVING clause.
The ORDER BY clause must specify a column name in the EMPLOYEE table.
Incorrect. Refer to Section 6
32. The EMPLOYEES table contains the following columns:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPTARTMENT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
You want to create a report that includes each employee's last name, employee
identification number, date of hire and salary. The report should include only
those employees who have been with the company for more than one year and whose
salary exceeds $40,000.
Which of the following SELECT statements will accomplish this task?
Mark for Review
(1) Points
SELECT employee_id, last_name, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT employee_id, last_name, hire_date, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT employee_id, last_name, hire_date, salary
FROM employees
WHERE salary > 40000
AND (sysdate-hire_date) / 365 > 1;
(*)
SELECT employee_id, last_name, salary
FROM employees
WHERE salary > 40000
AND hire_date IN (sysdate-hire_date) / 365 > 1);
Correct
33. You want to write a report that returns the average salary of all employees
in the company, sorted by departments.
The EMPLOYEES table contains the following columns:
EMPLOYEES
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPTARTMENT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which SELECT statement will return the information that you require?
Mark for Review
(1) Points
SELECT salary (AVG)
FROM employees
GROUP BY department;
SELECT AVG (salary)
FROM employees
GROUP BY department;
(*)
SELECT AVG (salary)
FROM employees
BY department;
SELECT AVG salary
FROM employees
BY department;
Correct
34. Evaluate this SELECT statement:
SELECT SUM(salary), department_id, manager_id
FROM employees
GROUP BY department_id, manager_id;
Which SELECT clause allows you to restrict the rows returned, based on a group
function?
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
WHERE salary > 100000
HAVING salary > 100000
Incorrect. Refer to Section 6
35. The EMPLOYEES table contains these columns:
ID_NUMBER NUMBER Primary Key
NAME VARCHAR2 (30)
DEPARTMENT_ID NUMBER
SALARY NUMBER (7,2)
HIRE_DATE DATE
Evaluate this SQL statement:
SELECT id_number, name, department_id, SUM(salary)
FROM employees
WHERE salary > 25000
GROUP BY department_id, id_number, name
ORDER BY hire_date;
Why will this statement cause an error?
Mark for Review
(1) Points
The HAVING clause is missing.
The WHERE clause contains a syntax error.
The SALARY column is NOT included in the GROUP BY clause.
The HIRE_DATE column is NOT included in the GROUP BY clause. (*)
Incorrect. Refer to Section 6
36. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)
Which SELECT statement could you use to display the number of times each customer
made a payment between January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
(*)
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
Incorrect. Refer to Section 6
Section 7
37. You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table.
What could you use in the INSERT statement to accomplish this task? Mark for
Review
(1) Points
An ON clause
A SET clause
A subquery (*)
A function
Correct
38. Using the INSERT statement, and assuming that a column can accept null
values, how can you implicitly insert a null value in a column? Mark for Review
(1) Points
Use the NULL keyword.
Use the ON clause
Omit the column in the column list. (*)
It is not possible to implicitly insert a null value in a column.
Correct
39. Which statement about the VALUES clause of an INSERT statement is true?
Mark for Review
(1) Points
If no column list is specified, then the values must be in the order the
columns are specified in the table. (*)
The VALUES clause in an INSERT statement is optional.
Character, date, and numeric data must be enclosed within single quotes in the
VALUES clause.
To specify a null value in the VALUES clause, use an empty string (" ").
Correct
40. You have been instructed to add a new customer to the CUSTOMERS table.
Because the new customer has not had a credit check, you should not add an amount
to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
Mark for Review
(1) Points
(Choose all correct answers)
INSERT INTO customers (cust_id, company, poc, location)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');
(*)
INSERT INTO customers
VALUES (cust_id, company, credit, poc, location) (200, 'InterCargo', 0,
'tflanders', 'samerica');
INSERT INTO customers
VALUES (200, InterCargo, 0, tflanders, samerica);
Correct
Section 7
41. The EMPLOYEES table contains the following columns:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in
department 10 to equal the new salary of employee number 89898. Currently, all
employees in department 10 have the same salary value. Which statement should you
execute?
Mark for Review
(1) Points
UPDATE employees
SET salary = SELECT salary FROM employees WHERE employee_id = 89898;
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898);
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898)
WHERE department_id = 10;
(*)
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898 AND
deptartment_id = 10);
Correct
42. Which of the following represents the correct syntax for an INSERT
statement? Mark for Review
(1) Points
INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN 37777;
INSERT INTO customers VALUES '3178' 'J.' 'Smith' '123 Main Street' 'Nashville'
'TN' '37777';
INSERT INTO customers VALUES ('3178', 'J.', 'Smith', '123 Main Street',
'Nashville', 'TN', '37777'); (*)
INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN, 37777;
Correct
43. You need to update the area code of employees that live in Atlanta. Evaluate
this partial UPDATE statement:
UPDATE employee
SET area_code = 770
Which of the following should you include in your UPDATE statement to achieve the
desired results?
Mark for Review
(1) Points
UPDATE city = Atlanta;
SET city = 'Atlanta';
WHERE city = 'Atlanta'; (*)
LIKE 'At%';
Correct
44. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta.
Which script should you use?
Mark for Review
(1) Points
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ATLANTA');
(*)
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
DELETE FROM products
WHERE supplier_id =
(SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ATLANTA');
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ALANTA');
Incorrect. Refer to Section 7
45. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5)
NAME VARCHAR2(25)
SUBJECT_ID NUMBER(5)
HIRE_DATE DATE
SALARY NUMBER(9,2)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER(5)
TEACHER_ID NUMBER(5)
START_DATE DATE
MAX_CAPACITY NUMBER(3)
Which scenario would require a subquery to return the desired results?
Mark for Review
(1) Points
You need to display the start date for each class taught by a given teacher.
You need to create a report to display the teachers who were hired more than
five years ago.
You need to display the names of the teachers who teach classes that start
within the next week.
You need to create a report to display the teachers who teach more classes than
the average number of classes taught by each teacher. (*)
Correct
46. Which two commands can be used to modify existing data in a database row?
Mark for Review
(1) Points
(Choose all correct answers)
DELETE
MERGE (*)
SELECT
UPDATE (*)
Correct
47. One of the sales representatives, Janet Roper, has informed you that she was
recently married, and she has requested that you update her name in the employee
database. Her new last name is Cooper. Janet is the only person with the last name
of Roper that is employed by the company. The EMPLOYEES table contains these
columns and all data is stored in lowercase:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET last_name = 'cooper'
WHERE last_name = 'roper';
(*)
UPDATE employees last_name = 'cooper'
WHERE last_name = 'roper';
UPDATE employees
SET last_name = 'roper'
WHERE last_name = 'cooper';
UPDATE employees
SET cooper = 'last_name'
WHERE last_name = 'roper';
Correct
48. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the
EMPLOYEES table using one UPDATE statement. Which clause should you include in the
UPDATE statement to update multiple columns? Mark for Review
(1) Points
The USING clause
The ON clause
The WHERE clause
The SET clause (*)
Correct
49. When the WHERE clause is missing in a DELETE statement, what is the result?
Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Correct
50. You want to enter a new record into the CUSTOMERS table. Which two commands
can be used to create new rows? Mark for Review
(1) Points
INSERT, CREATE
MERGE, CREATE
INSERT, MERGE (*)
INSERT, UPDATE
Correct
Test: Mid Term Exam Semester 2 - Part I
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Part I of the Semester 2 Mid Term Exam covers Sections 1-4, and the Review of
Joins in Section 5, of Database Programming with SQL curriculum.
Section 1
1. Which SELECT statement will return a numeric value? Mark for Review
(1) Points
SELECT SYSDATE + 600 / 24
FROM employee;
SELECT ROUND(hire_date, DAY)
FROM employee;
SELECT (SYSDATE - hire_date) / 7
FROM employee;
(*)
SELECT SYSDATE - 7
FROM employee;
Correct
2. You need to subtract three months from the current date. Which function
should you use? Mark for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Correct
3. You need to display the current year as a character value (for example: Two
Thousand and One). Which element would you use? Mark for Review
(1) Points
RR
YY
YYYY
YEAR (*)
Correct
4. You want to create a report that displays all orders and their amounts that
were placed during the month of January. You want the orders with the highest
amounts to appear first. Which query should you issue? Mark for Review
(1) Points
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
ORDER BY total;
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
(*)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
Correct
5. Which function would you use to return the current database server date and
time? Mark for Review
(1) Points
DATE
SYSDATE (*)
DATETIME
CURRENTDATE
Correct
6. You need to display each employee's name in all uppercase letters. Which
function should you use? Mark for Review
(1) Points
CASE
UCASE
UPPER (*)
TOUPPER
Correct
7. Which SQL function can be used to remove heading or trailing characters (or
both) from a character string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
Correct
8. The PRICE table contains this data:
PRODUCT_ID MANUFACTURER_ID
86950 59604
You query the database and return the value 95. Which script did you use?
Mark for Review
(1) Points
SELECT SUBSTR(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
(*)
SELECT LENGTH(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
SELECT SUBSTR(product_id, -1, 3)
FROM price
WHERE manufacturer_id = 59604;
SELECT TRIM(product_id, -3, 2)
FROM price
WHERE manufacturer_id = 59604;
Correct
9. Which functions can be used to manipulate character, number, and date column
values? Mark for Review
(1) Points
CONCAT, RPAD, and TRIM (*)
UPPER, LOWER, and INITCAP
ROUND, TRUNC, and MOD
ROUND, TRUNC, and ADD_MONTHS
Correct
10. Which three statements about functions are true? (Choose three.) Mark for
Review
(1) Points
(Choose all correct answers)
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the
nearest whole number. (*)
The CONCAT function can only be used on character strings, not on numbers.
The SUBSTR character function returns a portion of a string beginning at a
defined character position to a specified length. (*)
Correct
11. Evaluate this SELECT statement:
SELECT LENGTH(email)
FROM employee;
What will this SELECT statement display?
Mark for Review
(1) Points
The longest e-mail address in the EMPLOYEE table
The email address of each employee in the EMPLOYEE table
The number of characters for each value in the EMAIL column in the employees
table (*)
The maximum number of characters allowed in the EMAIL column
Correct
12. Which SQL function is used to return the position where a specific character
string begins within a larger character string? Mark for Review
(1) Points
CONCAT
INSTR (*)
LENGTH
SUBSTR
Correct
13. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'?
Mark for Review
(1) Points
SELECT TRUNC(hire_date, 'MONTH')
FROM employee;
(*)
SELECT ROUND(hire_date, 'MONTH')
FROM employee;
SELECT ROUND(hire_date, 'MON')
FROM employee;
SELECT TRUNC(hire_date, 'MI')
FROM employee;
Correct
14. Which two functions can be used to manipulate number or date column values,
but NOT character column values? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
Correct
15. You issue this SQL statement:
SELECT TRUNC(751.367,-1) FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
700
750 (*)
751
751.3
Correct
Section 2
16. The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
SELECT NVL(10 / price, 4)
FROM PRODUCT;
What would happen if the PRICE column contains null values?
Mark for Review
(1) Points
The statement would fail because values cannot be divided by 4.
A value of 4 would be displayed. (*)
A value of 0 would be displayed.
The statement would fail because values cannot be divided by null.
Correct
17. You need to replace null values in the DEPTARTMENT_ID column with the text
"N/A". Which functions should you use? Mark for Review
(1) Points
TO CHAR and NVL (*)
TO_CHAR and NULL
TO_CHAR and NULLIF
TO_NUMBER and NULLIF
Correct
18. Which of the following General Functions will return the first non-null
expression in the expression list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
COALESCE (*)
Correct
19. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
Evaluate this SELECT statement:
SELECT style_id, style_name, category, cost
FROM styles WHERE style_name LIKE 'SANDAL' AND NVL(cost, 0) < 15.00
ORDER BY category, cost;
Which result will the query provide?
Mark for Review
(1) Points
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
869506 SANDAL 89690 15.00
STYLE_ID STYLE_NAME CATEGORY COST
968950 SANDAL 85909 10.00
895840 SANDAL 85940 12.00
758960 SANDAL 86979
(*)
Correct
20. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script
should you use to display the salaries in format: "$45,000.00"?
Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees;
(*)
Correct
21. If you use the RR format when writing a query using the date 27-OCT-17 and the
year is 2001, what year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Correct
22. Which best describes the TO_CHAR function? Mark for Review
(1) Points
The TO_CHAR function can be used to specify meaningful column names in an SQL
statement's result set.
The TO_CHAR function can be used to remove text from column data that will be
returned by the database.
The TO_CHAR function can be used to display dates and numbers according to
formatting conventions that are supported by Oracle. (*)
The TO_CHAR function can only be used on Date columns.
Incorrect. Refer to Section 2
23. Which two statements concerning SQL functions are true? (Choose two.) Mark
for Review
(1) Points
(Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type.
(*)
Single-row functions manipulate groups of rows to return one result per group
of rows.
Correct
24. Which SQL Statement should you use to display the prices in this format:
"$00.30"? Mark for Review
(1) Points
SELECT TO_CHAR(price, '$99,900.99')
FROM product;
(*)
SELECT TO_CHAR(price, '$99,911.99')
FROM product;
SELECT TO_CHAR(price, '$99,990.99')
FROM product;
SELECT TO_NUMBER(price, '$99,900.99')
FROM product;
Correct
25. Which three statements concerning explicit data type conversions are true?
(Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
Use the TO_NUMBER function to convert a number to a character string.
Use the TO_DATE function to convert a character string to a date value. (*)
Use the TO_NUMBER function to convert a character string of digits to a number.
(*)
Use the TO_DATE function to convert a date value to character string or number.
Use the TO_CHAR function to convert a number or date value to character string.
(*)
Use the TO_CHAR function to convert a character string to a number or date
value.
Correct
Section 3
26. Evaluate this SELECT statement:
SELECT p.player_id, m.last_name, m.first_name, t.team_name
FROM player p
LEFT OUTER JOIN player m ON (p.manager_id = m.player_id)
LEFT OUTER JOIN team t ON (p.team_id = t.team_id);
Which join is evaluated first?
Mark for Review
(1) Points
The self-join of the player table (*)
The join between the player table and the team table on TEAM_ID
The join between the player table and the team table on MANAGER_ID
The join between the player table and the team table on PLAYER_ID
Incorrect. Refer to Section 3
27. Using Oracle Proprietary join syntax, which two operators can be used in an
outer join condition using the outer join operator (+)? Mark for Review
(1) Points
AND and = (*)
OR and =
BETWEEN...AND... and IN
IN and =
Correct
28. The EMPLOYEE_ID column in the EMPLOYEES table corresponds to the EMPLOYEE_ID
column of the ORDERS table. The EMPLOYEE_ID column in the ORDERS table contains
null values for rows that you need to display.
Which type of join should you use to display the data? Mark for Review
(1) Points
Natural join
Self-join
Outer join (*)
Equijoin
Incorrect. Refer to Section 3
29. What is the minimum number of join conditions required to join 5 tables
together? Mark for Review
(1) Points
4 (*)
One more than the number of tables
Correct
30. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
Correct
31. When joining 3 tables in a SELECT statement, how many join conditions are
needed in the WHERE clause? Mark for Review
(1) Points
2 (*)
Correct
32. You have the following EMPLOYEES table:
EMPLOYEE_ID NUMBER(5) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(25)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
DEPARTMENT_ID NUMBER(5) NOT NULL FOREIGN KEY
The BONUS table includes the following columns:
BONUS_ID NUMBER(5) NOT NULL PRIMARY KEY
ANNUAL_SALARY NUMBER(10)
BONUS_PCT NUMBER(3, 2)
EMPLOYEE_ID VARCHAR2(5) NOT NULL FOREIGN KEY
You want to determine the amount of each employee's bonus, as a calculation of
salary times bonus. Which of the following queries should you issue?
Mark for Review
(1) Points
SELECT e.first_name, e.last_name, b.annual_salary * b. bonus_pct
FROM employees e, bonus b
WHERE e.employee_id = b.employee_id;
(*)
SELECT e.first_name, e.last_name, b.annual_salary, b. bonus_pct
FROM employees e, bonus b
WHERE e.employee_id = b.employee_id;
SELECT e.first_name, e.last_name, b.annual_salary, b. bonus_pct
FROM employees, bonus
WHERE e.employee_id = b.employee_id;
SELECT first_name, last_name, annual_salary * bonus_pct
FROM employees, bonus NATURAL JOIN;
Incorrect. Refer to Section 3
33. You need to create a report that lists all employees in department 10
(Sales) whose salary is not equal to $25,000 per year. Which query should you issue
to accomplish this task? Mark for Review
(1) Points
SELECT last_name, first_name, salary
FROM employees
WHERE salary > 25000 AND department_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary = 25000 AND department_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary <= 25000 AND department_id = 10;
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND department_id = 10;
(*)
Correct
34. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total
sales?
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
Correct
35. Nonequijoins are normally used with which of the following? (Choose two)
Mark for Review
(1) Points
(Choose all correct answers)
Ranges of numbers (*)
Ranges of text
Ranges of dates (*)
Ranges of rowids
Ranges of columns
Incorrect. Refer to Section 3
36. Evaluate this SELECT statement:
SELECT *
FROM employee e, employee m
WHERE e.manager_id = m.employee_id;
Which type of join is created by this SELECT statement?
Mark for Review
(1) Points
a self join (*)
a cross join
a left outer join
a full outer join
Correct
Section 4
37. Below find the structure of the CUSTOMERS and SALES_ORDER tables:
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table
PHONE VARCHAR2 (20)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order. Which
statement could you use?
Mark for Review
(1) Points
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s
ON (c.customer_id = s.customer_id);
Correct
38. Below find the structures of the PRODUCTS and VENDORS tables:
PRODUCTS
PRODUCT_ID NUMBER
PRODUCT_NAME VARCHAR2 (25)
VENDOR_ID NUMBER
CATEGORY_ID NUMBER
VENDORS
VENDOR_ID NUMBER
VENDOR_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
You want to create a query that will return an alphabetical list of products,
including the product name and associated vendor name, for all products that have a
vendor assigned. Which two queries could you use?
Mark for Review
(1) Points
(Choose all correct answers)
SELECT p.product_name, v.vendor_name
FROM products p
LEFT OUTER JOIN vendors v ON p.vendor_id = v.vendor_id
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v ON (vendor_id)
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p NATURAL JOIN vendors v
ORDER BY p.product_name;
(*)
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v USING (p.vendor_id)
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v USING (vendor_id)
ORDER BY p.product_name;
(*)
Correct
39. For which condition would you use an equijoin query with the USING keyword?
Mark for Review
(1) Points
You need to perform a join of the CUSTOMER and ORDER tables but limit the
number of columns in the join condition. (*)
The ORDER table contains a column that has a referential constraint to a column
in the PRODUCT table.
The CUSTOMER and ORDER tables have no columns with identical names.
The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The CUST_ID
column in the ORDER table contains null values that need to be displayed.
Correct
40. Which of the following statements is the simplest description of a
nonequijoin? Mark for Review
(1) Points
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
A join that joins a table to itself
Correct
41. You need to display all the rows from both the EMPLOYEES and EMPLOYEE_HIST
tables. Which type of join would you use? Mark for Review
(1) Points
A right outer join
A left outer join
A full outer join (*)
An inner join
Correct
42. Which query will retrieve all the rows in the EMPLOYEES table, even if there
is no match in the DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
NATURAL JOIN departments d;
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
Correct
43. Which type of join returns rows from one table that have NO direct match in
the other table? Mark for Review
(1) Points
Equijoin
Self join
Outer join (*)
Natural join
Correct
44. The following SQL statement will produce what output?
SELECT last_name, department_name
FROM employees
CROSS JOIN departments;
Mark for Review
(1) Points
The missing rows from the join condition.
The last_name and department name from the employees table.
A Cartesian product between the two tables. (*)
A cross referenced result omitting similar fields from the two tables.
Incorrect. Refer to Section 4
45. Which of the following conditions will cause an error on a NATURAL JOIN?
Mark for Review
(1) Points
When you attempt to write it as an equijoin.
When the NATURAL JOIN clause is based on all columns in the two tables that
have the same name.
If it selects rows from the two tables that have equal values in all matched
columns.
If the columns having the same names have different data types, then an error
is returned. (*)
Correct
46. You need to join all the rows in the EMPLOYEES table to all the rows in the
EMP_REFERENCE table. Which type of join should you create? Mark for Review
(1) Points
An equijoin
A cross join (*)
An inner join
A full outer join
Incorrect. Refer to Section 4
Section 5
47. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
The first column listed in the GROUP BY clause is the most major grouping. (*)
The last column listed in the GROUP BY clause is the most major grouping.
The GROUP BY clause can contain an aggregate function.
A GROUP BY clause cannot be used without an ORDER BY clause.
Correct
48. What will the following SQL Statement do?
SELECT job_id, COUNT(*)
FROM employees
GROUP BY job_id;
Mark for Review
(1) Points
Displays all the employees and groups them by job.
Displays each job id and the number of people assigned to that job id. (*)
Displays only the number of job_ids.
Displays all the jobs with as many people as there are jobs.
Correct
49. Evaluate this SELECT statement:
SELECT MAX(salary), department_id
FROM employees
GROUP BY department_id;
Which What values are displayed?
Mark for Review
(1) Points
The highest salary for all employees.
The highest salary in each department. (*)
The employees with the highest salaries.
The employee with the highest salary for each department.
Correct
50. If a select list contains both a column as well as a group function then
what clause is required? Mark for Review
(1) Points
HAVING clause
JOIN clause
ORDER BY clause
GROUP BY clause (*)
Correct
Test: Quiz: Case and Character Manipulation
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1
1. What does the following SQL SELECT statement return?
SELECT UPPER( SUBSTR('Database Programming', INSTR('Database Programming','P'),20))
FROM dual;
Mark for Review
(1) Points
Programming
PROGRAMMING (*)
Database
DATABASE
Correct
. Single row functions may be used in ______, _______ and _______ clauses. (Choose
two correct answers.) Mark for Review
(1) Points
(Choose all correct answers)
SELECT, FROM, ALWAYS
FROM, SELECT, ORDERS
WHERE, DECODE, ORDER BY (*)
SELECT, WHERE, ORDER BY (*)
Incorrect. Refer to Section 1
3. Which query selects the first names of the DJ On Demand clients who have a
first name beginning with "A"? Mark for Review
(1) Points
SELECT UPPER(first_name)
FROM d_clients
WHERE first_name LIKE %a%
SELECT UPPER(first_name)
FROM d_clients v
WHERE first_name LIKE '%a%'
SELECT UPPER(first_name)
FROM d_clients
WHERE first_name LIKE 'a%'
SELECT UPPER(first_name)
FROM d_clients
WHERE LOWER(first_name) LIKE 'a%'
(*)
Incorrect. Refer to Section 1
4. Which character manipulation function always returns a numerical value? Mark
for Review
(1) Points
TRIM
LPAD
LENGTH (*)
SUBSTR
Correct
5. Which query would return a user password combining the ID of an employee and
the first 4 digits of the last name? Mark for Review
(1) Points
SELECT CONCAT (employee_id, SUBSTR(last_name,4,1))
AS "User Passwords"
FROM employees
SELECT CONCAT (employee_id, INSTR(last_name,4,1))
AS "User Passwords"
FROM employees
SELECT CONCAT (employee_id, INSTR(last_name,1,4))
AS "User Passwords"
FROM employees
SELECT CONCAT (employee_id, SUBSTR(last_name,1,4))
AS "User Passwords"
FROM employees
(*)
Correct
6. Character functions accept character arguments and only return character
values. True or False? Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 1
7. Which of the following are types of SQL functions? (Choose two correct
answers.) Mark for Review
(1) Points
(Choose all correct answers)
Multi-Row Functions (*)
Column-Row Functions
Single-Row Functions (*)
Many-to-Many Functions
Correct
8. Which of the following SQL statements would correctly return a song title
identified in the database as "All These Years"? Mark for Review
(1) Points
WHERE title CONTAINS 'Years';
WHERE title LIKE LOWER('all these years');
WHERE title IN('All','These','Years');
WHERE title LIKE INITCAP('%all these years'); (*)
Correct
9. Identify the output from the following SQL statement:
SELECT RPAD('SQL',6, '*')
FROM DUAL;
Mark for Review
(1) Points
******SQL
***SQL
SQL*** (*)
SQL******
Correct
1. The answer to the following script is 456. True or False?
SELECT TRUNC(ROUND(456.98))
FROM dual
Mark for Review
(1) Points
True
False (*)
Correct
2. ROUND and TRUNC functions can be used with which of the following Datatypes?
Mark for Review
(1) Points
Dates and numbers (*)
Dates and characters
Numbers and characters
None of the above
Correct
3. Which number function may be used to determine if a value is odd or even? Mark
for Review
(1) Points
MOD (*)
TRUNC
ROUND
BINARY
Correct
4. What is the result of the following SQL Statement:
SELECT ROUND(45.923,-1)
FROM DUAL;
Mark for Review
(1) Points
46
45.9
50 (*)
None of the above
Correct
1. Which query would return a whole number if the sysdate is 26-MAY-04? Mark for
Review
(1) Points
SELECT TRUNC(MONTHS_BETWEEN(SYSDATE,'19-MAR-79') /12)
AS YEARS
FROM DUAL;
(*)
SELECT TRUNC(YEARS_BETWEEN(SYSDATE,'19-MAR-79') /12)
AS YEARS
FROM DUAL;
SELECT MONTHS_BETWEEN(SYSDATE,'19-MAR-79') /12
AS YEARS
FROM DUAL;
None of the above
Correct
2. Round and Trunc can be used on Date datatypes. True or False? Mark for Review
(1) Points
True (*)
False
Correct
3. What is the result of the following query?
SELECT ADD_MONTHS ('11-JAN-94',6)
FROM dual;
Mark for Review
(1) Points
1/17/2004
1/11/1995
7/11/1994 (*)
7/17/1994
Correct
4. What is the result of the following query?
SELECT ADD_YEARS ('11-JAN-94',6)
FROM dual;
Mark for Review
(1) Points
This in not a valid SQL statement. (*)
7/11/1995
1/11/2000
7/11/2000
Correct
5. What function would you use to return the highest date in a month? Mark for
Review
(1) Points
FINAL_DAY
END_DAY
HIGHEST_DAY
LAST_DAY (*)
Correct
6. If hire_date has a value of '03-July-03', then what is the output from this
code?
SELECT ROUND(hire_date, 'Year') FROM employees;
Mark for Review
(1) Points
01-JAN-04 (*)
01-JAN-03
01-JUL-03
01-AUG-03
Correct
1. The main reason that constraints are added to a table is: Mark for Review
(1) Points
Constraints add a level of complexity
Constraints ensure data integrity (*)
Constraints gives programmers job security
None of the Above
Correct
2. A Primary Key that is made up of more than one column is called a: Mark for
Review
(1) Points
Multiple Primary Key
Composite Primary Key (*)
Double Key
Primary Multi-Key
None of the Above
Correct
3. Foreign Key Constraints are also known as: Mark for Review
(1) Points
Parental Key Constraints
Child Key Constraints
Referential Integrity Constraints (*)
Multi-Table Constraints
Correct
4. The table that contains the Primary Key in a Foreign Key Constraint is known
as: Mark for Review
(1) Points
Child Table
Parent Table (*)
Detail Table
Mother and Father Table
Correct
5. To automatically delete rows in a child table when a parent record is deleted
use: Mark for Review
(1) Points
ON DELETE SET NULL
ON DELETE ORPHAN
ON DELETE CASCADE (*)
None of the Above
Correct
6. The number of check constraints that can be defined on a column is: Mark for
Review
(1) Points
10
5
100
There is no limit (*)
Correct
7. An example of adding a check constraint to limit the salary that an employee
can earn is: Mark for Review
(1) Points
ALTER TABLE employees ADD CONSTRAINT emp_salary_ck SALARY < 100000
ALTER TABLE employees CONSTRAINT emp_salary_ck CHECK(salary < 100000)
MODIFY TABLE employees ADD CONSTRAINT emp_salary_ck CHECK(salary < 100000
ALTER TABLE employees ADD CONSTRAINT emp_salary_ck CHECK (salary < 100000) (*)
Correct
8. If a Primary Key is made up of more than one column, one of the columns can be
null. True or False? Mark for Review
(1) Points
True
False (*)
Correct
9. The employees table contains a foreign key column department_id that references
the id column in the departments table. Which of the following constraint modifiers
will NOT allow the deletion of id values in the department table? Mark for Review
(1) Points
ON DELETE CASCADE
ON DELETE SET NULL
Neither A nor B (*)
Both A and B
Correct
10. Which of the following pieces of code will NOT successfully create a foreign
key in the CDS table that references the SONGS table Mark for Review
(1) Points
CONSTRAINT d_cd_ song_id_fk FOREIGN KEY (song_id)REFERENCES d_songs(id)
CONSTRAINT k_cd_songid_fk FOREIGN KEY (song_id)REFERENCES d_songs(id)
song_id NUMBER(5) CONSTRAINT d_cd_ song_id_fk REFERENCES d_songs(id)
None of the above (*)
Correct
11. A composite primary key may only be defined at the table level. True or False?
Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 9
1. Once constraints have been created on a table you will have to live with them
as they are unless you drop and re-create the table. True or False? Mark for
Review
(1) Points
True
False (*)
Correct
2. The command to 'switch off' a constraint is: Mark for Review
(1) Points
ALTER TABLE STOP CHECKING
ALTER TABLE STOP CONSTRAINTS
ALTER TABLE DISABLE CONSTRAINT (*)
ALTER TABLE PAUSE CONSTRAINT
Correct
3. All of a user's constraints can be viewed in the Oracle Data Dictionary view
called: Mark for Review
(1) Points
USER_TABLES
USER_CONSTRAINTS (*)
CONSTRAINTS
TABLE_CONSTRAINTS
Correct
4. You can drop a column in a table with a simple ALTER TABLE DROP COLUMN
statement, even if the column is referenced in a constraint. True or False? Mark
for Review
(1) Points
True
False (*)
Correct
5. What mechamisn does Oracle use in the background to enforce uniqueness in
Primary and Unique key constraints? Mark for Review
(1) Points
Ordered Lists
Internal Pointers
Nothing extra is created when Primary Keys and Unique Keys are created
Unique indexes are created in the background by Oracle when Primary and Unique
constraints are created or enabled (*)
Correct
1. Views contain no data of their own. True or False? Mark for Review
(1) Points
True (*)
False
Correct
2. What is one advantage of using views? Mark for Review
(1) Points
To provide data dependence
To be able to store the same data in more than one place
To provide restricted data access (*)
Correct
3. Any select statement can be stored in the database as a view. True or False
Mark for Review
(1) Points
True (*)
False
Correct
4. Given the following CREATE VIEW statement, what data will be returned?
CREATE OR REPLACE VIEW emp_dept
AS SELECT SUBSTR(e.first_name,1,1) ||' '||e.last_name emp_name,
e.salary,
e.hire_date,
d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND d.department_id >=50;
Mark for Review
(1) Points
First character from employee first_name concatenated to the last_name, the
salary, the hire_date and department_id of all employees working in department
number 50 or higher.
First character from employee first_name concatenated to the last_name, the
salary, the hire_date and department_id of all employees working in department
number 50.
First character from employee first_name concatenated to the last_name, the
salary, the hire_date and department_name of all employees working in department
number 50.
First character from employee first_name concatenated to the last_name, the
salary, the hire_date and department_name of all employees working in department
number 50 or higher. (*)
Correct
5. A view can contain group functions. True or False? Mark for Review
(1) Points
True (*)
False
Correct
6. A view can contain a select statement with a subquery. True or False? Mark for
Review
(1) Points
True (*)
False
Correct
. Which of the following DML operations is not allowed when using a Simple View
created with read only? Mark for Review
(1) Points
INSERT
UPDATE
DELETE
All of the above (*)
Correct
2. Examine the view below and choose the operation that CANNOT be performed on it.
CREATE VIEW dj_view (last_name, number_events) AS
SELECT c.last_name, COUNT(e.name)
FROM d_clients c, d_events e
WHERE c.client_number = e.client_number
GROUP BY c.last_name
Mark for Review
(1) Points
CREATE OR REPLACE dj_view (last_name, number_events) AS
SELECT c.last_name, COUNT(e.name)
FROM d_clients c, d_events e
WHERE c.client_number = e.client_number
GROUP BY c.last_name;
INSERT INTO dj_view VALUES ('Turner', 8); (*)
SELECT last_name, number_events FROM dj_view;
DROP VIEW dj_view;
Correct
3. If a database administrator wants to ensure that changes performed through a
view do not violate existing constraints, which clause should he/she include when
creating the view? Mark for Review
(1) Points
WITH READ ONLY
FORCE
WITH CONSTRAINT CHECK
WITH CHECK OPTION (*)
Incorrect. Refer to Section 10
. Given the following view what operations would be allowed on the emp_dept view:
CREATE OR REPLACE VIEW emp_dept
AS SELECT SUBSTR(e.first_name,1,1) ||' '||e.last_name emp_name,
e.salary,
e.hire_date,
d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND d.department_id >=50;
Mark for Review
(1) Points
SELECT, DELETE
SELECT, UPDATE of all columns
SELECT, UPDATE of some columns, DELETE (*)
SELECT, INSERT
Correct
5. Using the pseudocolumn ROWNUM in a view has no implications on the ability to
do DML's through the view. True or False? Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 10
6. There is only one kind view? True or False? Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 10
. A Top-N Analysis is capable of ranking a top or bottom set of results. True or
False? Mark for Review
(1) Points
True (*)
False
Correct
2. Which of these is not a valid type of View? Mark for Review
(1) Points
INLINE
ONLINE (*)
SIMPLE
COMPLEX
Correct
3. Which of these Keywords is typically used with a Top-N Analysis? Mark for
Review
(1) Points
Rowid
Rownum (*)
Sequence
Number
Incorrect. Refer to Section 10
4. Which of the following is true about ROWNUM? Mark for Review
(1) Points
It is the number assigned to each row returned from a query after they are
ordered.
It is the number assigned to each row returned from a query as they are read
from disk. (*)
It is the number of rows in a table.
None of the above
Correct
5. How do you remove a view? Mark for Review
(1) Points
DELETE VIEW view_name
REMOVE VIEW view_name
DROP VIEW view_name (*)
You cannot remove a view
Correct
6. When you drop a table referenced by a view, the view is automatically dropped
as well. True or False? Mark for Review
(1) Points
True
False (*)
Correct
7. When you drop a view, the data it contains is also deleted. True or False?
Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 10
1. When you know you are good at answering questions in interviews, there is no
need to worry about your appearance or "first impressions." True or False? Mark
for Review
(1) Points
True
False (*)
Correct
2. Which answer would be the best in response to an interviewer's question: "Do
you have any children"? Mark for Review
(1) Points
Yes, I have 5 children and I am a single parent.
I am not required to answer that question.
I know your concern about my abilities to be able to be on the job everyday,
but I assure you, I took this into account when I applied for the job. (*)
It's none of your business.
Correct
3. Since you are not planning to get a job until after completing
college/university, you don't need to learn interview skills at this point? True or
False? Mark for Review
(1) Points
True
False (*)
Correct
4. When applying for a job at a discount department store, wearing casual clothing
would demonstrate an applicant's appropriateness for a position as a check out
clerk. True or False? Mark for Review
(1) Points
True
False (*)
Correct
5. In a behavioral interview, candidates are asked about: Mark for Review
(1) Points
Accomplishments, college, etc.
Past Performance. (*)
Personality traits.
How much money they would like to earn.
Correct
6. In a traditional interview, candidates are asked about: Mark for Review
(1) Points
Accomplishments, college, etc. (*)
Job history.
Personality traits.
How much money they would like to earn.
Incorrect. Refer to Section 11
1. A sequence is a database object. True or False? Mark for Review
(1) Points
True (*)
False
Correct
2. NEXTVAL and CURRVAL are known as column aliases. True or False? Mark for
Review
(1) Points
True
False (*)
Correct
3. Which keyword is used to modify a sequence? Mark for Review
(1) Points
Change.
Update.
Alter. (*)
Create.
Correct
4. Which keyword is used to remove a sequence? Mark for Review
(1) Points
Drop. (*)
Delete.
Remove.
Revoke.
Correct
5. Which is the correct syntax for specifying a maximum value in a sequence? Mark
for Review
(1) Points
Maxval.
Max_value.
Maximumvalue.
Maxvalue. (*)
Incorrect. Refer to Section 11
6. CURRVAL is a pseudocolumn used to extract successive sequence numbers from a
specified sequence. True or False? Mark for Review
(1) Points
True
False (*)
Correct
7. CURRVAL is a pseudocolumn used to refer to a sequence number that the current
user has just generated by referencing NEXTVAL. True or False? Mark for Review
(1) Points
True (*)
False
Correct
8. When you alter a sequence, a new increased MAXVALUE can be entered without
changing the existing number order. True or False? Mark for Review
(1) Points
True (*)
False
Correct
9. A sequence is a window through which data can be queried or changed. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
10. Why do gaps in sequences occur? Mark for Review
(1) Points
A rollback is executed.
The system crashes.
The sequence is used in another table.
All of the above. (*)
Correct
11. Examine the code for creating this sequence:
CREATE SEQUENCE track_id_seq
INCREMENT BY 10
START WITH 1000 MAXVALUE 10000
What are the first three values that would be generated by the sequence?
Mark for Review
(1) Points
100010011002.
1000, 1010, 1020. (*)
1100, 1200, 1300.
0, 1, 2.
Correct
12. In order to be able to generate primary key values that are not likely to
contain gaps, which phrase should be included in the sequence creation statement?
Mark for Review
(1) Points
NOCACHE. (*)
CACHE.
MAXVALUE.
Incorrect. Refer to Section 11
1. In SQL what is a synonym? Mark for Review
(1) Points
A table with the same number of columns as another table.
A table with the same name as another view.
A different name for a table, view or other database object. (*)
A table with that must be qualified with a username.
Correct
2. You must use a synonym to access another users table. True or False? Mark for
Review
(1) Points
True
False (*)
Correct
3. Which of the following SQL statments shows a correct syntax example of creating
a synonym accessible to all users of a database? Mark for Review
(1) Points
CREATE SYNONYM emp FOR EMPLOYEES
CREATE PUBLIC SYNONYM emp FOR EMPLOYEES (*)
CREATE UNRESTRICTED SYNONYM emp FOR EMPLOYEES
CREATE SHARED SYNONYM emp FOR EMPLOYEES
Correct
4. All tables must have indexes on them otherwise they cannot be queried. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
5. What kind of INDEX is created by Oracle when you create a primary key? Mark
for Review
(1) Points
UNIQUE INDEX. (*)
NONUNIQUE INDEX.
INDEX.
Oracle cannot create indexes automatically.
Correct
6. It is possible to have an indexed column in a table where a value in the table
column does not exist in the index. True or False? Mark for Review
(1) Points
True
False (*)
Correct
7. Which of the following statements best describes indexes and their use? Mark
for Review
(1) Points
They are just random copies of data in no particular order.
They contain the column value and pointers to the data in the table, but the
data is sorted. (*)
They contain all the rows and columns from the table.
None of the above.
Correct
8. Indexes can be used to speed up queries. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 11
1. Which of the following is not a database object? Mark for Review
(1) Points
View
Subquery (*)
Table
Sequence
Correct
2. Which of these is not a System Privilege granted by the DBA? Mark for Review
(1) Points
Create Sequence
Create Index (*)
Create Procedure
Create Session
Correct
3. Which Object Privilege apart from Alter can be granted to a Sequence? Mark for
Review
(1) Points
SELECT (*)
UPDATE
INSERT
DELETE
Correct
4. A Schema is a collection of Objects such as Tables, Views and Sequences. True
or False? Mark for Review
(1) Points
True (*)
False
Correct
5. By Controlling User Access with Oracle Database Security you can give access to
specific Objects in the Database. True or False? Mark for Review
(1) Points
True (*)
False
Correct
6. The following table shows some of the output from one of the data dictionary
views. Which view is being queried?
USERNAME PRIVILEGE ADMIN_OPTION
USCA_ORACLE_SQL01_S08 CREATE VIEW NO
USCA_ORACLE_SQL01_S08 CREATE TABLE NO
USCA_ORACLE_SQL01_S08 CREATE SYNONYM NO
USCA_ORACLE_SQL01_S08 CREATE TRIGGER NO
USCA_ORACLE_SQL01_S08 CREATE SEQUENCE NO
USCA_ORACLE_SQL01_S08 CREATE DATABASE NO
Mark for Review
(1) Points
user_sys_privs (lists system privileges granted to the user) (*)
user_tab_privs_recd (lists object privileges granted to the user)
role_tab_privs (lists table privileges granted to roles)
role_sys_privs (lists system privileges granted to roles)
Correct
7. Object privileges are: Mark for Review
(1) Points
Required to gain access to the database.
Required to manipulate the content of objects in the database. (*)
Named groups of related privileges given to a user.
A collection of objects, such as tables, views, and sequences.
Correct
8. A schema is: Mark for Review
(1) Points
Required to gain access to the database.
Required to manipulate the content of objects in the database.
A named group of related privileges given to a user.
A collection of objects, such as tables, views, and sequences. (*)
Correct
9. System privileges are: Mark for Review
(1) Points
Required to gain access to the database. (*)
Required to manipulate the content of objects in the database.
Named groups of related privileges given to a user.
A collection of objects, such as tables, views, and sequences.
Correct
10. What system privilege must be held in order to login to an Oracle database?
Mark for Review
(1) Points
CREATE LOGIN
CREATE SESSION (*)
CREATE LOGON
No special privilege is needed, if your username exists in the database, you
can login.
Correct
11. Which of the following Object Privileges can be granted on an individual
column on a table? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
Update (*)
References (*)
Insert
Delete
Incorrect. Refer to Section 13
1. What Oracle feature simplifies the process of granting and revoking privileges?
Mark for Review
(1) Points
Role (*)
Object
Data dictionary
Schema
Correct
2. Scott King owns a table called employees. He issues the following statement:
GRANT select ON employees TO PUBLIC;
Allison Plumb has been granted CREATE SESSION by the DBA. She logs into the
database and issues the following statement: GRANT select ON scott_king.employees
TO jennifer_cho;
True or False: Allison's statement will fail.
Mark for Review
(1) Points
True (*)
False
Correct
3. User1 owns a table and grants select on it WITH GRANT OPTION to User2. User2
then grants select on the same table to User3. If User1 revokes select privileges
from User2, will User3 be able to access the table? Mark for Review
(1) Points
Yes
No (*)
Correct
4. Which of the following statements about granting object privileges is false?
Mark for Review
(1) Points
To grant privileges on an object, the object must be in your own schema, or you
must have been granted the object privileges WITH GRANT OPTION.
An object owner can grant any object privilege on the object to any other user
or role of the database.
The owner of an object automatically acquires all object privileges on that
object.
Object privileges can only be granted through roles. (*)
Correct
5. If you are granted privileges to your friend's object, by default you may also
grant access to this same object to other users. True or False? Mark for Review
(1) Points
True
False (*)
Correct
6. Roles are: Mark for Review
(1) Points
Required to gain access to the database.
Required to manipulate the content of objects in the database.
Named groups of related privileges given to a user or another role. (*)
A collection of objects, such as tables, views, and sequences.
Correct
7. A role can be granted to another role. True or False? Mark for Review
(1) Points
True (*)
False
Correct
8. To take away a privilege from a user you use which command? Mark for Review
(1) Points
DELETE
REMOVE
REVOKE (*)
ALTER
Correct
9. When a user is logged into one database, they are restricted to working with
objects found in that database. True or False? Mark for Review
(1) Points
True
False (*)
Correct
10. Database Links are always accessible to all users of a database? True or
False? Mark for Review
(1) Points
True
False (*)
Correct
11. Which of the following statements is true? Mark for Review
(1) Points
Database Links allow users to work on remote database objects without having to
log into the other database. (*)
Database Links are pointers to another schema in the same database.
Database Links are never used in the real world.
Database Links can be created by any user of a database. You do not need any
special privileges to create them.
Incorrect. Refer to Section 13
1. REGULAR EXPRESSIONS does exactly the same as LIKE. No more and no less? (True
or False) Mark for Review
(1) Points
True
False (*)
Correct
2. REGULAR EXPRESSIONS can be used on CHAR, CLOB and VARCHAR2 datatypes? (True or
False) Mark for Review
(1) Points
True (*)
False
Correct
3. Select the correct REGULAR EXPRESSION functions: (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
REGEXP_LIKE, REGEXP_NEAR
REGEXP_LIKE, REGEXP_REPLACE (*)
REGEXP_REPLACE, REGEXP_REFORM
REGEXP_INSTR, REGEXP_SUBSTR (*)
Correct
4. REGULAR EXPRESSIONS can be used as a part of contraint definitions? (True or
False) Mark for Review
(1) Points
True (*)
False
Correct
1. Testing is done by programmers. True or False? Mark for Review
(1) Points
True (*)
False
Correct
2. All systems needs rigorous testing before they are delivered to end users. True
or False? Mark for Review
(1) Points
True (*)
False
Correct
3. What kind of transactions should you test against your tables and views? Mark
for Review
(1) Points
INSERT, UPDATE
INSERT, UPDATE, DELETE, MERGE (*)
DELETE, UPDATE
MERGE, INSERT
Correct
4. You need not worry about Contraints on tables when testing. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
1. You need not worry about controlling your transactions. Oracle does it all for
you. True or False? Mark for Review
(1) Points
True
False (*)
Correct
1. You need not worry about controlling your transactions. Oracle does it all for
you. True or False? Mark for Review
(1) Points
True
False (*)
Correct
3. When you log out of Oracle, your data changes are automatically rolled back.
True or False? Mark for Review
(1) Points
True
False (*)
Correct
2. As soon as UserA has entered data into a table UserB has privileges to see,
UserB can see that data. True or False? Mark for Review
(1) Points
True
False (*)
Correct
4. If Oracle crashes your changes are automatically rolled back. True or False?
Mark for Review
(1) Points
True (*)
False
Correct
5. Examine the following statements:
INSERT INTO emps
SELECT * FROM employees;
-- 107 rows inserted.
SAVEPOINT Ins_Done;
DELETE employees;
-- 107 rows deleted
SAVEPOINT Del_Done;
UPDATE emps SET last_name = 'Smith';
How would you undo the last Update only?
Mark for Review
(1) Points
Rollback update;
Rollback to savepoint Del_Done; (*)
There is nothing you can do.
Commit until Del_Done;
Correct
6. Examine the following Statement:
INSERT INTO emps SELECT * FROM employees; -- 107 rows inserted.
SAVEPOINT Ins_Done;
CREATE INDEX emp_lname_idx ON employees(last_name);
UPDATE emps SET last_name = 'Smith';
What happens if you issue a Rollback statement?
Mark for Review
(1) Points
The update of last_name is undone, but the insert was committed by the CREATE
INDEX statement. (*)
Both the UPDATE and the INSERT will be rolled back.
The INSERT is undone but the UPDATE is committed
Nothing happens.
Correct
7. COMMIT saves all outstanding data changes? True or False? Mark for Review
(1) Points
True (*)
False
Correct
1. INTERVAL DAY TO SECOND stores a period of time in terms of days, hours,
minutes, and seconds. True or False? Mark for Review
(1) Points
True (*)
False
Correct
2. To store large amounts of text you should simply create a series of VARCHAR2
columns in a table. True or False? Mark for Review
(1) Points
True
False (*)
Correct
3. The BLOB datatype can hold a maximum of 128 Terabytes of data. True or False?
Mark for Review
(1) Points
True (*)
False
Correct
4. Which of the following are valid Oracle datatypes? Mark for Review
(1) Points
DATE, BLOB, LOB, VARCHAR2
DATE, TIMESTAMP WITH LOCAL TIMEZONE, BLOB (*)
TIMESTAMP, LOB, VARCHAR2, NUMBER
SYSDATE, TIMESTAMP, DATE, LOCAL TIMEZONE
Incorrect. Refer to Section 8
1. I have a table named School_Friends in my schema. You want to build a table in
your schema named School_Friends. This is ______________, because
____________________________________. Mark for Review
(1) Points
possible; my schema is separate from yours, and it is okay for us to have like-
named tables in our separate schemas. (*)
possible; our data will merge into one table, and we can more easily access our
mutual friends information.
impossible; no matter what, there can never be two tables with the same name,
even if they are in separate schemas.
impossible; School_Friends is a reserved term in SQL.
Correct
2. DCL, which is the acronym for Data Control Language, allows: Mark for Review
(1) Points
the ALTER command to be used.
a Database Administrator the ability to grant privileges to users. (*)
the TRUNCATE command to be used.
the CONTROL TRANSACTION statement can be used.
Correct
3. It is possible to create a table by using the CREATE TABLE command in
conjunction with a subquery. True or False? Mark for Review
(1) Points
True (*)
False
Correct
4. CREATE TABLE bioclass
(hire_date DATE DEFAULT SYSDATE,
first_name varchar2(15),
last_name varchar2(15));
The above CREATE TABLE statement is acceptable, and will create a Table named
bioclass that contains a hire_date, first_name and last_name column. True or False?
Mark for Review
(1) Points
True (*)
False
Correct
5. When creating a new table, which of the following naming rules apply: (Choose
three) Mark for Review
(1) Points
(Choose all correct answers)
Must begin with a letter (*)
Can have the same name as another object owned by the same user
Must contain ONLY A - Z, a - z, 0 - 9, _ (underscore), $, and # (*)
Must be an Oracle reserved word
Must be between 1 and 30 characters long (*)
Correct
6. CREATE TABLE student_table
(id NUMBER(6),
lname VARCHAR(20),
fname VARCHAR(20),
lunch_num NUMBER(4));
Which of the following statements best describes the above SQL statement:
Mark for Review
(1) Points
creates a table named student_table with four columns: lname, fname, lunch, num
creates a table named student with four columns: id, lname, fname, lunch_num
creates a table named student_table with four columns: id, lname, fname,
lunch_num (*)
creates a table named student_table with four columns: lname, fname, lunch, num
Correct
7. Given this employee table:
(employee_id NUMBER(10) NOT NULL,
first_name VARCHAR2(25) NOT NULL,
last_name VARCHAR2(30) NOT NULL,
hire_date DATE DEFAULT sysdate)
What will be the result in the hire_date column following this insert statement:
INSERT INTO employees VALUES (10, 'Natacha', 'Hansen', DEFAULT);
Mark for Review
(1) Points
Statement will fail, as you must list the columns into which you are inserting.
Statement will work and the hire_date column will have the value of the date
when the statement was run. (*)
The character string SYSDATE.
The column for hire_date will be null.
Correct
8. Examine this CREATE TABLE statement:
CREATE TABLE emp_load
(employee_number CHAR(5),
employee_dob CHAR(20),
employee_last_name CHAR(20),
employee_first_name CHAR(15),
employee_middle_name CHAR(15),
employee_hire_date DATE)
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY def_dir1
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
FIELDS (employee_number CHAR(2),
employee_dob CHAR(20),
employee_last_name CHAR(18),
employee_first_name CHAR(11),
employee_middle_name CHAR(11),
employee_hire_date CHAR(10) date_format DATE mask "mm/dd/yyyy))
LOCATION ('info.dat'));
What kind of table is created here?
Mark for Review
(1) Points
An external table with the data stored in a file outside the database. (*)
A View.
An external table with the data stored in a file inside the database.
None. This is in invalid statement.
9. Once they are created, external tables are accessed with normal SQL statements?
(True or False) Mark for Review
(1) Points
True (*)
False
Test: Quiz: Modifying a Table
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1
1. When you use ALTER TABLE to add a column, the new column: Mark for Review
(1) Points
Becomes the first column in the table
Becomes the last column in the table (*)
Can be placed by adding a GROUP BY clause
Will not be created because you cannot add a column after the table is created
Correct
2. To completely get rid of a table, its contents, its structure, AND release the
storage space the keyword is: Mark for Review
(1) Points
DROP (*)
DELETE
TRUNCATE
KILL
Incorrect. Refer to Section 8
3. Comments can be added to a table by using the COMMENT ON TABLE statement. The
comments being added are enclosed in: Mark for Review
(1) Points
Double quotes " "
Single quotes ' ' (*)
Parentheses ( )
Brackets { }
Correct
4. A column?s data type can always be changed from NUMBER to VARCHAR2 but not from
VARCHAR2 to NUMBER, provided the table is empty. True or False? Mark for Review
(1) Points
True
False (*)
Correct
5. You can use DROP COLUMN to drop all columns in a table, leaving a table
structure with no columns. True or False? Mark for Review
(1) Points
True
False (*)
Correct
6. After issuing a SET UNUSED command on a column, another column with the same
name can be added using an ALTER TABLE statement. True or False? Mark for Review
(1) Points
True (*)
False
Correct
7. When should you use the SET UNUSED command? Mark for Review
(1) Points
Never, there is no SET UNUSED command
You should use it if you think the column may be needed again later
You should use it when the system is being heavily used (*)
You should only use this command if you want the column to still be visible
when you DESCRIBE the table
Correct
8. The following code creates a table named student_table with four columns: id,
lname, fname, lunch_num
CREATE TABLE student_table
(id NUMBER(6),
lname VARCHAR(20),
fname VARCHAR(20),
lunch_num NUMBER(4));
The lunch_num column in the above table has been marked as UNUSED. Which of the
following is the best statement you can use if you wish to remove the UNUSED column
from the student_table?
Mark for Review
(1) Points
DROP column
ALTER TABLE DELETE UNUSED COLUMNS
ALTER TABLE DROP UNUSED COLUMNS (*)
ALTER TABLE DELETE ALL COLUMNS
Correct
9. You can use the ALTER TABLE statement to: Mark for Review
(1) Points
Add a new column
Modify an existing column
Drop a column
All of the above (*)
Correct
10. Which of the following will correctly change the name of the LOCATIONS table
to NEW_LOCATIONS? Mark for Review
(1) Points
ALTER TABLE LOCATIONS RENAME NEW_LOCATIONS
MODIFY TABLE LOCATIONS RENAME NEW_LOCATIONS
RENAME LOCATIONS TO NEW_LOCATIONS (*)
None of the above; you cannot rename a table, you can only CREATE, ALTER and
DROP a table.
Correct
11. The data type of a column can never be changed once it has been created. True
or False? Mark for Review
(1) Points
True
False (*)
Correct
12. ALTER TABLE table_name RENAME can be used to: Mark for Review
(1) Points
Rename a row.
Rename a column.
Rename a table. (*)
All of the above.
13. The FLASHBACK QUERY statement can restore data back to a point in time before
the last COMMIT. True or False? Mark for Review
(1) Points
True
False (*)
14. The FLASHBACK TABLE to BEFORE DROP can restore only the table structure, but
not its data back to before the table was dropped. True or False?
Mark for Review
(1) Points
True
False (*)
1. A unique key constraint can only be defined on a not null column. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
2. A table can have more than one UNIQUE key constraint. True or False? Mark for
Review
(1) Points
True (*)
False
Correct
3. A column defined as NOT NULL can have a DEFAULT value of NULL. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
4. If the employees table has a UNIQUE constraint on the DEPARTMENT_ID column, we
can only have one employee per department. True or False? Mark for Review
(1) Points
True (*)
False
Correct
5. A table must have at least one not null constraint and one unique constraint.
True or False? Mark for Review
(1) Points
True
False (*)
Correct
6. Which of the following is not a valid Oracle constraint type? Mark for Review
(1) Points
UNIQUE KEY
NOT NULL
EXTERNAL KEY (*)
PRIMARY KEY
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Test: Institute Exit Exam
Section 1
1. You issue this SQL statement:
SELECT TRUNC(751.367,-1) FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
700
750 (*)
751
751.3
Correct
2. Which three statements about functions are true? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
The SYSDATE function returns the Oracle Server date and time. (*)
The ROUND number function rounds a value to a specified decimal place or the
nearest whole number. (*)
The CONCAT function can only be used on character strings, not on numbers.
The SUBSTR character function returns a portion of a string beginning at a defined
character position to a specified length. (*)
Incorrect. Refer to Section 1
3. What will the following SQL statement display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value, size
of 15 and the column labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of the
decimal and the column labeled SALARY.
The last name and salary for all employees with the format of the salary 15
characters long, left-padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where
expected."
Correct
4. Which of the following Date Functions will add calendar months to a date? Mark
for Review
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Correct
5. Evaluate this SELECT statement: Mark for Review
Page 1 of 3
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
(1) Points
The current date plus 30 hours.
The current date plus 30 days. (*)
The current date plus 30 months.
No value is returned because the SELECT statement generates an error.
Correct
Section 2
6. Which statement about group functions is true? Mark for Review
(1) Points
NVL and NVL2, but not COALESCE, can be used with group functions to replace
null values.
NVL and COALESCE, but not NVL2, can be used with group functions to replace
null values.
NVL, NVL2, and COALESCE can be used with group functions to replace null
values. (*)
COALESCE, but not NVL and NVL2, can be used with group functions to replace
null values.
Correct
7. You have been asked to create a report that lists all customers who have placed
orders
of at least $2,500. The report's date should be displayed in the Day, Date Month,
Year
format (For example, Tuesday, 13 April, 2004 ). Which statement should you issue?
Mark for Review
(1) Points
SELECT companyname, TO_CHAR (sysdate, 'fmdd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (date, 'day, dd month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_DATE (sysdate, 'dd, dy month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
SELECT companyname, TO_CHAR (sysdate, 'fmDay, dd Month, yyyy'), total
FROM customers NATURAL JOIN orders
WHERE total >= 2500;
(*)
Correct
8. Which best describes the TO_CHAR function? Mark for Review
(1) Points
The TO_CHAR function can be used to specify meaningful column names in an
SQL statement's result set.
The TO_CHAR function can be used to remove text from column data that will be
returned by the database.
The TO_CHAR function can be used to display dates and numbers according to
formatting conventions that are supported by Oracle. (*)
The TO_CHAR function can only be used on Date columns.
Page 2 of 3
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
Correct
Section 3
9. Using Oracle Proprietary join syntax, which two operators can be used in an
outer join
condition using the outer join operator (+)?
Mark for Review
(1) Points
AND and = (*)
OR and =
BETWEEN...AND... and IN
IN and =
Correct
10. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all
possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Correct
Page 1 of 5
Page 3 of 3
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Test: Institute Exit Exam
Section 3
11. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
Correct
Section 4
12. Which of the following best describes a natural join? Mark for Review
(1) Points
A join between two tables that includes columns that share the same name,
datatypes and lengths (*)
A join that produces a Cartesian product
A join between tables where matching fields do not exist
A join that uses only one table
Correct
13. For which condition would you use an equijoin query with the USING keyword?
Mark for Review
(1) Points
You need to perform a join of the CUSTOMER and ORDER tables but limit the
number of columns in the join condition. (*)
The ORDER table contains a column that has a referential constraint to a column in
the PRODUCT table.
The CUSTOMER and ORDER tables have no columns with identical names.
The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The
CUST_ID column in the ORDER table contains null values that need to be
displayed.
Correct
14. What should be included in a SELECT statement to return NULL values from all
tables?
Mark for Review
(1) Points
Natural joins
Left outer joins
Full outer joins (*)
Page 1 of 3
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
Right outer joins
Correct
Section 5
15. Group functions can avoid computations involving duplicate values by including
which
keyword?
Mark for Review
(1) Points
NULL
DISTINCT (*)
SELECT
UNLIKE
Correct
16. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater than $50,000?
Which SELECT would you use?
Mark for Review
(1) Points
SELECT * FROM employees
WHERE salary > 50000;
SELECT * FROM employees
WHERE salary < 50000;
SELECT COUNT(*)
FROM employees
WHERE salary < 50000;
SELECT COUNT(*)
FROM employees
WHERE salary > 50000;
(*)
SELECT COUNT(*)
FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
Correct
17. Which group function would you use to display the highest salary value in the
EMPLOYEES table?
Mark for Review
(1) Points
AVG
COUNT
MAX (*)
MIN
Correct
18. Which group function would you use to display the average price of all products
in the
PRODUCTS table?
Mark for Review
(1) Points
Page 2 of 3
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
SUM
AVG (*)
COUNT
MAX
Correct
19. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
NAME VARCHAR2(30)
LOCATION_ID NUMBER
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
(Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT MIN(AVG(order_amount)) (*)
Correct
20. Which group function would you use to display the lowest value in the
SALES_AMOUNT column?
Mark for Review
(1) Points
AVG
COUNT
MAX
MIN (*)
Correct
Page 2 of 5
Page 3 of 3
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Test: Institute Exit Exam
Section 5
21. What is the best explanation as to why this SQL statement will NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
Mark for Review
(1) Points
Salaries cannot be averaged as not all the numbers will divide evenly.
You cannot use a column alias in the GROUP BY clause. (*)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Correct
Section 6
22. Examine the data in the PAYMENT table:
This statement fails when executed:
SELECT customer_id, payment_type
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
Mark for Review
(1) Points
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
Change the comparison operator to a single-row operator.
Correct
23. Which operator or keyword cannot be used with a multiple-row subquery? Mark for
Review
(1) Points
ALL
ANY
= (*)
>
Page 1 of 4
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
Incorrect. Refer to Section 6
24. Evaluate this SELECT statement that includes a subquery:
SELECT last_name, first_name
FROM customer
WHERE area_code IN
(SELECT area_code
FROM sales
WHERE salesperson_id = 20);
Which statement is true about the given subquery?
Mark for Review
(1) Points
The outer query executes before the nested subquery.
The results of the inner query are returned to the outer query. (*)
An error occurs if the either the inner or outer queries do not return a value.
Both the inner and outer queries must return a value, or an error occurs.
Correct
25. The EMPLOYEES and ORDERS tables contain these columns:
EMPLOYEES
EMPLOYEE_ID NUMBER(10) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(30)
LAST_NAME VARCHAR2(30)
ADDRESS VARCHAR2(25)
CITY VARCHAR2(20)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
ORDERS
ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY
EMPLOYEE_ID NUMBER(10) NOT NULL FOREIGN KEY
ORDER_DATE DATE
TOTAL NUMBER(10)
Which SELECT statement will return all orders generated by a sales representative
named
Franklin during the year 2001?
Mark for Review
(1) Points
SELECT order_id, total
FROM ORDERS
( SELECT employee_id FROM employees WHERE last_name = 'Franklin') WHERE
order_date BETWEEN '01-jan-01' AND '31-dec-01';
SELECT (SELECT employee_id FROM employees WHERE last_name = 'Franklin') AND
order_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
SELECT order_id, employee_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01' AND emp_id = 'Franklin';
SELECT order_id, total
FROM ORDERS
WHERE employee_id = (SELECT employee_id FROM employees WHERE last_name =
'Franklin')
AND order_date BETWEEN '01-jan-01' AND '31-dec-01';
(*)
Page 2 of 4
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
Correct
26. The PLAYERS table contains these columns:
PLAYER_ID NUMBER PK
PLAYER_NAME VARCHAR2 (30)
TEAM_ID NUMBER
HIRE_DATE DATE
SALARY NUMBER (8,2)
Which clauses represent valid uses of aggregate functions? (Choose three.)
Mark for Review
(1) Points
(Choose all correct answers)
ORDER BY AVG(salary) (*)
GROUP BY MAX(salary)
SELECT AVG(NVL(salary, 0)) (*)
HAVING MAX(salary) > 10000 (*)
WHERE hire_date > AVG(hire_date)
Correct
27. If a single-row subquery returns a null value and uses the equality comparison
operator, what
will the outer query return?
Mark for Review
(1) Points
No rows (*)
All the rows in the table
A null value
An error
Correct
Section 7
28. Assume all the column names are correct. The following SQL statement will
execute which of
the following?
INSERT INTO departments
(department_id, department_name, manager_id, location_id)
VALUES (70, 'Public Relations', 100, 1700);
Mark for Review
(1) Points
100 will be inserted into the department_id column
1700 will be inserted into the manager_id column
70 will be inserted into the department_id column (*)
'Public Relations' will be inserted into the manager_name column
Correct
29. The PLAYERS table contains these columns:
PLAYER_ID NUMBER NOT NULL
PLAYER_LNAME VARCHAR2(20) NOT NULL
PLAYER_FNAME VARCHAR2(10) NOT NULL
TEAM_ID NUMBER
SALARY NUMBER(9,2)
You need to increase the salary of each player for all players on the Tiger team by
12.5
percent. The TEAM_ID value for the Tiger team is 5960. Which statement should you
use?
Mark for Review
(1) Points
Page 3 of 4
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
UPDATE players (salary)
SET salary = salary * 1.125;
UPDATE players
SET salary = salary * .125
WHERE team_id = 5960;
UPDATE players
SET salary = salary * 1.125
WHERE team_id = 5960;
(*)
UPDATE players (salary)
VALUES(salary * 1.125)
WHERE team_id = 5960;
Correct
30. One of the sales representatives, Janet Roper, has informed you that she was
recently
married, and she has requested that you update her name in the employee database.
Her new
last name is Cooper. Janet is the only person with the last name of Roper that is
employed by
the company. The EMPLOYEES table contains these columns and all data is stored in
lowercase:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET last_name = 'cooper'
WHERE last_name = 'roper';
(*)
UPDATE employees last_name = 'cooper'
WHERE last_name = 'roper';
UPDATE employees
SET last_name = 'roper'
WHERE last_name = 'cooper';
UPDATE employees
SET cooper = 'last_name'
WHERE last_name = 'roper';
Correct
Page 3 of 5
Page 4 of 4
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Test: Institute Exit Exam
Section 8
31. 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct
32. Evaluate the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this
column's data type?
Mark for Review
(1) Points
ALTER TABLE employees
MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employees
REPLACE (employee_id VARCHAR2(9));
ALTER employees TABLE
MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is
not empty. (*)
Correct
33. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Correct
34. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
Mark for Review
Page 1 of 3
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
(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?
(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. (*)
Incorrect. Refer to Section 8
35. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a combination
of both.
All employee identification values are only 6 digits so the column should be
variable
in length.
Description values can range from 0 to 30 characters so the column should be fixed
in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct
Section 9
36. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
37. You want to disable the FOREIGN KEY constraint that is defined in the EMPLOYEES
table on the DEPARTMENT_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
Page 2 of 3
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
38. You need to add a PRIMARY KEY to the DEPARTMENTS table. Which statement
should you use?
Mark for Review
(1) Points
ALTER TABLE departments ADD PRIMARY KEY dept_id_pk (dept_id);
ALTER TABLE departments ADD CONSTRAINT dept_id_pk PK (dept_id);
ALTER TABLE departments ADD CONSTRAINT dept_id_pk PRIMARY KEY
(dept_id); (*)
ALTER TABLE departments ADD CONSTRAINT PRIMARY KEY dept_id_pk
(dept_id);
Correct
39. 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 automatically increments by a value
of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the same
datatype in another table.
Data that is entered into a primary key column is restricted to a range of numbers
that is defined by the local Oracle database.
Correct
40. 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
Page 4 of 5
Page 3 of 3
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Test: Institute Exit Exam
Section 10
41. In order to query a database using a view, which of the following statements
applies? Mark for Review
(1) Points
Use special VIEW SELECT keywords.
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
42. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Correct
43. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
JOB_ID VARCHAR(25)
MANAGER_ID NUMBER
SALARY NUMBER(9,2)
COMMISSOIN NUMBER(7,2)
HIRE_DATE DATE
Which SELECT statement could be used to display the 10 lowest paid clerks that
belong to department 70?
Mark for Review
(1) Points
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary
FROM employees
ORDER BY salary)
WHERE ROWNUM <=10 AND job_id LIKE 'CLERK' AND department_id = 70;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
Page 1 of 4
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary, job_id, dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Correct
44. 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
Section 11
45. 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.
Incorrect. Refer to Section 11
46. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DEPARTMENT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCT
table
HIRE_DATE DATE DEFAULT SYSDATE
SALARY NUMBER (8,2) NOT NULL
On which column is an index automatically created for the EMPLOYEES table?
Mark for Review
(1) Points
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct
Page 2 of 4
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
47. Sequences can be used to: (Choose three) Mark for Review
(1) Points
(Choose all correct answers)
Ensure primary key values will be unique and consecutive
Ensure primary key values will be unique even though gaps may exist (*)
Generate a range of numbers and optionally cycle through them again (*)
Set a fixed interval between successively generated numbers. (*)
Guarantee that no primary key values are unused
Correct
Section 12
48. 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
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
49. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other
object privileges on the table to other users.
Mark for Review
(1) Points
True
False (*)
Correct
Section 14
50. Examine the following statements:
UPDATE employees SET salary = 15000;
SAVEPOINT upd1_done;
UPDATE employees SET salary = 22000;
SAVEPOINT upd2_done;
DELETE FROM employees;
You want to retain all the employees with a salary of 15000; What statement would
you
execute next?
Mark for Review
(1) Points
ROLLBACK;
ROLLBACK TO SAVEPOINT upd1_done; (*)
ROLLBACK TO SAVEPOINT upd2_done;
ROLLBACK TO SAVE upd1_done;
There is nothing you can do, either all changes must be rolled back, or none of
them can be rolled back.
Page 3 of 4
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
Correct
Page 5 of 5
Page 4 of 4
http://ilearning.oracle.com/ilearn/en/assessment/jsp/test_player.jsp 9/6/2008
Test: Final Exam Semester 2 - Part I
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Part I of the Semester 2 Final Exam covers Sections 8-9 of Database Programming
with SQL.
Section 8
1. Evaluate this statement:
ALTER TABLE employees SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEES table
Incorrect. Refer to Section 8 Lesson 3
2. 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 DELETE statement
The TRUNCATE TABLE statement (*)
Correct
3. 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
4. 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
Incorrect. Refer to Section 8 Lesson 3
5. To do a logical delete of a column without the performance penalty of
rewriting all the table datablocks you can issue the following command: Mark for
Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column "columname"
Correct
6. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams
MODIFY (mgr_id VARCHAR2(15));
(*)
ALTER TABLE teams
REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE
MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Incorrect. Refer to Section 8 Lesson 3
7. Evaluate this statement:
TRUNCATE TABLE employees;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
You can produce the same results by issuing the 'DROP TABLE employee'
statement.
You can issue this statement to retain the structure of the employees table.
(*)
You can reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE employees' statement.
Correct
8. 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
9. 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct
10. Evaluate the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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 employees TABLE ALTER COLUMN (last_name VARCHAR2(35));
ALTER TABLE employees RENAME last_name VARCHAR2(35);
ALTER TABLE employees MODIFY (last_name VARCHAR2(35));
(*)
You CANNOT increase the width of the LAST_NAME column.
Correct
Section 8
11. 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. (*)
Correct
12. Which column name is valid? Mark for Review
(1) Points
1NUMBER
NUMBER
NUMBER_1$ (*)
1_NUMBER#
Incorrect. Refer to Section 8
13. 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));
CREATE TABLE travel
(destination_id number primary key, departure_date date, return_date date, emp_id
number(10) REFERENCES employees (emp_id));
(*)
Incorrect. Refer to Section 8
14. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Correct
15. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
4 (*)
Incorrect. Refer to Section 8
16. 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.
Incorrect. Refer to Section 8
17. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees;
(*)
Incorrect. Refer to Section 8
18. 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
Incorrect. Refer to Section 8
19. 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
Correct
20. 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
Correct
Section 8
21. The TIMESTAMP data type allows what? Mark for Review
(1) Points
Time to be stored as an interval of years and months.
Time to be stored as a date with fractional seconds. (*)
Time to be stored as an interval of days to hours, minutes and seconds.
None of the above.
Incorrect. Refer to Section 8
22. Which data types stores variable-length character data? Select two. Mark
for Review
(1) Points
(Choose all correct answers)
CHAR
NCHAR
CLOB (*)
VARCHAR2 (*)
Correct
23. 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
Correct
24. 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
Section 9
25. Which of the following types of constraints enforces uniqueness? Mark for
Review
(1) Points
CHECK
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct
26. 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
27. 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
28. How many PRIMARY KEY constraints can be created for each table? Mark for
Review
(1) Points
None
One and only one (*)
One or two
Unlimited
Correct
29. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Correct
30. Which statement about a non-mandatory 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. (*)
Incorrect. Refer to Section 9
31. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY,
donor_id NUMBER FOREIGN KEY donor_id_fk REFERENCES donors(donor_id),
pledge_date DATE,
amount_pledged NUMBER(7,2),
amount_paid NUMBER(7,2),
payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY,
donor_id NUMBER CONSTRAINT donor_id_fk REFERENCES donors(donor_id), pledge_date
DATE,
amount_pledged NUMBER(7,2),
amount_paid NUMBER(7,2),
payment_dt DATE);
(*)
Incorrect. Refer to Section 9
32. 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) (*)
CHECK CONSTRAINT employee_salary_min (salary > 1000)
Correct
33. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the same
datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Correct
34. You want to disable the FOREIGN KEY constraint that is defined in the
EMPLOYEES table on the DEPARTMENT_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
35. The DEPARTMENTS table contains these columns:
DEPARTMENT_ID NUMBER, Primary Key
DEPARTMENT_ABBR VARCHAR2(4)
DEPARTMENT_NAME VARCHAR2(30)
MANAGER_ID NUMBER
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)
HIRE_DATE DATE
Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT REFERENTIAL (manager_id) TO departments(manager_id);
Which statement is true?
Mark for Review
(1) Points
The ALTER TABLE statement creates a referential constraint from the EMPLOYEES
table to the DEPARTMENTS table.
The ALTER TABLE statement creates a referential constraint from the DEPARTMENTS
table to the EMPLOYEES table.
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.
Incorrect. Refer to Section 9
36. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct
37. 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
Correct
38. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
39. Which of the following would definitely cause an integrity constraint error?
Mark for Review
(1) Points
Using a subquery in an INSERT statement.
Using the MERGE statement to conditionally insert or update rows.
Using the DELETE command on a row that contains a primary key with a dependent
foreign key declared without either an ON DELETE CASCADE or ON DELETE SET NULL. (*)
Using the UPDATE command on rows based in another table.
Correct
40. 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
Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id)
REFERENCES employees (employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY
BETWEEN salary (employee_id) AND employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees (employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) = employees
(employee_id);
Incorrect. Refer to Section 9
41. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE; For which task would you issue this
statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
To drop and recreate the PRIMARY KEY constraint on the PO_NUM column
To disable the PRIMARY KEY and 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
Incorrect. Refer to Section 9
42. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Incorrect. Refer to Section 9
43. 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
Incorrect. Refer to Section 9
44. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
10
3
You can have as many NOT NULL constraints as you have columns in your table.
(*)
Correct
45. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
46. 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
47. 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
Correct
48. 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
49. 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
Incorrect. Refer to Section 9
50. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
( customer_id NUMBER, customer_name VARCHAR2(25),
address VARCHAR2(25),
city VARCHAR2(25),
region VARCHAR2(25),
postal_code VARCHAR2(11),
CONSTRAINT customer_id_un UNIQUE(customer_id),
CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Incorrect. Refer to Section 9
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Incorrect. Refer to Section 1
2. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 12.00
You query the database and return the value 79. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
(*)
Incorrect. Refer to Section 1
3. Which functions can be used to manipulate character, number, and date column
values? Mark for Review
(1) Points
CONCAT, RPAD, and TRIM (*)
UPPER, LOWER, and INITCAP
ROUND, TRUNC, and MOD
ROUND, TRUNC, and ADD_MONTHS
Correct
4. You need to display each employee's name in all uppercase letters. Which
function should you use? Mark for Review
(1) Points
CASE
UCASE
UPPER (*)
TOUPPER
Incorrect. Refer to Section 1
5. The PRICE table contains this data:
PRODUCT_ID MANUFACTURER_ID
86950 59604
You query the database and return the value 95. Which script did you use?
Mark for Review
(1) Points
SELECT SUBSTR(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
(*)
SELECT LENGTH(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
SELECT SUBSTR(product_id, -1, 3)
FROM price
WHERE manufacturer_id = 59604;
SELECT TRIM(product_id, -3, 2)
FROM price
WHERE manufacturer_id = 59604;
Correct
6. Which SQL function is used to return the position where a specific character
string begins within a larger character string? Mark for Review
(1) Points
CONCAT
INSTR (*)
LENGTH
SUBSTR
Incorrect. Refer to Section 1
7. Which SQL function can be used to remove heading or trailing characters (or
both) from a character string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
Incorrect. Refer to Section 1
Section 1 Lesson 2
(Answer all questions in this section)
8. You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
Mark for Review
(1) Points
1200
1282
1282.25
1300 (*)
Incorrect. Refer to Section 1
9. Which two functions can be used to manipulate number or date column values,
but NOT character column values? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
Incorrect. Refer to Section 1
10. You issue this SQL statement:
SELECT TRUNC(751.367,-1)
FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
700
750 (*)
751
751.3
Incorrect. Refer to Section 1
Page 1 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1 Lesson 3
(Answer all questions in this section)
11. Which function would you use to return the current database server date and
time? Mark for Review
(1) Points
DATE
SYSDATE (*)
DATETIME
CURRENTDATE
Incorrect. Refer to Section 1
12. You want to create a report that displays all orders and their amounts that
were placed during the month of January. You want the orders with the highest
amounts to appear first. Which query should you issue? Mark for Review
(1) Points
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
ORDER BY total;
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
(*)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
Incorrect. Refer to Section 1
13. Which SELECT statement will return a numeric value? Mark for Review
(1) Points
SELECT SYSDATE + 600 / 24
FROM employee;
SELECT ROUND(hire_date, DAY)
FROM employee;
SELECT (SYSDATE - hire_date) / 7
FROM employee;
(*)
SELECT SYSDATE - 7
FROM employee;
Incorrect. Refer to Section 1
14. The EMPLOYEE table contains these columns:
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
HIRE_DATE DATE
EVAL_MONTHS NUMBER(3)
Evaluate this SELECT statement:
SELECT hire_date + eval_months
FROM employee;
The values returned by this SELECT statement will be of which data type?
Mark for Review
(1) Points
DATE (*)
NUMBER
DATETIME
INTEGER
Correct
15. You need to subtract three months from the current date. Which function
should you use? Mark for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Incorrect. Refer to Section 1
Section 2 Lesson 1
(Answer all questions in this section)
16. Which two statements concerning SQL functions are true? (Choose two.) Mark
for Review
(1) Points
(Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type.
(*)
Single-row functions manipulate groups of rows to return one result per group
of rows.
Incorrect. Refer to Section 2
17. If you use the RR format when writing a query using the date 27-OCT-17 and
the year is 2001, what year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Incorrect. Refer to Section 2
18. Which SQL Statement should you use to display the prices in this format:
"$00.30"? Mark for Review
(1) Points
SELECT TO_CHAR(price, '$99,900.99') FROM product; (*)
SELECT TO_CHAR(price, "$99,900.99") FROM product;
SELECT TO_CHAR(price, '$99,990.99') FROM product;
SELECT TO_NUMBER(price, '$99,900.99') FROM product;
Correct
19. Which best describes the TO_CHAR function? Mark for Review
(1) Points
The TO_CHAR function can be used to specify meaningful column names in an SQL
statement's result set.
The TO_CHAR function can be used to remove text from column data that will be
returned by the database.
The TO_CHAR function can be used to display dates and numbers according to
formatting conventions that are supported by Oracle. (*)
The TO_CHAR function can only be used on DATE columns.
Incorrect. Refer to Section 2
20. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script
should you use to display the salaries in format: "$45,000.00"?
Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees;
(*)
Incorrect. Refer to Section 2
Page 2 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 2 Lesson 1
(Answer all questions in this section)
21. Which arithmetic operation will return a numeric value? Mark for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
SYSDATE + 30 / 24
Correct
Section 2 Lesson 2
(Answer all questions in this section)
22. You need to replace null values in the DEPT_ID column with the text "N/A".
Which functions should you use? Mark for Review
(1) Points
TO_CHAR and NVL (*)
TO_CHAR and NULL
TO_CHAR and NULLIF
TO_NUMBER and NULLIF
Correct
23. The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
SELECT NVL(10 / price, '0')
FROM PRODUCT;
What would happen if the PRICE column contains null values?
Mark for Review
(1) Points
The statement would fail because values cannot be divided by 0.
A value of 0 would be displayed. (*)
A value of 10 would be displayed.
The statement would fail because values cannot be divided by null.
Incorrect. Refer to Section 2
24. Which of the following General Functions will return the first non-null
expression in the expression list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
COALESCE (*)
Incorrect. Refer to Section 2
Section 3 Lesson 2
(Answer all questions in this section)
25. What is produced when a join condition is not specified in a multiple-table
query? Mark for Review
(1) Points
a self-join
an outer join
an equijoin
a Cartesian product (*)
Incorrect. Refer to Section 3
26. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all
possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Correct
27. You have been asked to create a report that lists all corporate customers
and all orders that they have placed. The customers should be listed alphabetically
beginning with the letter 'A', and their corresponding order totals should be
sorted from the highest amount to the lowest amount.
Which of the following statements should you issue? Mark for Review
(1) Points
SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount
FROM customers c, orders o
WHERE c.custid = o.custid
ORDER BY amount DESC, companyname;
SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount
FROM customers c, orders o
WHERE c.custid = o.custid
ORDER BY companyname, amount DESC;
(*)
SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount
FROM customers c, orders o
WHERE c.custid = o.custid
ORDER BY companyname, amount;
SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount
Q FROM customers c, orders o
WHERE c.custid = o.custid
ORDER BY companyname ASC, amount ASC;
Incorrect. Refer to Section 3
28. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total
sales?
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
Incorrect. Refer to Section 3
29. The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
Which result will this statement provide?
Mark for Review
(1) Points
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID
values (*)
A report containing each patient's id value and their doctor's id value
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
A syntax error
Correct
30. You need to provide a list of the first and last names of all employees who
work in the Sales department who earned a bonus and had sales over $50,000. The
company president would like the sales listed starting with the highest amount
first. The EMPLOYEES table and the SALES_DEPT table contain the following columns:
EMPLOYEES
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
SALES_DEPT
SALES_ID NUMBER(10) PRIMARY KEY
SALES NUMBER(20)
QUOTA NUMBER(20)
MGR VARCHAR2(30)
BONUS NUMBER(10)
EMP_ID NUMBER(10) FOREIGN KEY
Which SELECT statement will accomplish this task?
Mark for Review
(1) Points
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s.sales
FROM employees e, sales_dept s
ORDER BY sales DESC
WHERE e.emp_id = s.emp_id AND sales > 50000 AND s.bonus IS NOT NULL;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
ORDER BY sales DESC
FROM employees e, sales_dept s
WHERE e.emp_id = s.emp_id AND s.bonus IS NOT NULL AND sales > 50000;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
WHERE e.emp_id = s.emp_id
FROM employees e, sales_dept s AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
FROM employees e, sales_dept s
WHERE e.emp_id = s.emp_id AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
(*)
Incorrect. Refer to Section 3
Page 3 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 3 Lesson 4
(Answer all questions in this section)
31. Which two operators can be used in an outer join condition using the outer
join operator (+)? Mark for Review
(1) Points
AND and = (*)
OR and =
BETWEEN...AND... and IN
IN and =
Correct
32. Which operator would you use after one of the column names in the WHERE
clause when creating an outer join? Mark for Review
(1) Points
(+) (*)
Correct
33. Which statement about outer joins is true? Mark for Review
(1) Points
The tables must be aliased.
The FULL, RIGHT, or LEFT keyword must be included.
The OR operator cannot be used to link outer join conditions. (*)
Outer joins are always evaluated before other types of joins in the query.
Incorrect. Refer to Section 3
Section 4 Lesson 2
(Answer all questions in this section)
34. The following SQL statement will produce what output?
SELECT last_name, department_name
FROM employees
CROSS JOIN departments;
Mark for Review
(1) Points
The missing rows from the join condition.
The last_name and department name from the employee table.
A Cartesian product between the two tables. (*)
A cross referenced result omitting similar fields from the two tables.
Incorrect. Refer to Section 4
35. Which of the following best describes a natural join? Mark for Review
(1) Points
A join between two tables that includes columns that share the same name,
datatypes and lengths (*)
A join that produces a Cartesian product
A join between tables where matching fields do not exist
A join that uses only one table
Correct
36. You need to join two tables that have two columns with the same name and
compatible data types. Which type of join would you create to join the tables on
both of the columns? Mark for Review
(1) Points
Natural join (*)
Cross join
Outer join
Self-join
Correct
Section 4 Lesson 3
(Answer all questions in this section)
37. Evaluate this SELECT statement:
SELECT a.lname || ', ' || a.fname as "Patient", b.lname || ', ' || b.fname as
"Physician", c.admission
FROM patient a
JOIN physician b
ON (b.physician_id = c.physician_id);
JOIN admission c
ON (a.patient_id = c.patient_id);
Which clause generates an error?
Mark for Review
(1) Points
JOIN physician b
ON (b.physician_id = c.physician_id); (*)
JOIN admission c
ON (a.patient_id = c.patient_id)
Incorrect. Refer to Section 4
38. You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE
statements in sequence:
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information about
orders placed by customers who reside in Nashville . Which query should you issue
to achieve the desired results?
Mark for Review
(1) Points
SELECT custid, companyname
FROM customers
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
(*)
SELECT orderid, orderdate, total
FROM orders
WHERE city = 'Nashville';
Incorrect. Refer to Section 4
39. Below find the structures of the PRODUCTS and VENDORS tables:
PRODUCTS
PRODUCT_ID NUMBER
PRODUCT_NAME VARCHAR2 (25)
VENDOR_ID NUMBER
CATEGORY_ID NUMBER
VENDORS
VENDOR_ID NUMBER
VENDOR_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
You want to create a query that will return an alphabetical list of products,
including the product name and associated vendor name, for all products that have a
vendor assigned.
Which two queries could you use?
Mark for Review
(1) Points
(Choose all correct answers)
SELECT p.product_name, v.vendor_name
FROM products p
LEFT OUTER JOIN vendors v ON p.vendor_id = v.vendor_id
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v ON (vendor_id)
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p NATURAL JOIN vendors v
ORDER BY p.product_name;
(*)
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v USING (p.vendor_id)
ORDER BY p.product_name;
SELECT p.product_name, v.vendor_name
FROM products p
JOIN vendors v USING (vendor_id)
ORDER BY p.product_name;
(*)
Incorrect. Refer to Section 4
40. Below find the structure of the CUSTOMERS and SALES_ORDER tables:
CUSTOMERS
CUSTOMER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_NAME VARCHAR2 (30)
CONTACT_NAME VARCHAR2 (30)
CONTACT_TITLE VARCHAR2 (20)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (20)
COUNTRY_ID NUMBER Foreign key to COUNTRY_ID column of the COUNTRY table
PHONE VARCHAR2 (20)
FAX VARCHAR2 (20)
CREDIT_LIMIT NUMBER(7,2)
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order. Which
statement could you use?
Mark for Review
(1) Points
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
(*)
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id = s.customer_id(+);
SELECT c.customer_name
FROM customers c, sales_order s
WHERE c.customer_id (+) = s.customer_id;
SELECT c.customer_name
FROM customers c
RIGHT OUTER JOIN sales_order s ON (c.customer_id = s.customer_id);
Correct
Page 4 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. You need to join the EMPLOYEE_HIST and EMPLOYEE tables. The EMPLOYEE_HIST
table will be the first table in the FROM clause. All the matched and unmatched
rows in the EMPLOYEE table need to be displayed. Which type of join will you use?
Mark for Review
(1) Points
a cross join
an inner join
a left outer join
a right outer join (*)
Incorrect. Refer to Section 4
42. Which query will retrieve all the rows in the EMPLOYEES table, even if there
is no match in the DEPARTMENTS table? Mark for Review
(1) Points
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
NATURAL JOIN departments d;
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
(*)
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
JOIN departments d USING (e.department_id = d.department_id);
Incorrect. Refer to Section 4
43. Which type of join returns rows from one table that have NO direct match in
the other table? Mark for Review
(1) Points
equijoin
self join
outer join (*)
natural join
Incorrect. Refer to Section 4
Section 5 Lesson 1
(Answer all questions in this section)
44. What will the following SQL Statement do?
SELECT job_id, COUNT(*)
FROM employees
GROUP BY job_id;
Mark for Review
(1) Points
Displays all the employees and groups them by job.
Displays each job id and the number of people assigned to that job id. (*)
Displays only the number of job_ids.
Displays all the jobs with as many people as there are jobs.
Incorrect. Refer to Section 5
45. Evaluate this SELECT statement:
SELECT MAX(salary), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The highest salary for all employees.
The highest salary in each department. (*)
The employees with the highest salaries.
The employee with the highest salary for each department.
Incorrect. Refer to Section 5
46. If a select list contains both a column as well as a group function then
what clause is required? Mark for Review
(1) Points
having clause
join clause
order by clause
group by clause (*)
Incorrect. Refer to Section 5
47. Evaluate this SELECT statement:
SELECT MIN(hire_date), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEE table.
The latest hire date in the EMPLOYEE table.
The hire dates in the EMPLOYEE table that contain NULL values.
Correct
Section 5 Lesson 2
(Answer all questions in this section)
48. Which group function would you use to display the average price of all
products in the PRODUCTS table? Mark for Review
(1) Points
SUM
AVG (*)
COUNT
MAX
Incorrect. Refer to Section 5
49. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(9,2)
HIRE_DATE DATE
BONUS NUMBER(7,2)
COMM_PCT NUMBER(4,2)
Which three functions could be used with the HIRE_DATE, LAST_NAME, or SALARY
columns? (Choose three.)
Mark for Review
(1) Points
(Choose all correct answers)
MAX (*)
SUM
AVG
MIN (*)
COUNT (*)
Incorrect. Refer to Section 5
50. The TRUCKS table contains these columns:
TRUCKS
TYPE VARCHAR2(30)
YEAR DATE
MODEL VARCHAR2(20)
PRICE NUMBER(10)
Which SELECT statement will return the average price for the 4x4 model?
Mark for Review
(1) Points
SELECT AVG (price) FROM trucks WHERE model = '4x4'; (*)
SELECT AVG (price) FROM trucks WHERE model IS '4x4';
SELECT AVG(price) FROM trucks WHERE model IS 4x4;
SELECT AVG(price), model FROM trucks WHERE model IS '4x4';
Correct
Page 5 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 5 Lesson 2
(Answer all questions in this section)
51. Which group function would you use to display the highest salary value in
the EMPLOYEE table? Mark for Review
(1) Points
AVG
COUNT
MAX (*)
MIN
Incorrect. Refer to Section 5
52. Which group functions below act on character, number and date data types?
(Choose more than one answer) Mark for Review
(1) Points
(Choose all correct answers)
SUM
MAX (*)
MIN (*)
AVG
COUNT (*)
Incorrect. Refer to Section 5
53. The CUSTOMER table contains these columns:
CUSTOMER_ID NUMBER(9)
FNAME VARCHAR2(25)
LNAME VARCHAR2(30)
CREDIT_LIMIT NUMBER (7,2)
CATEGORY VARCHAR2(20)
You need to calculate the average credit limit for all the customers in each
category. The average should be calculated based on all the rows in the table
excluding any customers who have not yet been assigned a credit limit value. Which
group function should you use to calculate this value?
Mark for Review
(1) Points
AVG (*)
SUM
COUNT
STDDEV
Correct
54. Which group function would you use to display the total of all salary values
in the EMPLOYEE table? Mark for Review
(1) Points
SUM (*)
AVG
COUNT
MAX
Correct
55. Group functions return a value for ________________ and ________________
null values in their computations. Mark for Review
(1) Points
a row set, ignore (*)
each row, ignore
a row set, include
each row, include
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did
you execute?
Mark for Review
(1) Points
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_item;
Incorrect. Refer to Section 5
57. Evaluate this SELECT statement:
SELECT COUNT(*)
FROM products;
Which statement is true?
Mark for Review
(1) Points
The number of rows in the table is displayed. (*)
The number of unique PRODUCT_IDs in the table is displayed.
An error occurs due to an error in the SELECT clause.
An error occurs because no WHERE clause is included in the SELECT statement.
Correct
58. Evaluate this SELECT statement:
SELECT COUNT(*)
FROM employee
WHERE salary > 30000;
Which results will the query display?
Mark for Review
(1) Points
The number of employees that have a salary less than 30000.
The total of the SALARY column for all employees that have a salary greater
than 30000.
The number of rows in the EMPLOYEE table that have a salary greater than 30000.
(*)
The query generates an error and returns no results.
Incorrect. Refer to Section 5
59. Which SELECT statement will calculate the number of rows in the PRODUCTS
table? Mark for Review
(1) Points
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
Incorrect. Refer to Section 5
Section 6 Lesson 1
(Answer all questions in this section)
60. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you
use should a WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
Correct
Page 6 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. The MANUFACTURER table contains these columns:
MANUFACTURER_ID NUMBER
MANUFACTURER_NAME VARCHAR2(30)
TYPE VARCHAR2(25)
LOCATION_ID NUMBER
You need to display the number of unique types of manufacturers at each location.
Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY location_id;
(*)
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer;
SELECT location_id, COUNT(type)
FROM manufacturer
GROUP BY location_id;
SELECT location_id, COUNT(DISTINCT type)
FROM manufacturer
GROUP BY type;
Correct
62. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product category.
Which statement could you use to accomplish this task?
Mark for Review
(1) Points
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_price;
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_cat;
(*)
SELECT MIN (prod_price), prod_cat
FROM products
GROUP BY MIN (prod_price), prod_cat;
SELECT prod_price, MIN (prod_cat)
FROM products
GROUP BY prod_cat;
Incorrect. Refer to Section 6
63. The PLAYERS table contains these columns:
PLAYER_ID NUMBER PK
PLAYER_NAME VARCHAR2 (30)
TEAM_ID NUMBER
HIRE_DATE DATE
SALARY NUMBER (8,2)
Which two clauses represent valid uses of aggregate functions? (Choose three.)
Mark for Review
(1) Points
(Choose all correct answers)
ORDER BY AVG(salary)
GROUP BY MAX(salary) (*)
SELECT AVG(NVL(salary, 0)) (*)
HAVING MAX(salary) > 10000 (*)
WHERE hire_date > AVG(hire_date)
Incorrect. Refer to Section 6
64. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id
FROM employee
GROUP BY dept_id;
How are the results of this statement sorted?
Mark for Review
(1) Points
Ascending order by dept_id (*)
Descending order by dept_id
Ascending order by cumulative salary
Descending order by cumulative salary
Correct
65. The EMPLOYEES table contains the following columns:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
You want to create a report that includes each employee's last name, employee
identification number, date of hire and salary. The report should include only
those employees who have been with the company for more than one year and whose
salary exceeds $40,000.
Which of the following SELECT statements will accomplish this task?
Mark for Review
(1) Points
SELECT emp_id, lname, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT emp_id, lname, hire_date, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT emp_id, lname, hire_date, salary
FROM employees
WHERE salary > 40000
AND (sysdate-hire_date) / 365 > 1;
(*)
SELECT emp_id, lname, salary
FROM employees
WHERE salary > 40000
AND hire_date IN (sysdate-hire_date) / 365 > 1);
Incorrect. Refer to Section 6
66. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
Mark for Review
(1) Points
SELECT
FROM
WHERE
GROUP BY (*)
Incorrect. Refer to Section 6
67. The PAYMENT table contains these columns:
PAYMENT_ID NUMBER(9) PK
PAYMENT_DATE DATE
CUSTOMER_ID NUMBER(9)
Which SELECT statement could you use to display the number of times each customer
made a payment between January 1, 2003 and June 30, 2003 ?
Mark for Review
(1) Points
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
(*)
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT customer_id, COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003';
SELECT COUNT(payment_id)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '30-JUN-2003'
GROUP BY customer_id;
Correct
Section 6 Lesson 2
(Answer all questions in this section)
68. Which of the following is TRUE regarding the order of subquery execution?
Mark for Review
(1) Points
The outer query is executed first
The subquery executes once after the main query
The subquery executes once before the main query (*)
The result of the main query is used with the subquery
Incorrect. Refer to Section 6
69. The EMPLOYEES and ORDERS tables contain these columns:
EMPLOYEES
EMP_ID NUMBER(10) NOT NULL PRIMARY KEY
FNAME VARCHAR2(30)
LNAME VARCHAR2(30)
ADDRESS VARCHAR2(25)
CITY VARCHAR2(20)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
ORDERS
ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY
EMP_ID NUMBER(10) NOT NULL FOREIGN KEY
ORDER_DATE DATE
TOTAL NUMBER(10)
Which SELECT statement will return all orders generated by a sales representative
named Franklin during the year 2001?
Mark for Review
(1) Points
SELECT order_id, total
FROM ORDERS (SELECT emp_id FROM employees WHERE lname = 'Franklin')
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
SELECT (SELECT emp_id FROM employees WHERE lname = 'Franklin') AND order_id,
total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01';
SELECT order_id, emp_id, total
FROM ORDERS
WHERE order_date BETWEEN '01-jan-01' AND '31-dec-01' AND emp_id = 'Franklin';
SELECT order_id, total
FROM ORDERS
WHERE emp_id = (SELECT emp_id FROM employees WHERE lname = 'Franklin')
AND order_date BETWEEN '01-jan-01' AND '31-dec-01';
(*)
Incorrect. Refer to Section 6
70. You need to create a report to display the names of products with a cost
value greater than the average cost of all products. Which SELECT statement should
you use? Mark for Review
(1) Points
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost) FROM product);
(*)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
SELECT AVG(cost), product_name
FROM products
WHERE cost > AVG(cost)
GROUP by product_name;
SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
Correct
Page 7 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 2
(Answer all questions in this section)
71. If you use the equality operator (=) with a subquery, how many values can
the subquery return? Mark for Review
(1) Points
only 1 (*)
up to 2
up to 5
unlimited
Correct
72. You need to display all the players whose salaries are greater than or equal
to John Brown's salary. Which comparison operator should you use? Mark for Review
(1) Points
>
<=
>= (*)
Incorrect. Refer to Section 6
Section 6 Lesson 3
(Answer all questions in this section)
73. If a single-row subquery returns a null value and uses the equality
comparison operator, what will the outer query return? Mark for Review
(1) Points
no rows (*)
all the rows in the table
a null value
an error
Correct
74. Examine the structure of the EMPLOYEE, DEPARTMENT, and ORDERS tables.
EMPLOYEE
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
DEPARTMENT
DEPARTMENT_ID NUMBER(9)
DEPARTMENT_NAME VARCHAR2(25)
CREATION_DATE DATE
ORDERS
ORDER_ID NUMBER(9)
EMPLOYEE_ID NUMBER(9)
DATE DATE
CUSTOMER_ID NUMBER(9)
You want to display all employees who had an order after the Sales department was
established. Which of the following constructs would you use?
Mark for Review
(1) Points
a group function
a single-row subquery (*)
the HAVING clause
a MERGE statement
Incorrect. Refer to Section 6
75. You need to produce a report that contains all employee-related information
for those employees who have Brad Carter as a supervisor. However, you are not sure
which supervisor ID belongs to Brad Carter. Which query should you issue to
accomplish this task? Mark for Review
(1) Points
SELECT *
FROM employees
WHERE supervisor_id =
(SELECT supervisor_id
FROM employees
WHERE last_name = 'Carter');
SELECT *
FROM supervisors
WHERE supervisor_id =
(SELECT supervisor_id
FROM employees
WHERE last_name = 'Carter');
SELECT *
FROM supervisors
WHERE supervisor_id =
(SELECT employee_id
FROM supervisors
WHERE last_name = 'Carter');
SELECT *
FROM employees
WHERE supervisor_id =
(SELECT employee_id
FROM employees
WHERE last_name = 'Carter');
(*)
Incorrect. Refer to Section 6
Section 6 Lesson 4
(Answer all questions in this section)
76. Examine the structures of the PARTS and MANUFACTURERS tables:
PARTS:
PARTS_ID VARCHAR2(25)
PK PARTS_NAME VARCHAR2(50)
MANUFACTURERS_ID NUMBER
COST NUMBER(5,2)
PRICE NUMBER(5,2)
MANUFACTURERS:
ID NUMBER
PK NAME VARCHAR2(30)
LOCATION VARCHAR2(20)
Which SQL statement correctly uses a subquery?
Mark for Review
(1) Points
UPDATE parts SET price = price * 1.15
WHERE manufacturers_id =
(SELECT id
FROM manufacturers
WHERE UPPER(location) IN('ATLANTA ', 'BOSTON ', 'DALLAS '));
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id !=
(SELECT id
FROM manufacturers
WHERE LOWER(name) = 'cost plus');
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id IN
(SELECT id
FROM manufacturers m
JOIN part p ON (m.id = p.manufacturers_id));
(*)
SELECT parts_name
FROM
(SELECT AVG(cost)
FROM manufacturers)
WHERE cost > AVG(cost);
Incorrect. Refer to Section 6
77. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT payment_date, customer_id, payment_amount
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?
Mark for Review
(1) Points
Remove the subquery WHERE clause.
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Include the PAYMENT_ID column in the select list of the outer query.
Remove the single quotes around the date value in the inner query WHERE clause.
Incorrect. Refer to Section 6
78. Evaluate this SELECT statement:
SELECT student_id, last_name, first_name
FROM student
WHERE major_id NOT IN
(SELECT major_id
FROM majors
WHERE department_head_id = 30 AND title = 'ADJUNCT');
What would happen if the inner query returned a NULL value row?
Mark for Review
(1) Points
A syntax error would be returned.
No rows would be returned from the STUDENT table. (*)
All the rows in the STUDENT table would be displayed.
Only the rows with STUDENT_ID values equal to NULL would be displayed.
Incorrect. Refer to Section 6
79. Which statement about single-row and multiple-row subqueries is true? Mark
for Review
(1) Points
Multiple-row subqueries cannot be used with the LIKE operator. (*)
Single-row operators can be used with both single-row and multiple-row
subqueries.
Multiple-row subqueries can be used with both single-row and multiple-row
operators.
Multiple-row subqueries can only be used in SELECT statements.
Correct
80. Which operator or keyword cannot be used with a multiple-row subquery? Mark
for Review
(1) Points
ALL
ANY
= (*)
>
Incorrect. Refer to Section 6
Page 8 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. Evaluate this SELECT statement:
SELECT player_id, name
FROM players
WHERE team_id IN
(SELECT team_id
FROM teams
WHERE team_id > 300 AND salary_cap > 400000);
What would happen if the inner query returned a NULL value?
Mark for Review
(1) Points
No rows would be returned by the outer query. (*)
A syntax error in the outer query would be returned.
A syntax error in the inner query would be returned.
All the rows in the PLAYER table would be returned by the outer query.
Correct
82. Which of the following is a valid reason why the query below will not
execute successfully?
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id =
(SELECT department_id FROM employees WHERE last_name like '%u%')
Mark for Review
(1) Points
First subquery not enclosed in parenthesis
Single rather than multiple value operator used. (*)
Second subquery found on the right instead of the left side of the operator.
The greater than operator is not valid.
Incorrect. Refer to Section 6
83. You need to create a SELECT statement that contains a multiple-row subquery,
which comparison operator(s) can you use? Mark for Review
(1) Points
IN, ANY, and ALL (*)
LIKE
BETWEEN...AND...
=, <, and >
Correct
84. Which of the following best describes the meaning of the ANY operator? Mark
for Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
Equal to each value in the list
Incorrect. Refer to Section 6
85. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than
$30,000 and more than $50,000.
All employees who work in a department with employees who earn more than
$30,000, but less than $50,000. (*)
Incorrect. Refer to Section 6
86. Evaluate this SELECT statement that includes a subquery:
SELECT last_name, first_name
FROM customer
WHERE area_code IN
(SELECT area_code FROM sales WHERE salesperson_id = 20);
Which statement is true about the given subquery?
Mark for Review
(1) Points
The outer query executes before the nested subquery.
The results of the inner query are returned to the outer query. (*)
An error occurs if the either the inner or outer queries do not return a value.
Both the inner and outer queries must return a value, or an error occurs.
Incorrect. Refer to Section 6
Section 7 Lesson 1
(Answer all questions in this section)
87. Which statement about the VALUES clause of an INSERT statement is true?
Mark for Review
(1) Points
If no column list is specified, then the values must be in the order the
columns are specified in the table. (*)
The VALUES clause in an INSERT statement is optional.
Character, date, and numeric data must be enclosed within single quotes in the
VALUES clause.
To specify a null value in the VALUES clause, use an empty string (' ').
Correct
88. Assume all the column names are correct. The following SQL statement will
execute which of the following?
INSERT INTO departments (department_id, department_name, manager_id, location_id)
VALUES (70, 'Public Relations', 100, 1700);
Mark for Review
(1) Points
100 will be inserted into the department_id column
1700 will be inserted into the manager_id column
70 will be inserted into the department_id column (*)
'Public Relations' will be inserted into the manager_name column
Incorrect. Refer to Section 7
89. You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table.
What could you use in the INSERT statement to accomplish this task? Mark for
Review
(1) Points
an ON clause
a SET clause
a subquery (*)
a function
Incorrect. Refer to Section 7
90. The STUDENTS table contains these columns:
STU_ID NUMBER(9) NOT NULL
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
DOB DATE
STU_TYPE_ID VARCHAR2(1) NOT NULL
ENROLL_DATE DATE
You create another table, named FT_STUDENTS, with an identical structure.You want
to insert all full-time students, who have a STU_TYPE_ID value of "F", into the new
table. You execute this INSERT statement:
INSERT INTO ft_students
(SELECT stu_id, last_name, first_name, dob, stu_type_id, enroll_date
FROM students
WHERE UPPER(stu_type_id) = 'F');
What is the result of executing this INSERT statement?
Mark for Review
(1) Points
All full-time students are inserted into the FT_STUDENTS table. (*)
An error occurs because the FT_STUDENTS table already exists.
An error occurs because you CANNOT use a subquery in an INSERT statement.
An error occurs because the INSERT statement does NOT contain a VALUES clause.
Correct
Page 9 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 7 Lesson 2
(Answer all questions in this section)
91. You need to remove a row from the EMPLOYEE table. Which statement would you
use? Mark for Review
(1) Points
UPDATE with a WHERE clause
INSERT with a WHERE clause
DELETE with a WHERE clause (*)
MERGE with a WHERE clause
Incorrect. Refer to Section 7
92. You need to update the expiration date of products manufactured before June
30th . In which clause of the UPDATE statement will you specify this condition?
Mark for Review
(1) Points
the ON clause
the WHERE clause (*)
the SET clause
the USING clause
Incorrect. Refer to Section 7
93. What keyword in an UPDATE statement speficies the columns you want to
change? Mark for Review
(1) Points
SELECT
WHERE
SET (*)
HAVING
Incorrect. Refer to Section 7
94. You want to enter a new record into the CUSTOMERS table. Which two commands
can be used to create new rows? Mark for Review
(1) Points
INSERT, CREATE
MERGE, CREATE
INSERT, MERGE (*)
INSERT, UPDATE
Incorrect. Refer to Section 7
95. One of the sales representatives, Janet Roper, has informed you that she was
recently married, and she has requested that you update her name in the employee
database. Her new last name is Cooper. Janet is the only person with the last name
of Roper that is employed by the company. The EMPLOYEES table contains these
columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
Correct
96. Evaluate this statement: DELETE FROM customer; Which statement is true?
Mark for Review
(1) Points
The statement deletes all the rows from the CUSTOMER table. (*)
The statement deletes the CUSTOMER column.
The statement deletes the first row in the CUSTOMERS table.
The statement removes the structure of the CUSTOMER table from the database.
Correct
97. Which two commands can be used to modify existing data in a database row?
Mark for Review
(1) Points
(Choose all correct answers)
DELETE
INSERT (*)
SELECT
UPDATE (*)
Incorrect. Refer to Section 7
98. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the
EMPLOYEE table using one UPDATE statement. Which clause should you include in the
UPDATE statement to update multiple columns? Mark for Review
(1) Points
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
Incorrect. Refer to Section 7
99. You need to update the area code of employees that live in Atlanta .
Evaluate this partial UPDATE statement:
UPDATE employee
SET area_code = 770
Which of the following should you include in your UPDATE statement to achieve the
desired results?
Mark for Review
(1) Points
UPDATE city = Atlanta;
SET city = 'Atlanta';
WHERE city = 'Atlanta'; (*)
LIKE 'At%';
Incorrect. Refer to Section 7
100. When the WHERE clause is missing in a DELETE statement, what is the result?
Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Correct
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 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));
Incorrect. Refer to Section 8
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));
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct
3. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct
4. Which statement about table and column names is true? Mark for Review
(1) Points
Table and column names must begin with a letter. (*)
1. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
4 (*)
Incorrect. Refer to Section 8
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));
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Incorrect. Refer to Section 8
3. 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));
Correct
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
Correct
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.
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
Section 8 Lesson 2
(Answer all questions in this section)
6. 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 (*)
Correct
7. 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
8. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Correct
9. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
10. 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
Correct
11. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct
12. 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
Correct
Section 8 Lesson 3
(Answer all questions in this section)
13. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Correct
14. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
ALTER TABLE teams REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Incorrect. Refer to Section 8 Lesson 3
15. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
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
Incorrect. Refer to Section 8 Lesson 3
17. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct
18. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Correct
19. Examine the structure of the DONATIONS table.
DONATIONS:
PLEDGE_ID NUMBER
DONOR_ID NUMBER
PLEDGE_DT DATE
AMOUNT_PLEDGED NUMBER (7,2)
AMOUNT_PAID NUMBER (7,2)
PAYMENT_DT DATE
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
You CANNOT decrease the width of the AMOUNT_PLEDGED column.
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.
Incorrect. Refer to Section 8 Lesson 3
20. Which statement about a column is NOT true? Mark for Review
(1) Points
You can increase the width of a CHAR column.
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.
You can decrease the width of a VARCHAR2 column.
Incorrect. Refer to Section 8 Lesson 3
21. 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.
Incorrect. Refer to Section 8
22. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
23. 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. (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. 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
25. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
address VARCHAR2(25),
city VARCHAR2(25),
region VARCHAR2(25),
postal_code VARCHAR2(11),
CONSTRAINT customer_id_un UNIQUE(customer_id),
CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct
26. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
10
You can have as many NOT NULL constraints as you have columns in your table.
(*)
Correct
27. 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
28. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Correct
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE);
(*)
Correct
31. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
Correct
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
Correct
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
ON DELETE SET NULL
Incorrect. Refer to Section 9
34. How many PRIMARY KEY constraints can be created for each table? Mark for
Review
(1) Points
none
one and only one (*)
one or two
unlimited
Correct
35. 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
Correct
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. (*)
Incorrect. Refer to Section 9
37. 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.
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
39. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Correct
40. 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 (*)
ENABLE
Correct
41. 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
42. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct
43. 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;
Correct
44. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
Incorrect. Refer to Section 9
45. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Incorrect. Refer to Section 9
46. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Incorrect. Refer to Section 9
47. 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
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
WITH READ ONLY
Correct
49. 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
50. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Correct
51. 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
52. The FACULTY table contains these columns:
FACULTYID VARCHAR2(5) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(20)
LAST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
STATUS VARCHAR2(2) NOT NULL
The COURSE table contains these columns:
COURSEID VARCHAR2(5) NOT NULL PRIMARY KEY
SUBJECT VARCHAR2(5)
TERM VARCHAR2(6
FACULTYID VARCHAR2(5) NOT NULL FOREIGN KEY
You have been asked to compile a report that identifies all adjunct professors who
will be teaching classes in the upcoming term. You want to create a view that will
simplify the creation of this report. Which CREATE VIEW statements will accomplish
this task?
Mark for Review
(1) Points
CREATE VIEW
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty, course
WHERE facultyid = facultyid);
CREATE VIEW pt_view ON
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f and course c
WHERE f.facultyid = c.facultyid);
CREATE VIEW pt_view IN
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty course);
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
(*)
Incorrect. Refer to Section 10
53. 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
54. Which statement about the CREATE VIEW statement is false? Mark for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Incorrect. Refer to Section 10
55. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Incorrect. Refer to Section 10
Section 10 Lesson 2
(Answer all questions in this section)
56. 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
Correct
57. You create a view on the EMPLOYEES and DEPARTMENTS tables to display salary
information per department. What will happen if you issue the following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points
A complex view is created that returns the sum of salaries per department,
sorted by department name. (*)
A simple view is created that returns the sum of salaries per department,
sorted by department name.
A complex view is created that returns the sum of salaries per department,
sorted by department id.
Nothing, as the statement constains an error and will fail.
Correct
58. 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.
Correct
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 (*)
Correct
60. 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.
(*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in subquery
Correct
61. 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.
(*)
Incorrect. Refer to Section 10
62. 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
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 execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
64. 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
65. 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; (*)
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Correct
69. Which pseudocolumn returns the latest value supplied by a sequence? Mark
for Review
(1) Points
NEXTVAL
CURRVAL (*)
CURRENT
NEXT
Incorrect. Refer to Section 11
70. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Incorrect. Refer to Section 11
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 ; (*)
Incorrect. Refer to Section 11
72. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq CYCLE;
Which statement is true?
Mark for Review
(1) Points
The sequence cannot be used with more than one table.
The sequence preallocates values and retains them in memory.
The sequence cannot generate additional values after reaching its maximum
value.
The sequence will continue to generate values after the maximum sequence value
has been generated. (*)
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. 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
an index (*)
a FOREIGN KEY constraint
Correct
74. 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
75. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
76. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
77. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
78. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
79. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
80. Unique indexes are automatically created on columns that have which two
types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
81. 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
82. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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. (*)
Incorrect. Refer to Section 11
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
(1) Points
CREATE INDEX fl_idx ON employees(first_name || last_name);
CREATE INDEX fl_idx ON employees(first_name), employees(last_name);
CREATE INDEX fl_idx ON employees(first_name,last_name);
(*)
CREATE INDEX fl_idx ON employees(first_name);
CREATE INDEX fl_idx ON employees(last_name);
Correct
84. 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
85. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true?
Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index. (*)
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
87. 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
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
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
Incorrect. Refer to Section 12
89. 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
90. 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;
Correct
91. 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
Incorrect. Refer to Section 12
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.
GRANT SELECT ON employees_view TO public;
GRANT SELECT ON employees_view TO audrey; (*)
GRANT SELECT ON employees AND employees_view TO audrey;
Correct
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to grant privileges to a role? Mark for
Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
Correct
94. Which of the following simplifies the administration of privileges? Mark
for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
95. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other object privileges on the table to other users. True or False? Mark for
Review
(1) Points
True
False (*)
Correct
96. Which statement would you use to grant a role to users? Mark for Review
(1) Points
GRANT (*)
ALTER USER
CREATE USER
ASSIGN
Incorrect. Refer to Section 12
97. Which keyword would you use to grant an object privilege to all database
users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Correct
98. 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
Incorrect. Refer to Section 12
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
Incorrect. Refer to Section 14
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
None of the above
Correct
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
5. 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
Correct
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
INTERVAL YEAR TO MONTH
TIMESTAMP (*)
INTERVAL DAY TO SECOND
Correct
7. 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 (*)
Correct
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
Correct
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
Correct
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
column? Mark for Review
(1) Points
CHAR
DATE
NUMBER (*)
VARCHAR2
Correct
Page 1 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 2
(Answer all questions in this section)
11. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
12. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege TRUNCATE TABLE employee;
Correct
14. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
15. 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
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect. Refer to Section 8 Lesson 3
17. 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. (*)
Correct
18. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct
19. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
20. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Correct
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. 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
22. To do a logical delete of a column without the performance penalty of
rewriting all the table datablocks you can issue the following command: Mark for
Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Correct
23. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
ALTER TABLE teams REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
10
You can have as many NOT NULL constraints as you have columns in your table.
(*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. You need to add a NOT NULL constraint to the COST column in the PART table.
Which statement should you use to complete this task? Mark for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL); (*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Correct
28. A table can only have one unique key constraint defined. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
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
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct
Page 3 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 2
(Answer all questions in this section)
31. 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 (*)
Correct
32. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the same
datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Correct
33. 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
34. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Incorrect. Refer to Section 9
35. 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
36. 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) (*)
CHECK CONSTRAINT part_cost_ck (cost > 1.00)
CONSTRAINT CHECK part_cost_ck (cost > 1.00)
Correct
37. 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. (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
39. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
40. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
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. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Incorrect. Refer to Section 9
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';
ALTER TABLE employees DISABLE fk_dept_id_01;
ALTER TABLE employees DISABLE CONSTRAINT fk_dept_id_01; (*)
Correct
43. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
44. 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
Correct
45. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct
46. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct
47. 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
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. (*)
Correct
49. 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
50. 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.
Incorrect. Refer to Section 10
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. 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
52. Evaluate this view definition:
CREATE OR REPLACE VIEW part_name_v
AS SELECT DISTINCT part_name
FROM parts
WHERE cost >= 45;
Which of the following statements using the PART_NAME_V view will execute
successfully?
Mark for Review
(1) Points
SELECT *
FROM part_name_v;
(*)
UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;
DELETE FROM part_name_v
WHERE part_id = 56897;
INSERT INTO part_name_v (part_id, part_name, product_id, cost) VALUES (857986,
'cylinder', 8790, 3.45);
Correct
53. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Incorrect. Refer to Section 10
54. Which of the following keywords cannot be used when creating a view? Mark
for Review
(1) Points
HAVING
WHERE
ORDER BY (*)
They are all valid keywords when creating views.
Correct
55. Which statement about the CREATE VIEW statement is false? Mark for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Correct
Section 10 Lesson 2
(Answer all questions in this section)
56. 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
Correct
57. You cannot create a view if the view subquery contains an inline view. True
or False? Mark for Review
(1) Points
True
False (*)
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. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
60. 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
Incorrect. Refer to Section 10
Page 6 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 2
(Answer all questions in this section)
61. 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
62. 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.
(*)
Incorrect. Refer to Section 10
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;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary "Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Correct
64. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
65. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
66. The EMP_HIST_V view is no longer needed. Which statement should you use to
the remove this view? Mark for Review
(1) Points
DROP emp_hist_v;
DELETE emp_hist_v;
REMOVE emp_hist_v;
DROP VIEW emp_hist_v; (*)
Correct
67. 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
SELECT (*)
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Incorrect. Refer to Section 11
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct
Page 7 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 2
(Answer all questions in this section)
71. You need to retrieve the next available value for the SALES_IDX sequence.
Which would you include in your SQL statement? Mark for Review
(1) Points
sales_idx
sales_idx.NEXT
sales_idx.NEXTVAL (*)
sales_idx.CURRVAL
Correct
72. 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 ; (*)
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. 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 (*)
Incorrect. Refer to Section 11
74. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
75. Unique indexes are automatically created on columns that have which two
types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
76. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
77. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
78. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
79. 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
80. 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.
An index can prevent users from viewing certain data in a table.
Correct
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. You want to speed up the following query by creating an index:
SELECT * FROM employees WHERE (salary * 12) > 100000;
Which of the following will achieve this?
Mark for Review
(1) Points
Create a composite index on (salary,12).
Create a function-based index on (salary * 12). (*)
Create an index on (salary).
Create a function_based index on ((salary * 12) > 100000).
Correct
82. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
83. 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; (*)
Correct
84. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you own.
You created a public synonym on the EMPLOYEES table owned by user Sam.
You created a private synonym on the EMPLOYEES table owned by user Sam. (*)
Correct
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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
87. 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;
Correct
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
Incorrect. Refer to Section 12
89. 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
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.
A role is a name for a group of privileges. (*)
A role is an object privilege which allows a user to update a table.
Correct
Page 9 of 10
Test: 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 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;
Correct
92. 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
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
Section 12 Lesson 3
(Answer all questions in this section)
93. 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
Correct
94. Which statement would you use to remove an object privilege granted to a
user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
Correct
95. Which of the following simplifies the administration of privileges? Mark
for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
96. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other object privileges on the table to other users. True or False? Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 12
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;
Incorrect. Refer to Section 12
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.
Correct
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically rolled
back. True or False? Mark for Review
(1) Points
True (*)
False
Correct
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
Correct
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 statement about creating a table is true? Mark for Review
(1) Points
With a CREATE TABLE statement, a table will always be created in the current
user's schema.
If no schema is explicitly included in a CREATE TABLE statement, the table is
created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE statement, the CREATE
TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE statement and the schema
does not exist, it will be created.
Correct
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);
Correct
3. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Correct
4. 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));
Incorrect. Refer to Section 8
5. 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
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
Incorrect. Refer to Section 8
7. 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
8. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Incorrect. Refer to Section 8
9. 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
Incorrect. Refer to Section 8
10. 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.
(*)
Incorrect. Refer to Section 8
Page 1 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 2
(Answer all questions in this section)
11. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Incorrect. Refer to Section 8
12. 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
Section 8 Lesson 3
(Answer all questions in this section)
13. You need to change the name of the EMPLOYEE table to the EMP table. Which
statement should you use? Mark for Review
(1) Points
RENAME employee emp;
RENAME employee TO emp; (*)
ALTER TABLE employee TO emp;
ALTER TABLE employee RENAME TO emp;
Correct
14. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Incorrect. Refer to Section 8 Lesson 3
15. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect. Refer to Section 8 Lesson 3
17. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is not
empty. (*)
Incorrect. Refer to Section 8 Lesson 3
18. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Incorrect. Refer to Section 8 Lesson 3
19. 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct
20. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
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. 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. (*)
Correct
22. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
23. 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 (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. A table can only have one unique key constraint defined. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. 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 (*)
Incorrect. Refer to Section 9
28. You need to add a NOT NULL constraint to the COST column in the PART table.
Which statement should you use to complete this task? Mark for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL); (*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Incorrect. Refer to Section 9
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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.
Incorrect. Refer to Section 9
Page 3 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 2
(Answer all questions in this section)
31. 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
32. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Incorrect. Refer to Section 9
33. 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
34. How many PRIMARY KEY constraints can be created for each table? Mark for
Review
(1) Points
none
one and only one (*)
one or two
unlimited
Incorrect. Refer to Section 9
35. 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
Correct
36. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
Correct
37. 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 (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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);
Incorrect. Refer to Section 9
39. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
40. 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
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. 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);
(*)
ALTER TABLE employee
MODIFY emp_id PRIMARY KEY;
ALTER TABLE employee
MODIFY CONSTRAINT PRIMARY KEY (emp_id);
Correct
42. What actions can be performed on or with Constraints? Mark for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct
43. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
44. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Incorrect. Refer to Section 9
45. Which of the following would always cause an integrity constraint error?
Mark for Review
(1) Points
Using a subquery in an INSERT statement.
Using the MERGE statement to conditionally insert or update rows.
Using the DELETE command on a row that contains a primary key with a dependent
foreign key. (*)
Using the UPDATE command on rows based in another table.
Incorrect. Refer to Section 9
46. 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
Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES employees
(employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY BETWEEN salary (employee_id) AND
employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees (employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) = employees
(employee_id);
Incorrect. Refer to Section 9
47. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Incorrect. Refer to Section 9
Section 10 Lesson 1
(Answer all questions in this section)
48. 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
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. (*)
Correct
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.
Incorrect. Refer to Section 10
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. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Incorrect. Refer to Section 10
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 (*)
Incorrect. Refer to Section 10
53. 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
Incorrect. Refer to Section 10
54. Views must be used to select data from a table if one exist. As soon as a
view is created on a table, you can no longer select direct from the table. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
55. 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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct
Section 10 Lesson 2
(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.
(*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in subquery
Incorrect. Refer to Section 10
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.
Correct
58. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct
59. You create a view on the EMPLOYEES and DEPARTMENTS tables to display salary
information per department. What will happen if you issue the following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points
A complex view is created that returns the sum of salaries per department,
sorted by department name. (*)
A simple view is created that returns the sum of salaries per department,
sorted by department name.
A complex view is created that returns the sum of salaries per department,
sorted by department id.
Nothing, as the statement constains an error and will fail.
Incorrect. Refer to Section 10
60. 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
Page 6 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 2
(Answer all questions in this section)
61. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
62. 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
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
64. 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
SELECT (*)
Correct
65. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. A gap can occur in a sequence because a user generated a number from the
sequence and then rolled back the transaction. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 11
70. The ALTER SEQUENCE statement can be used to: Mark for Review
(1) Points
Change the START WITH value of a sequence
Change the maximum value to a lower number than was last used
Change the name of the sequence
Change how much a sequence increments by each time a number is generated (*)
Correct
Page 7 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 2
(Answer all questions in this section)
71. Sequences can be used to: (choose three) Mark for Review
(1) Points
(Choose all correct answers)
Ensure primary key values will be unique and consecutive
Ensure primary key values will be unique even though gaps may exist (*)
Generate a range of numbers and optionally cycle through them again (*)
Set a fixed interval between successively generated numbers. (*)
Guarantee that no primary key values are unused
Incorrect. Refer to Section 11
72. 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.
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of
the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Correct
74. 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.
Incorrect. Refer to Section 11
75. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
76. 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.
An index can prevent users from viewing certain data in a table.
Correct
77. 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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
78. 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
79. 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
80. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Incorrect. Refer to Section 11
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. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true?
Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index. (*)
Incorrect. Refer to Section 11
82. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
83. When creating an index on one or more columns of a table, which of the
following statements are true? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
You should create an index if the table is large and most queries are expected
to retrieve less than 2 to 4 percent of the rows. (*)
You should always create an index on tables that are frequently updated.
You should create an index if one or more columns are frequently used together
in a join condition. (*)
You should create an index if the table is very small.
Incorrect. Refer to Section 11
84. 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.
Incorrect. Refer to Section 11
85. 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
an index (*)
a FOREIGN KEY constraint
Incorrect. Refer to Section 11
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;
Incorrect. Refer to Section 12
87. Which of the following are system privileges? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE PROCEDURE (*)
INDEX
Correct
88. 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
89. You want to grant privileges to user CHAN that will allow CHAN to update the
data in the EMPLOYEE table. Which type of privileges will you grant to CHAN? Mark
for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct
90. 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;
Correct
Page 9 of 10
Test: 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 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Correct
92. 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;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
(*)
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to grant privileges to a role? Mark for
Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
Incorrect. Refer to Section 12
94. 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
Incorrect. Refer to Section 12
95. Which keyword would you use to grant an object privilege to all database
users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Incorrect. Refer to Section 12
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.
Correct
97. Which statement would you use to remove an object privilege granted to a
user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
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
Section 14 Lesson 1
(Answer all questions in this section)
99. 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
Incorrect. Refer to Section 14
100. 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;
What result will JANE see?
Mark for Review
(1) Points
22
20 (*)
JANE will receive an error message because she is not allowed to query the
table while BOB is updating it.
Incorrect. Refer to Section 14
Page 10 of 10
Skip navigation elements to page contents
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
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);
Correct Correct
2. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct Correct
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct Correct
4. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Incorrect Incorrect. Refer to Section 8
5. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
4 (*)
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 2
(Answer all questions in this section)
6. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct Correct
7. The TIMESTAMP data type allows what? Mark for Review
(1) Points
Time to be stored as an interval of years and months.
Time to be stored as a date with fractional seconds. (*)
Time to be stored as an interval of days to hours, minutes and seconds.
None of the above.
Incorrect Incorrect. Refer to Section 8
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
Correct Correct
9. 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 Correct
10. 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 Correct
Page 1 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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
12. 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
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect Incorrect. Refer to Section 8 Lesson 3
14. 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. (*)
Correct Correct
15. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct Correct
16. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct Correct
17. 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
Correct Correct
18. To do a logical delete of a column without the performance
penalty of rewriting all the table datablocks you can issue the following command:
Mark for Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Incorrect Incorrect. Refer to Section 8 Lesson 3
19. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct Correct
20. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is
not empty. (*)
Incorrect Incorrect. Refer to Section 8 Lesson 3
Previous Page 2 of 10 Next Summary
Skip navigation elements to page contents
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. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Incorrect Incorrect. Refer to Section 8 Lesson 3
22. 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 (*)
Correct 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
 address VARCHAR2(25),
 city VARCHAR2(25),
 region VARCHAR2(25),
 postal_code VARCHAR2(11),
 CONSTRAINT customer_id_un UNIQUE(customer_id),
 CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct Correct
25. 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 Correct
26. 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
Correct Correct
27. Which constraint can only be created at the column level? Mark
for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct Correct
28. A table can only have one unique key constraint defined. True or
False? Mark for Review
(1) Points
True
False (*)
Correct Correct
29. 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 Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the
same datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Incorrect Incorrect. Refer to Section 9
Previous Page 3 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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 of the following types of constraints enforces uniqueness?
Mark for Review
(1) Points
CHECK
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct Correct
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.
Incorrect Incorrect. Refer to Section 9
33. 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 Correct
34. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE);
(*)
Incorrect Incorrect. Refer to Section 9
35. 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
Correct Correct
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 (*)
Correct Correct
37. 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. (*)
Incorrect Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
Correct Correct
39. 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
Incorrect Incorrect. Refer to Section 9
40. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct Correct
Previous Page 4 of 10 Next Summary
Skip navigation elements to page contents
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. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct Correct
42. You need to display the names and definitions of constraints only
in your schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct 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. (*)
Incorrect Incorrect. Refer to Section 9
44. 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;
Correct Correct
45. 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 (*)
ENABLE
Incorrect Incorrect. Refer to Section 9
46. What actions can be performed on or with Constraints? Mark
for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct Correct
47. 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);
ALTER TABLE employee
ADD CONSTRAINT dept_id_fk FOREIGN KEY (dept_id) REFERENCES department(id);
(*)
ALTER TABLE employee
ADD FOREIGN KEY CONSTRAINT dept_id_fk ON (dept_id) REFERENCES department(id);
ALTER TABLE employee
ADD FOREIGN KEY department(id) REFERENCES (dept_id);
Correct Correct
Section 10 Lesson 1
(Answer all questions in this section)
48. 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 Correct
49. 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 Correct
50. 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. (*)
Incorrect Incorrect. Refer to Section 10
Previous Page 5 of 10 Next Summary
Skip navigation elements to page contents
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 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct Correct
54. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple (*)
inline
complex
Incorrect Incorrect. Refer to Section 10
55. Which statement about the CREATE VIEW statement is false? Mark
for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Incorrect Incorrect. Refer to Section 10
Section 10 Lesson 2
(Answer all questions in this section)
56. 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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 Correct
59. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct 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
Correct Correct
Previous Page 6 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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.
Correct Correct
62. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct Correct
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
SELECT (*)
Correct 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 Correct
65. Evaluate this SELECT statement:
SELECT ROWNUM "Rank", customer_id, new_balance
FROM
(SELECT customer_id, new_balance
FROM customer_finance
ORDER BY new_balance DESC)
WHERE ROWNUM <= 25;
Which type of query is this SELECT statement?
Mark for Review
(1) Points
A Top-n query (*)
A complex view
A simple view
A hierarchical view
Correct Correct
66. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect Incorrect. Refer to Section 10
67. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
JOB_ID NUMBER
MANAGER_ID NUMBER
SALARY NUMBER(9,2)
COMMISSOIN NUMBER(7,2)
HIRE_DATE DATE
Which SELECT statement could be used to display the 10 lowest paid clerks that
belong to department 70?
Mark for Review
(1) Points
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary
FROM employees
ORDER BY salary)
WHERE ROWNUM <=10 AND job_id LIKE 'CLERK' AND department_id = 70;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Incorrect Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. You issue this statement:
ALTER SEQUENCE po_sequence INCREMENT BY 2;
Which statement is true?
Mark for Review
(1) Points
Sequence numbers will be cached.
Future sequence numbers generated will increase by 2 each time a number is
generated. (*)
If the PO_SEQUENCE sequence does not exist, it will be created.
The statement fails if the current value of the sequence is greater than the
START WITH value.
Correct Correct
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
Correct Correct
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct Correct
Previous Page 7 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq INCREMENT BY -1;
Which statement is true?
Mark for Review
(1) Points
The statement will not execute successfully.
The sequence will generate sequential descending values. (*)
The starting value of the LINE_ITEM_ID_SEQ sequence will by -1.
The minimum value of the LINE_ITEM_ID_SEQ will be the smallest possible
integer value.
Correct Correct
72. Evaluate this statement:
CREATE SEQUENCE sales_item_id_seq
START WITH 101 MAXVALUE 9000090 CYCLE;
Which statement about this CREATE SEQUENCE statement is true?
Mark for Review
(1) Points
The sequence will reuse numbers and will start with 101. (*)
The sequence will generate decrementing sequence numbers starting at 101.
The statement fails because no INCREMENT BY value is specified.
The sequence will generate sequence numbers starting with 101, but will not
reuse numbers.
Correct Correct
Section 11 Lesson 3
(Answer all questions in this section)
73. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Incorrect Incorrect. Refer to Section 11
74. The EMPLOYEES table has an index named LN_IDX on the LAST_NAME
column. You want to change this index so that it is on the FIRST_NAME column
instead. Which SQL statement will do this? Mark for Review
(1) Points
ALTER INDEX ln_idx ON employees(first_name);
ALTER INDEX ln_idx TO employees(first_name);
ALTER INDEX ln_idx TO fn_idx ON employees(first_name);
None of the above; you cannot ALTER an index. (*)
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 (*)
Incorrect Incorrect. Refer to Section 11
76. 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; (*)
Incorrect Incorrect. Refer to Section 11
77.
As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you
own.
You created a public synonym on the EMPLOYEES table owned by user
Sam.
You created a private synonym on the EMPLOYEES table owned by
user Sam. (*)
Incorrect Incorrect. Refer to Section 11
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.
(*)
An index must be created by a database administrator when a PRIMARY KEY
constraint is created.
An index is never created for a unique constraint.
An index cannot be created before a PRIMARY KEY constraint is created.
Correct 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct Correct
80. 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.
An index can prevent users from viewing certain data in a table.
Correct Correct
Previous Page 8 of 10 Next Summary
Skip navigation elements to page contents
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. 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 Correct
82. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct Correct
83. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DEPARTMENT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCT table
HIRE_DATE DATE DEFAULT SYSDATE
SALARY NUMBER (8,2) NOT NULL
On which column is an index automatically created for the EMPLOYEES table?
Mark for Review
(1) Points
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct Correct
84. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of
the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Incorrect Incorrect. Refer to Section 11
85. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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 Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. You want to grant privileges to user CHAN that will allow CHAN to
update the data in the EMPLOYEE table. Which type of privileges will you grant to
CHAN? Mark for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct Correct
87. 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
Incorrect Incorrect. Refer to Section 12
88. 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
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.
Incorrect Incorrect. Refer to Section 12
89. 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;
Incorrect Incorrect. Refer to Section 12
90. 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 Correct
Previous Page 9 of 10 Next Summary
Skip navigation elements to page contents
Test: 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 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;
Incorrect Incorrect. Refer to Section 12
92. 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Incorrect Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. 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 Correct
94. 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;
Incorrect Incorrect. Refer to Section 12
95. To join a table in your database to a table on a second (remote)
Oracle database, you need to use: Mark for Review
(1) Points
A remote procedure call
An Oracle gateway product
An ODBC driver
A database link (*)
Correct Correct
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.
Incorrect Incorrect. Refer to Section 12
97. Which of the following simplifies the administration of
privileges? Mark for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct 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;
Incorrect Incorrect. Refer to Section 12
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically
rolled back. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect Incorrect. Refer to Section 14
100. Examine the following statements:
UPDATE employees SET salary = 15000;
SAVEPOINT upd1_done;
UPDATE employees SET salary = 22000;
SAVEPOINT upd2_done;
DELETE FROM employees;
You want to retain all the employees with a salary of 15000; What statement would
you execute next?
Mark for Review
(1) Points
ROLLBACK;
ROLLBACK TO SAVEPOINT upd1_done; (*)
ROLLBACK TO SAVEPOINT upd2_done;
ROLLBACK TO SAVE upd1_done;
There is nothing you can do, either all changes must be rolled back, or none
of them can be rolled back.
Correct Correct
Previous Page 10 of 10 Summary
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. 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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct
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 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));
Incorrect. Refer to Section 8
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));
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct
3. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct
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.
Correct
5. 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
Correct
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
INTERVAL YEAR TO MONTH
TIMESTAMP (*)
INTERVAL DAY TO SECOND
Correct
7. 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 (*)
Correct
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
Correct
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
Correct
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
column? Mark for Review
(1) Points
CHAR
DATE
NUMBER (*)
VARCHAR2
Correct
Page 1 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 2
(Answer all questions in this section)
11. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
12. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
14. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
15. 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
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect. Refer to Section 8 Lesson 3
17. 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. (*)
Correct
18. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct
19. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
20. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Correct
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. 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
22. To do a logical delete of a column without the performance penalty of
rewriting all the table datablocks you can issue the following command: Mark for
Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Correct
23. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
ALTER TABLE teams REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
10
You can have as many NOT NULL constraints as you have columns in your table.
(*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. You need to add a NOT NULL constraint to the COST column in the PART table.
Which statement should you use to complete this task? Mark for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL); (*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Correct
28. A table can only have one unique key constraint defined. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
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
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct
Page 3 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 2
(Answer all questions in this section)
31. 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 (*)
Correct
32. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the same
datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Correct
33. 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
34. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Incorrect. Refer to Section 9
35. 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
36. 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) (*)
CHECK CONSTRAINT part_cost_ck (cost > 1.00)
CONSTRAINT CHECK part_cost_ck (cost > 1.00)
Correct
37. 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. (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
39. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
40. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
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. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Incorrect. Refer to Section 9
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';
ALTER TABLE employees DISABLE fk_dept_id_01;
ALTER TABLE employees DISABLE CONSTRAINT fk_dept_id_01; (*)
Correct
43. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
44. 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
Correct
45. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct
46. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct
47. 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
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. (*)
Correct
49. 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
50. 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.
Incorrect. Refer to Section 10
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. 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
52. Evaluate this view definition:
CREATE OR REPLACE VIEW part_name_v
AS SELECT DISTINCT part_name
FROM parts
WHERE cost >= 45;
Which of the following statements using the PART_NAME_V view will execute
successfully?
Mark for Review
(1) Points
SELECT *
FROM part_name_v;
(*)
UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;
DELETE FROM part_name_v
WHERE part_id = 56897;
INSERT INTO part_name_v (part_id, part_name, product_id, cost) VALUES (857986,
'cylinder', 8790, 3.45);
Correct
53. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Incorrect. Refer to Section 10
54. Which of the following keywords cannot be used when creating a view? Mark
for Review
(1) Points
HAVING
WHERE
ORDER BY (*)
They are all valid keywords when creating views.
Correct
55. Which statement about the CREATE VIEW statement is false? Mark for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Correct
Section 10 Lesson 2
(Answer all questions in this section)
56. 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
Correct
57. You cannot create a view if the view subquery contains an inline view. True
or False? Mark for Review
(1) Points
True
False (*)
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. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
60. 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
Incorrect. Refer to Section 10
Page 6 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 2
(Answer all questions in this section)
61. 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
62. 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.
(*)
Incorrect. Refer to Section 10
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;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary "Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Correct
64. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
65. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
66. The EMP_HIST_V view is no longer needed. Which statement should you use to
the remove this view? Mark for Review
(1) Points
DROP emp_hist_v;
DELETE emp_hist_v;
REMOVE emp_hist_v;
DROP VIEW emp_hist_v; (*)
Correct
67. 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
SELECT (*)
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Incorrect. Refer to Section 11
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct
Page 7 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 2
(Answer all questions in this section)
71. You need to retrieve the next available value for the SALES_IDX sequence.
Which would you include in your SQL statement? Mark for Review
(1) Points
sales_idx
sales_idx.NEXT
sales_idx.NEXTVAL (*)
sales_idx.CURRVAL
Correct
72. 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 ; (*)
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. 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 (*)
Incorrect. Refer to Section 11
74. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
75. Unique indexes are automatically created on columns that have which two
types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
76. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
77. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
78. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
79. 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
80. 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.
An index can prevent users from viewing certain data in a table.
Correct
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. You want to speed up the following query by creating an index:
SELECT * FROM employees WHERE (salary * 12) > 100000;
Which of the following will achieve this?
Mark for Review
(1) Points
Create a composite index on (salary,12).
Create a function-based index on (salary * 12). (*)
Create an index on (salary).
Create a function_based index on ((salary * 12) > 100000).
Correct
82. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
83. 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; (*)
Correct
84. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you own.
You created a public synonym on the EMPLOYEES table owned by user Sam.
You created a private synonym on the EMPLOYEES table owned by user Sam. (*)
Correct
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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
87. 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;
Correct
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
Incorrect. Refer to Section 12
89. 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
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.
A role is a name for a group of privileges. (*)
A role is an object privilege which allows a user to update a table.
Correct
Page 9 of 10
Test: 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 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;
Correct
92. 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
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
Section 12 Lesson 3
(Answer all questions in this section)
93. 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
Correct
94. Which statement would you use to remove an object privilege granted to a
user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
Correct
95. Which of the following simplifies the administration of privileges? Mark
for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
96. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other object privileges on the table to other users. True or False? Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 12
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;
Incorrect. Refer to Section 12
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.
Correct
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically rolled
back. True or False? Mark for Review
(1) Points
True (*)
False
Correct
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
Correct
Page 10 of 10
2. 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));
Correct
3. Which statement about creating a table is true? Mark for Review
(1) Points
With a CREATE TABLE statement, a table will always be created in the current
user's schema.
If no schema is explicitly included in a CREATE TABLE statement, the table is
created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE statement, the CREATE
TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE statement and the schema
does not exist, it will be created.
Correct
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
Correct
5. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct
Section 8 Lesson 2
(Answer all questions in this section)
6. 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.
(*)
Incorrect. Refer to Section 8
7. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct
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 (*)
Correct
9. Which data types stores variable-length character data? Select two. Mark for
Review
(1) Points
(Choose all correct answers)
CHAR
NCHAR
VARCHAR (*)
VARCHAR2 (*)
Incorrect. Refer to Section 8
10. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
Page 1 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. 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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct
2. 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));
Correct
3. Which statement about creating a table is true? Mark for Review
(1) Points
With a CREATE TABLE statement, a table will always be created in the current
user's schema.
If no schema is explicitly included in a CREATE TABLE statement, the table is
created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE statement, the CREATE
TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE statement and the schema
does not exist, it will be created.
Correct
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
Correct
5. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct
Section 8 Lesson 2
(Answer all questions in this section)
6. 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.
(*)
Incorrect. Refer to Section 8
7. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct
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 (*)
Correct
9. Which data types stores variable-length character data? Select two. Mark for
Review
(1) Points
(Choose all correct answers)
CHAR
NCHAR
VARCHAR (*)
VARCHAR2 (*)
Incorrect. Refer to Section 8
10. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
Page 1 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 2
(Answer all questions in this section)
11. 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
12. 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
Correct
Section 8 Lesson 3
(Answer all questions in this section)
13. You need to change the name of the EMPLOYEE table to the EMP table. Which
statement should you use? Mark for Review
(1) Points
RENAME employee emp;
RENAME employee TO emp; (*)
ALTER TABLE employee TO emp;
ALTER TABLE employee RENAME TO emp;
Correct
14. To do a logical delete of a column without the performance penalty of
rewriting all the table datablocks you can issue the following command: Mark for
Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Correct
15. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Correct
16. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Correct
17. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
18. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct
19. 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct
20. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
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. 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.
Incorrect. Refer to Section 8
22. 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
Correct
23. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
address VARCHAR2(25),
city VARCHAR2(25),
region VARCHAR2(25),
postal_code VARCHAR2(11),
CONSTRAINT customer_id_un UNIQUE(customer_id),
CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Incorrect. Refer to Section 9
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
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. A table can only have one unique key constraint defined. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
28. 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
Incorrect. Refer to Section 9
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.
Incorrect. Refer to Section 9
Section 9 Lesson 2
(Answer all questions in this section)
30. 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
Page 3 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 2
(Answer all questions in this section)
31. 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) (*)
CHECK CONSTRAINT part_cost_ck (cost > 1.00)
CONSTRAINT CHECK part_cost_ck (cost > 1.00)
Correct
32. 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. (*)
Incorrect. Refer to Section 9
33. 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
34. 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
Correct
35. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Correct
36. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE);
(*)
Correct
37. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
Correct
Section 9 Lesson 3
(Answer all questions in this section)
38. Which of the following would always cause an integrity constraint error?
Mark for Review
(1) Points
Using a subquery in an INSERT statement.
Using the MERGE statement to conditionally insert or update rows.
Using the DELETE command on a row that contains a primary key with a dependent
foreign key. (*)
Using the UPDATE command on rows based in another table.
Correct
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 (*)
ENABLE
Correct
40. 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);
ALTER TABLE employee
ADD CONSTRAINT dept_id_fk FOREIGN KEY (dept_id) REFERENCES department(id);
(*)
ALTER TABLE employee
ADD FOREIGN KEY CONSTRAINT dept_id_fk ON (dept_id) REFERENCES department(id);
ALTER TABLE employee
ADD FOREIGN KEY department(id) REFERENCES (dept_id);
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. Examine the structures of the PRODUCT and SUPPLIER tables.
PRODUCT
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIER table
LIST_PRICE NUMBER (7,2)
COST NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
REORDER_QTY NUMBER
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;
For which task would you issue this statement?
Mark for Review
(1) Points
To remove all constraint references to SUPPLIERS table
To drop the FOREIGN KEY constraint on the PRODUCTS table
To remove all constraint references to the PRODUCTS table
To disable any dependent integrity constraints on the SUPPLIER_ID column in the
PRODUCTS table
To disable any dependent integrity constraints on the SUPPLIER_ID column in the
SUPPLIERS table (*)
Incorrect. Refer to Section 9
42. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct
43. 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
Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES employees
(employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY BETWEEN salary (employee_id) AND
employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees (employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) = employees
(employee_id);
Correct
44. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
45. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct
46. 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;
Correct
47. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Correct
Section 10 Lesson 1
(Answer all questions in this section)
48. 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
49. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Correct
50. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Correct
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. Views must be used to select data from a table if one exist. As soon as a
view is created on a table, you can no longer select direct from the table. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
52. 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
53. 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.
Incorrect. Refer to Section 10
54. Evaluate this view definition:
CREATE OR REPLACE VIEW part_name_v
AS SELECT DISTINCT part_name
FROM parts
WHERE cost >= 45;
Which of the following statements using the PART_NAME_V view will execute
successfully?
Mark for Review
(1) Points
SELECT *
FROM part_name_v;
(*)
UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;
DELETE FROM part_name_v
WHERE part_id = 56897;
INSERT INTO part_name_v (part_id, part_name, product_id, cost) VALUES (857986,
'cylinder', 8790, 3.45);
Correct
55. 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
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 (*)
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. 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
Incorrect. Refer to Section 10
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. 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.
Correct
Page 6 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 2
(Answer all questions in this section)
61. 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.
(*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in subquery
Correct
62. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
64. 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
65. 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. (*)
Incorrect. Refer to Section 10
66. 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
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this statement:
DROP SEQUENCE line_item_id_seq;
What does this statement accomplish?
Mark for Review
(1) Points
It sets the next value of the sequence to 1.
It sets the next value of the sequence to 0.
It sets the current value of the sequence to 0.
It removes the sequence from the data dictionary. (*)
Incorrect. Refer to Section 11
69. You issue this statement:
ALTER SEQUENCE po_sequence INCREMENT BY 2;
Which statement is true?
Mark for Review
(1) Points
Sequence numbers will be cached.
Future sequence numbers generated will increase by 2 each time a number is
generated. (*)
If the PO_SEQUENCE sequence does not exist, it will be created.
The statement fails if the current value of the sequence is greater than the
START WITH value.
Correct
70. Which pseudocolumn returns the latest value supplied by a sequence? Mark
for Review
(1) Points
NEXTVAL
CURRVAL (*)
CURRENT
NEXT
Incorrect. Refer to Section 11
Page 7 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 2
(Answer all questions in this section)
71. To see the most recent value that you fetched from a sequence named my_seq
you should reference: Mark for Review
(1) Points
my_seq.nextval
my_seq.(currval)
my_seq.(lastval)
my_seq.currval (*)
Incorrect. Refer to Section 11
72. 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;
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
74. 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. (*)
An index must be created by a database administrator when a PRIMARY KEY
constraint is created.
An index is never created for a unique constraint.
An index cannot be created before a PRIMARY KEY constraint is created.
Correct
75. 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);
CREATE INDEX fl_idx ON employees(first_name), employees(last_name);
CREATE INDEX fl_idx ON employees(first_name,last_name);
(*)
CREATE INDEX fl_idx ON employees(first_name);
CREATE INDEX fl_idx ON employees(last_name);
Correct
76. The EMPLOYEES table has an index named LN_IDX on the LAST_NAME column. You
want to change this index so that it is on the FIRST_NAME column instead. Which SQL
statement will do this? Mark for Review
(1) Points
ALTER INDEX ln_idx ON employees(first_name);
ALTER INDEX ln_idx TO employees(first_name);
ALTER INDEX ln_idx TO fn_idx ON employees(first_name);
None of the above; you cannot ALTER an index. (*)
Correct
77. 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
an index (*)
a FOREIGN KEY constraint
Correct
78. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DEPARTMENT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCT table
HIRE_DATE DATE DEFAULT SYSDATE
SALARY NUMBER (8,2) NOT NULL
On which column is an index automatically created for the EMPLOYEES table?
Mark for Review
(1) Points
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct
79. Unique indexes are automatically created on columns that have which two
types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
80. 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
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. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
82. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you own.
You created a public synonym on the EMPLOYEES table owned by user Sam.
You created a private synonym on the EMPLOYEES table owned by user Sam. (*)
Correct
83. 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; (*)
Correct
84. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of
the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Correct
85. 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
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
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE PROCEDURE (*)
INDEX
Correct
87. 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 (*)
Incorrect. Refer to Section 12
88. 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
89. 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
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;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
(*)
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
Correct
Page 9 of 10
Test: 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. You want to grant privileges to user CHAN that will allow CHAN to update the
data in the EMPLOYEE table. Which type of privileges will you grant to CHAN? Mark
for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct
92. 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
Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other object privileges on the table to other users. True or False? Mark for
Review
(1) Points
True
False (*)
Correct
94. 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
95. 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
96. To join a table in your database to a table on a second (remote) Oracle
database, you need to use: Mark for Review
(1) Points
A remote procedure call
An Oracle gateway product
An ODBC driver
A database link (*)
Correct
97. Which of the following simplifies the administration of privileges? Mark
for Review
(1) Points
an index
a view
a trigger
a role (*)
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;
Correct
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically rolled
back. True or False? Mark for Review
(1) Points
True (*)
False
Correct
100. 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 ;
Correct
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 statement about creating a table is true? Mark for Review
(1) Points
With a CREATE TABLE statement, a table will always be created in the current
user's schema.
If no schema is explicitly included in a CREATE TABLE statement, the table is
created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE statement, the CREATE
TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE statement and the schema
does not exist, it will be created.
Correct
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);
Correct
3. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Correct
4. 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));
Incorrect. Refer to Section 8
5. 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
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
Incorrect. Refer to Section 8
7. 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
8. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Incorrect. Refer to Section 8
9. 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
Incorrect. Refer to Section 8
10. 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.
(*)
Incorrect. Refer to Section 8
Page 1 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 2
(Answer all questions in this section)
11. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Incorrect. Refer to Section 8
12. 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
Section 8 Lesson 3
(Answer all questions in this section)
13. You need to change the name of the EMPLOYEE table to the EMP table. Which
statement should you use? Mark for Review
(1) Points
RENAME employee emp;
RENAME employee TO emp; (*)
ALTER TABLE employee TO emp;
ALTER TABLE employee RENAME TO emp;
Correct
14. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Incorrect. Refer to Section 8 Lesson 3
15. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect. Refer to Section 8 Lesson 3
17. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is not
empty. (*)
Incorrect. Refer to Section 8 Lesson 3
18. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Incorrect. Refer to Section 8 Lesson 3
19. 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct
20. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
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. 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. (*)
Correct
22. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
23. 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 (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. A table can only have one unique key constraint defined. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. 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 (*)
Incorrect. Refer to Section 9
28. You need to add a NOT NULL constraint to the COST column in the PART table.
Which statement should you use to complete this task? Mark for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL); (*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Incorrect. Refer to Section 9
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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.
Incorrect. Refer to Section 9
Page 3 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 2
(Answer all questions in this section)
31. 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
32. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Incorrect. Refer to Section 9
33. 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
34. How many PRIMARY KEY constraints can be created for each table? Mark for
Review
(1) Points
none
one and only one (*)
one or two
unlimited
Incorrect. Refer to Section 9
35. 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
Correct
36. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
Correct
37. 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 (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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);
Incorrect. Refer to Section 9
39. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
40. 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
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. 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);
(*)
ALTER TABLE employee
MODIFY emp_id PRIMARY KEY;
ALTER TABLE employee
MODIFY CONSTRAINT PRIMARY KEY (emp_id);
Correct
42. What actions can be performed on or with Constraints? Mark for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct
43. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
44. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Incorrect. Refer to Section 9
45. Which of the following would always cause an integrity constraint error?
Mark for Review
(1) Points
Using a subquery in an INSERT statement.
Using the MERGE statement to conditionally insert or update rows.
Using the DELETE command on a row that contains a primary key with a dependent
foreign key. (*)
Using the UPDATE command on rows based in another table.
Incorrect. Refer to Section 9
46. 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
Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES employees
(employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY BETWEEN salary (employee_id) AND
employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees (employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) = employees
(employee_id);
Incorrect. Refer to Section 9
47. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Incorrect. Refer to Section 9
Section 10 Lesson 1
(Answer all questions in this section)
48. 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
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. (*)
Correct
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.
Incorrect. Refer to Section 10
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. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Incorrect. Refer to Section 10
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 (*)
Incorrect. Refer to Section 10
53. 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
Incorrect. Refer to Section 10
54. Views must be used to select data from a table if one exist. As soon as a
view is created on a table, you can no longer select direct from the table. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
55. 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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct
Section 10 Lesson 2
(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.
(*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in subquery
Incorrect. Refer to Section 10
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.
Correct
58. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct
59. You create a view on the EMPLOYEES and DEPARTMENTS tables to display salary
information per department. What will happen if you issue the following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points
A complex view is created that returns the sum of salaries per department,
sorted by department name. (*)
A simple view is created that returns the sum of salaries per department,
sorted by department name.
A complex view is created that returns the sum of salaries per department,
sorted by department id.
Nothing, as the statement constains an error and will fail.
Incorrect. Refer to Section 10
60. 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
Page 6 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 2
(Answer all questions in this section)
61. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
62. 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
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
64. 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
SELECT (*)
Correct
65. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. A gap can occur in a sequence because a user generated a number from the
sequence and then rolled back the transaction. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 11
70. The ALTER SEQUENCE statement can be used to: Mark for Review
(1) Points
Change the START WITH value of a sequence
Change the maximum value to a lower number than was last used
Change the name of the sequence
Change how much a sequence increments by each time a number is generated (*)
Correct
Page 7 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 2
(Answer all questions in this section)
71. Sequences can be used to: (choose three) Mark for Review
(1) Points
(Choose all correct answers)
Ensure primary key values will be unique and consecutive
Ensure primary key values will be unique even though gaps may exist (*)
Generate a range of numbers and optionally cycle through them again (*)
Set a fixed interval between successively generated numbers. (*)
Guarantee that no primary key values are unused
Incorrect. Refer to Section 11
72. 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.
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of
the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Correct
74. 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.
Incorrect. Refer to Section 11
75. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
76. 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.
An index can prevent users from viewing certain data in a table.
Correct
77. 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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
78. 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
79. 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
80. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Incorrect. Refer to Section 11
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. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true?
Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index. (*)
Incorrect. Refer to Section 11
82. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
83. When creating an index on one or more columns of a table, which of the
following statements are true? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
You should create an index if the table is large and most queries are expected
to retrieve less than 2 to 4 percent of the rows. (*)
You should always create an index on tables that are frequently updated.
You should create an index if one or more columns are frequently used together
in a join condition. (*)
You should create an index if the table is very small.
Incorrect. Refer to Section 11
84. 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.
Incorrect. Refer to Section 11
85. 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
an index (*)
a FOREIGN KEY constraint
Incorrect. Refer to Section 11
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;
Incorrect. Refer to Section 12
87. Which of the following are system privileges? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE PROCEDURE (*)
INDEX
Correct
88. 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
89. You want to grant privileges to user CHAN that will allow CHAN to update the
data in the EMPLOYEE table. Which type of privileges will you grant to CHAN? Mark
for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct
90. 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;
Correct
Page 9 of 10
Test: 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 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Correct
92. 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;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
(*)
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to grant privileges to a role? Mark for
Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
Incorrect. Refer to Section 12
94. 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
Incorrect. Refer to Section 12
95. Which keyword would you use to grant an object privilege to all database
users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Incorrect. Refer to Section 12
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.
Correct
97. Which statement would you use to remove an object privilege granted to a
user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
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
Section 14 Lesson 1
(Answer all questions in this section)
99. 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
Incorrect. Refer to Section 14
100. 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;
What result will JANE see?
Mark for Review
(1) Points
22
20 (*)
JANE will receive an error message because she is not allowed to query the
table while BOB is updating it.
Incorrect. Refer to Section 14
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 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));
Incorrect. Refer to Section 8
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));
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct
3. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct
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.
Correct
5. 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
Correct
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
INTERVAL YEAR TO MONTH
TIMESTAMP (*)
INTERVAL DAY TO SECOND
Correct
7. 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 (*)
Correct
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
Correct
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
Correct
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
column? Mark for Review
(1) Points
CHAR
DATE
NUMBER (*)
VARCHAR2
Correct
Page 1 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 2
(Answer all questions in this section)
11. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
12. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
14. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
15. 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
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect. Refer to Section 8 Lesson 3
17. 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. (*)
Correct
18. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct
19. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
20. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Correct
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. 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
22. To do a logical delete of a column without the performance penalty of
rewriting all the table datablocks you can issue the following command: Mark for
Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Correct
23. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
ALTER TABLE teams REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
10
You can have as many NOT NULL constraints as you have columns in your table.
(*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. You need to add a NOT NULL constraint to the COST column in the PART table.
Which statement should you use to complete this task? Mark for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL); (*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Correct
28. A table can only have one unique key constraint defined. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
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
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct
Page 3 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 2
(Answer all questions in this section)
31. 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 (*)
Correct
32. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the same
datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Correct
33. 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
34. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Incorrect. Refer to Section 9
35. 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
36. 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) (*)
CHECK CONSTRAINT part_cost_ck (cost > 1.00)
CONSTRAINT CHECK part_cost_ck (cost > 1.00)
Correct
37. 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. (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
39. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
40. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
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. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Incorrect. Refer to Section 9
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';
ALTER TABLE employees DISABLE fk_dept_id_01;
ALTER TABLE employees DISABLE CONSTRAINT fk_dept_id_01; (*)
Correct
43. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
44. 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
Correct
45. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct
46. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct
47. 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
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. (*)
Correct
49. 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
50. 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.
Incorrect. Refer to Section 10
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. 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
52. Evaluate this view definition:
CREATE OR REPLACE VIEW part_name_v
AS SELECT DISTINCT part_name
FROM parts
WHERE cost >= 45;
Which of the following statements using the PART_NAME_V view will execute
successfully?
Mark for Review
(1) Points
SELECT *
FROM part_name_v;
(*)
UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;
DELETE FROM part_name_v
WHERE part_id = 56897;
INSERT INTO part_name_v (part_id, part_name, product_id, cost) VALUES (857986,
'cylinder', 8790, 3.45);
Correct
53. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Incorrect. Refer to Section 10
54. Which of the following keywords cannot be used when creating a view? Mark
for Review
(1) Points
HAVING
WHERE
ORDER BY (*)
They are all valid keywords when creating views.
Correct
55. Which statement about the CREATE VIEW statement is false? Mark for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Correct
Section 10 Lesson 2
(Answer all questions in this section)
56. 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
Correct
57. You cannot create a view if the view subquery contains an inline view. True
or False? Mark for Review
(1) Points
True
False (*)
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. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
60. 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
Incorrect. Refer to Section 10
Page 6 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 2
(Answer all questions in this section)
61. 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
62. 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.
(*)
Incorrect. Refer to Section 10
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;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary "Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Correct
64. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
65. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
66. The EMP_HIST_V view is no longer needed. Which statement should you use to
the remove this view? Mark for Review
(1) Points
DROP emp_hist_v;
DELETE emp_hist_v;
REMOVE emp_hist_v;
DROP VIEW emp_hist_v; (*)
Correct
67. 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
SELECT (*)
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Incorrect. Refer to Section 11
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct
Page 7 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 2
(Answer all questions in this section)
71. You need to retrieve the next available value for the SALES_IDX sequence.
Which would you include in your SQL statement? Mark for Review
(1) Points
sales_idx
sales_idx.NEXT
sales_idx.NEXTVAL (*)
sales_idx.CURRVAL
Correct
72. 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 ; (*)
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. 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 (*)
Incorrect. Refer to Section 11
74. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
75. Unique indexes are automatically created on columns that have which two
types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
76. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
77. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
78. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
79. 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
80. 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.
An index can prevent users from viewing certain data in a table.
Correct
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. You want to speed up the following query by creating an index:
SELECT * FROM employees WHERE (salary * 12) > 100000;
Which of the following will achieve this?
Mark for Review
(1) Points
Create a composite index on (salary,12).
Create a function-based index on (salary * 12). (*)
Create an index on (salary).
Create a function_based index on ((salary * 12) > 100000).
Correct
82. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
83. 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; (*)
Correct
84. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you own.
You created a public synonym on the EMPLOYEES table owned by user Sam.
You created a private synonym on the EMPLOYEES table owned by user Sam. (*)
Correct
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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
87. 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;
Correct
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
Incorrect. Refer to Section 12
89. 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
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.
A role is a name for a group of privileges. (*)
A role is an object privilege which allows a user to update a table.
Correct
Page 9 of 10
Test: 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 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;
Correct
92. 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
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
Section 12 Lesson 3
(Answer all questions in this section)
93. 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
Correct
94. Which statement would you use to remove an object privilege granted to a
user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
Correct
95. Which of the following simplifies the administration of privileges? Mark
for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
96. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other object privileges on the table to other users. True or False? Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 12
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;
Incorrect. Refer to Section 12
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.
Correct
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically rolled
back. True or False? Mark for Review
(1) Points
True (*)
False
Correct
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
Correct
Page 10 of 10
Skip navigation elements to page contents
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
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);
Correct Correct
2. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct Correct
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct Correct
4. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Incorrect Incorrect. Refer to Section 8
5. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
1
2
4 (*)
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 2
(Answer all questions in this section)
6. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct Correct
7. The TIMESTAMP data type allows what? Mark for Review
(1) Points
Time to be stored as an interval of years and months.
Time to be stored as a date with fractional seconds. (*)
Time to be stored as an interval of days to hours, minutes and seconds.
None of the above.
Incorrect Incorrect. Refer to Section 8
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
Correct Correct
9. 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 Correct
10. 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 Correct
Page 1 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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
12. 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
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect Incorrect. Refer to Section 8 Lesson 3
14. 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. (*)
Correct Correct
15. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct Correct
16. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct Correct
17. 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
Correct Correct
18. To do a logical delete of a column without the performance
penalty of rewriting all the table datablocks you can issue the following command:
Mark for Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Incorrect Incorrect. Refer to Section 8 Lesson 3
19. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct Correct
20. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is
not empty. (*)
Incorrect Incorrect. Refer to Section 8 Lesson 3
Previous Page 2 of 10 Next Summary
Skip navigation elements to page contents
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. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Incorrect Incorrect. Refer to Section 8 Lesson 3
22. 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 (*)
Correct 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
 address VARCHAR2(25),
 city VARCHAR2(25),
 region VARCHAR2(25),
 postal_code VARCHAR2(11),
 CONSTRAINT customer_id_un UNIQUE(customer_id),
 CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct Correct
25. 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 Correct
26. 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
Correct Correct
27. Which constraint can only be created at the column level? Mark
for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct Correct
28. A table can only have one unique key constraint defined. True or
False? Mark for Review
(1) Points
True
False (*)
Correct Correct
29. 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 Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the
same datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Incorrect Incorrect. Refer to Section 9
Previous Page 3 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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 of the following types of constraints enforces uniqueness?
Mark for Review
(1) Points
CHECK
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct Correct
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.
Incorrect Incorrect. Refer to Section 9
33. 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 Correct
34. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE);
(*)
Incorrect Incorrect. Refer to Section 9
35. 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
Correct Correct
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 (*)
Correct Correct
37. 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. (*)
Incorrect Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
Correct Correct
39. 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
Incorrect Incorrect. Refer to Section 9
40. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct Correct
Previous Page 4 of 10 Next Summary
Skip navigation elements to page contents
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. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct Correct
42. You need to display the names and definitions of constraints only
in your schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct 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. (*)
Incorrect Incorrect. Refer to Section 9
44. 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;
Correct Correct
45. 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 (*)
ENABLE
Incorrect Incorrect. Refer to Section 9
46. What actions can be performed on or with Constraints? Mark
for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct Correct
47. 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);
ALTER TABLE employee
ADD CONSTRAINT dept_id_fk FOREIGN KEY (dept_id) REFERENCES department(id);
(*)
ALTER TABLE employee
ADD FOREIGN KEY CONSTRAINT dept_id_fk ON (dept_id) REFERENCES department(id);
ALTER TABLE employee
ADD FOREIGN KEY department(id) REFERENCES (dept_id);
Correct Correct
Section 10 Lesson 1
(Answer all questions in this section)
48. 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 Correct
49. 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 Correct
50. 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. (*)
Incorrect Incorrect. Refer to Section 10
Previous Page 5 of 10 Next Summary
Skip navigation elements to page contents
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 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct Correct
54. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple (*)
inline
complex
Incorrect Incorrect. Refer to Section 10
55. Which statement about the CREATE VIEW statement is false? Mark
for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Incorrect Incorrect. Refer to Section 10
Section 10 Lesson 2
(Answer all questions in this section)
56. 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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 Correct
59. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct 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
Correct Correct
Previous Page 6 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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.
Correct Correct
62. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct Correct
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
SELECT (*)
Correct 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 Correct
65. Evaluate this SELECT statement:
SELECT ROWNUM "Rank", customer_id, new_balance
FROM
(SELECT customer_id, new_balance
FROM customer_finance
ORDER BY new_balance DESC)
WHERE ROWNUM <= 25;
Which type of query is this SELECT statement?
Mark for Review
(1) Points
A Top-n query (*)
A complex view
A simple view
A hierarchical view
Correct Correct
66. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect Incorrect. Refer to Section 10
67. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
JOB_ID NUMBER
MANAGER_ID NUMBER
SALARY NUMBER(9,2)
COMMISSOIN NUMBER(7,2)
HIRE_DATE DATE
Which SELECT statement could be used to display the 10 lowest paid clerks that
belong to department 70?
Mark for Review
(1) Points
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary
FROM employees
ORDER BY salary)
WHERE ROWNUM <=10 AND job_id LIKE 'CLERK' AND department_id = 70;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Incorrect Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. You issue this statement:
ALTER SEQUENCE po_sequence INCREMENT BY 2;
Which statement is true?
Mark for Review
(1) Points
Sequence numbers will be cached.
Future sequence numbers generated will increase by 2 each time a number is
generated. (*)
If the PO_SEQUENCE sequence does not exist, it will be created.
The statement fails if the current value of the sequence is greater than the
START WITH value.
Correct Correct
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
Correct Correct
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct Correct
Previous Page 7 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq INCREMENT BY -1;
Which statement is true?
Mark for Review
(1) Points
The statement will not execute successfully.
The sequence will generate sequential descending values. (*)
The starting value of the LINE_ITEM_ID_SEQ sequence will by -1.
The minimum value of the LINE_ITEM_ID_SEQ will be the smallest possible
integer value.
Correct Correct
72. Evaluate this statement:
CREATE SEQUENCE sales_item_id_seq
START WITH 101 MAXVALUE 9000090 CYCLE;
Which statement about this CREATE SEQUENCE statement is true?
Mark for Review
(1) Points
The sequence will reuse numbers and will start with 101. (*)
The sequence will generate decrementing sequence numbers starting at 101.
The statement fails because no INCREMENT BY value is specified.
The sequence will generate sequence numbers starting with 101, but will not
reuse numbers.
Correct Correct
Section 11 Lesson 3
(Answer all questions in this section)
73. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Incorrect Incorrect. Refer to Section 11
74. The EMPLOYEES table has an index named LN_IDX on the LAST_NAME
column. You want to change this index so that it is on the FIRST_NAME column
instead. Which SQL statement will do this? Mark for Review
(1) Points
ALTER INDEX ln_idx ON employees(first_name);
ALTER INDEX ln_idx TO employees(first_name);
ALTER INDEX ln_idx TO fn_idx ON employees(first_name);
None of the above; you cannot ALTER an index. (*)
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 (*)
Incorrect Incorrect. Refer to Section 11
76. 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; (*)
Incorrect Incorrect. Refer to Section 11
77.
As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you
own.
You created a public synonym on the EMPLOYEES table owned by user
Sam.
You created a private synonym on the EMPLOYEES table owned by
user Sam. (*)
Incorrect Incorrect. Refer to Section 11
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.
(*)
An index must be created by a database administrator when a PRIMARY KEY
constraint is created.
An index is never created for a unique constraint.
An index cannot be created before a PRIMARY KEY constraint is created.
Correct 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct Correct
80. 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.
An index can prevent users from viewing certain data in a table.
Correct Correct
Previous Page 8 of 10 Next Summary
Skip navigation elements to page contents
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. 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 Correct
82. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct Correct
83. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DEPARTMENT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCT table
HIRE_DATE DATE DEFAULT SYSDATE
SALARY NUMBER (8,2) NOT NULL
On which column is an index automatically created for the EMPLOYEES table?
Mark for Review
(1) Points
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct Correct
84. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of
the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Incorrect Incorrect. Refer to Section 11
85. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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 Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. You want to grant privileges to user CHAN that will allow CHAN to
update the data in the EMPLOYEE table. Which type of privileges will you grant to
CHAN? Mark for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct Correct
87. 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
Incorrect Incorrect. Refer to Section 12
88. 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
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.
Incorrect Incorrect. Refer to Section 12
89. 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;
Incorrect Incorrect. Refer to Section 12
90. 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 Correct
Previous Page 9 of 10 Next Summary
Skip navigation elements to page contents
Test: 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 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;
Incorrect Incorrect. Refer to Section 12
92. 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Incorrect Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. 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 Correct
94. 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;
Incorrect Incorrect. Refer to Section 12
95. To join a table in your database to a table on a second (remote)
Oracle database, you need to use: Mark for Review
(1) Points
A remote procedure call
An Oracle gateway product
An ODBC driver
A database link (*)
Correct Correct
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.
Incorrect Incorrect. Refer to Section 12
97. Which of the following simplifies the administration of
privileges? Mark for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct 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;
Incorrect Incorrect. Refer to Section 12
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically
rolled back. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect Incorrect. Refer to Section 14
100. Examine the following statements:
UPDATE employees SET salary = 15000;
SAVEPOINT upd1_done;
UPDATE employees SET salary = 22000;
SAVEPOINT upd2_done;
DELETE FROM employees;
You want to retain all the employees with a salary of 15000; What statement would
you execute next?
Mark for Review
(1) Points
ROLLBACK;
ROLLBACK TO SAVEPOINT upd1_done; (*)
ROLLBACK TO SAVEPOINT upd2_done;
ROLLBACK TO SAVE upd1_done;
There is nothing you can do, either all changes must be rolled back, or none
of them can be rolled back.
Correct Correct
Previous Page 10 of 10 Summary
Skip navigation elements to page contents
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
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);
Correct Correct
2. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct Correct
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct Correct
4. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Incorrect Incorrect. Refer to Section 8
5. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
4 (*)
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 2
(Answer all questions in this section)
6. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct Correct
7. The TIMESTAMP data type allows what? Mark for Review
(1) Points
Time to be stored as an interval of years and months.
Time to be stored as a date with fractional seconds. (*)
Time to be stored as an interval of days to hours, minutes and seconds.
None of the above.
Incorrect Incorrect. Refer to Section 8
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
Correct Correct
9. 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 Correct
10. 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 Correct
Page 1 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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
12. 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
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect Incorrect. Refer to Section 8 Lesson 3
14. 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. (*)
Correct Correct
15. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct Correct
16. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct Correct
17. 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
Correct Correct
18. To do a logical delete of a column without the performance
penalty of rewriting all the table datablocks you can issue the following command:
Mark for Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Incorrect Incorrect. Refer to Section 8 Lesson 3
19. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct Correct
20. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is
not empty. (*)
Incorrect Incorrect. Refer to Section 8 Lesson 3
Previous Page 2 of 10 Next Summary
Skip navigation elements to page contents
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. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Incorrect Incorrect. Refer to Section 8 Lesson 3
22. 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 (*)
Correct 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
 address VARCHAR2(25),
 city VARCHAR2(25),
 region VARCHAR2(25),
 postal_code VARCHAR2(11),
 CONSTRAINT customer_id_un UNIQUE(customer_id),
 CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct Correct
25. 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 Correct
26. 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
Correct Correct
27. Which constraint can only be created at the column level? Mark
for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct Correct
28. A table can only have one unique key constraint defined. True or
False? Mark for Review
(1) Points
True
False (*)
Correct Correct
29. 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 Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the
same datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Incorrect Incorrect. Refer to Section 9
Previous Page 3 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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 of the following types of constraints enforces uniqueness?
Mark for Review
(1) Points
CHECK
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct Correct
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.
Incorrect Incorrect. Refer to Section 9
33. 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 Correct
34. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE);
(*)
Incorrect Incorrect. Refer to Section 9
35. 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
Correct Correct
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 (*)
Correct Correct
37. 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. (*)
Incorrect Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
Correct Correct
39. 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
Incorrect Incorrect. Refer to Section 9
40. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct Correct
Previous Page 4 of 10 Next Summary
Skip navigation elements to page contents
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. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct Correct
42. You need to display the names and definitions of constraints only
in your schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct 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. (*)
Incorrect Incorrect. Refer to Section 9
44. 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;
Correct Correct
45. 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 (*)
ENABLE
Incorrect Incorrect. Refer to Section 9
46. What actions can be performed on or with Constraints? Mark
for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct Correct
47. 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);
ALTER TABLE employee
ADD CONSTRAINT dept_id_fk FOREIGN KEY (dept_id) REFERENCES department(id);
(*)
ALTER TABLE employee
ADD FOREIGN KEY CONSTRAINT dept_id_fk ON (dept_id) REFERENCES department(id);
ALTER TABLE employee
ADD FOREIGN KEY department(id) REFERENCES (dept_id);
Correct Correct
Section 10 Lesson 1
(Answer all questions in this section)
48. 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 Correct
49. 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 Correct
50. 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. (*)
Incorrect Incorrect. Refer to Section 10
Previous Page 5 of 10 Next Summary
Skip navigation elements to page contents
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 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct Correct
54. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple (*)
inline
complex
Incorrect Incorrect. Refer to Section 10
55. Which statement about the CREATE VIEW statement is false? Mark
for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Incorrect Incorrect. Refer to Section 10
Section 10 Lesson 2
(Answer all questions in this section)
56. 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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 Correct
59. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct 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
Correct Correct
Previous Page 6 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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.
Correct Correct
62. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct Correct
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
SELECT (*)
Correct 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 Correct
65. Evaluate this SELECT statement:
SELECT ROWNUM "Rank", customer_id, new_balance
FROM
(SELECT customer_id, new_balance
FROM customer_finance
ORDER BY new_balance DESC)
WHERE ROWNUM <= 25;
Which type of query is this SELECT statement?
Mark for Review
(1) Points
A Top-n query (*)
A complex view
A simple view
A hierarchical view
Correct Correct
66. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect Incorrect. Refer to Section 10
67. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
JOB_ID NUMBER
MANAGER_ID NUMBER
SALARY NUMBER(9,2)
COMMISSOIN NUMBER(7,2)
HIRE_DATE DATE
Which SELECT statement could be used to display the 10 lowest paid clerks that
belong to department 70?
Mark for Review
(1) Points
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary
FROM employees
ORDER BY salary)
WHERE ROWNUM <=10 AND job_id LIKE 'CLERK' AND department_id = 70;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Incorrect Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. You issue this statement:
ALTER SEQUENCE po_sequence INCREMENT BY 2;
Which statement is true?
Mark for Review
(1) Points
Sequence numbers will be cached.
Future sequence numbers generated will increase by 2 each time a number is
generated. (*)
If the PO_SEQUENCE sequence does not exist, it will be created.
The statement fails if the current value of the sequence is greater than the
START WITH value.
Correct Correct
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
Correct Correct
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct Correct
Previous Page 7 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq INCREMENT BY -1;
Which statement is true?
Mark for Review
(1) Points
The statement will not execute successfully.
The sequence will generate sequential descending values. (*)
The starting value of the LINE_ITEM_ID_SEQ sequence will by -1.
The minimum value of the LINE_ITEM_ID_SEQ will be the smallest possible
integer value.
Correct Correct
72. Evaluate this statement:
CREATE SEQUENCE sales_item_id_seq
START WITH 101 MAXVALUE 9000090 CYCLE;
Which statement about this CREATE SEQUENCE statement is true?
Mark for Review
(1) Points
The sequence will reuse numbers and will start with 101. (*)
The sequence will generate decrementing sequence numbers starting at 101.
The statement fails because no INCREMENT BY value is specified.
The sequence will generate sequence numbers starting with 101, but will not
reuse numbers.
Correct Correct
Section 11 Lesson 3
(Answer all questions in this section)
73. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Incorrect Incorrect. Refer to Section 11
74. The EMPLOYEES table has an index named LN_IDX on the LAST_NAME
column. You want to change this index so that it is on the FIRST_NAME column
instead. Which SQL statement will do this? Mark for Review
(1) Points
ALTER INDEX ln_idx ON employees(first_name);
ALTER INDEX ln_idx TO employees(first_name);
ALTER INDEX ln_idx TO fn_idx ON employees(first_name);
None of the above; you cannot ALTER an index. (*)
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 (*)
Incorrect Incorrect. Refer to Section 11
76. 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; (*)
Incorrect Incorrect. Refer to Section 11
77.
As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you
own.
You created a public synonym on the EMPLOYEES table owned by user
Sam.
You created a private synonym on the EMPLOYEES table owned by
user Sam. (*)
Incorrect Incorrect. Refer to Section 11
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.
(*)
An index must be created by a database administrator when a PRIMARY KEY
constraint is created.
An index is never created for a unique constraint.
An index cannot be created before a PRIMARY KEY constraint is created.
Correct 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct Correct
80. 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.
An index can prevent users from viewing certain data in a table.
Correct Correct
Previous Page 8 of 10 Next Summary
Skip navigation elements to page contents
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. 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 Correct
82. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct Correct
83. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DEPARTMENT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCT table
HIRE_DATE DATE DEFAULT SYSDATE
SALARY NUMBER (8,2) NOT NULL
On which column is an index automatically created for the EMPLOYEES table?
Mark for Review
(1) Points
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct Correct
84. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of
the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Incorrect Incorrect. Refer to Section 11
85. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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 Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. You want to grant privileges to user CHAN that will allow CHAN to
update the data in the EMPLOYEE table. Which type of privileges will you grant to
CHAN? Mark for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct Correct
87. 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
Incorrect Incorrect. Refer to Section 12
88. 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
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.
Incorrect Incorrect. Refer to Section 12
89. 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;
Incorrect Incorrect. Refer to Section 12
90. 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 Correct
Previous Page 9 of 10 Next Summary
Skip navigation elements to page contents
Test: 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 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;
Incorrect Incorrect. Refer to Section 12
92. 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Incorrect Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. 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 Correct
94. 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;
Incorrect Incorrect. Refer to Section 12
95. To join a table in your database to a table on a second (remote)
Oracle database, you need to use: Mark for Review
(1) Points
A remote procedure call
An Oracle gateway product
An ODBC driver
A database link (*)
Correct Correct
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.
Incorrect Incorrect. Refer to Section 12
97. Which of the following simplifies the administration of
privileges? Mark for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct 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;
Incorrect Incorrect. Refer to Section 12
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically
rolled back. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect Incorrect. Refer to Section 14
100. Examine the following statements:
UPDATE employees SET salary = 15000;
SAVEPOINT upd1_done;
UPDATE employees SET salary = 22000;
SAVEPOINT upd2_done;
DELETE FROM employees;
You want to retain all the employees with a salary of 15000; What statement would
you execute next?
Mark for Review
(1) Points
ROLLBACK;
ROLLBACK TO SAVEPOINT upd1_done; (*)
ROLLBACK TO SAVEPOINT upd2_done;
ROLLBACK TO SAVE upd1_done;
There is nothing you can do, either all changes must be rolled back, or none
of them can be rolled back.
Correct Correct
Previous Page 10 of 10 Summary
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. 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
Correct
2. 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 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)
Incorrect. Refer to Section 8
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
4. 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);
Correct
5. Which statement about creating a table is true? Mark for
Review
(1) Points
With a CREATE TABLE statement, a table will always be
created in the current user's schema.
If no schema is explicitly included in a CREATE TABLE
statement, the table is created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE
statement, the CREATE TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE
statement and the schema does not exist, it will be created.
Correct
Section 8 Lesson 2
(Answer all questions in this section)
6. 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
7. 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 (*)
Correct
8. 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
Correct
9. 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
10. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish? Mark for Review
(1) Points
Sales identification values could be either numbers
or characters, or a combination of both.
All employee identification values are only 6 digits
so the column should be variable in length.
Description values can range from 0 to 30 characters
so the column should be fixed in length.
Today's date should be used if no value is provided
for the sale date. (*)
Correct
Page 1 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 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));
Correct
2. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct
3. 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
Correct
4. Which column name is valid? Mark for Review
(1) Points
1NUMBER
NUMBER
NUMBER_1$ (*)
1_NUMBER#
Incorrect. Refer to Section 8
5. Which statement about creating a table is true? Mark for Review
(1) Points
With a CREATE TABLE statement, a table will always be created in the current
user's schema.
If no schema is explicitly included in a CREATE TABLE statement, the table is
created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE statement, the CREATE
TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE statement and the schema
does not exist, it will be created.
Correct
Section 8 Lesson 2
(Answer all questions in this section)
6. The TIMESTAMP data type allows what? Mark for Review
(1) Points
Time to be stored as an interval of years and months.
Time to be stored as a date with fractional seconds. (*)
Time to be stored as an interval of days to hours, minutes and seconds.
None of the above.
Correct
7. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
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 (*)
Correct
9. 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
Correct
10. 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
Page 1 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 2
(Answer all questions in this section)
11. 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
12. Which data types stores variable-length character data? Select two. Mark
for Review
(1) Points
(Choose all correct answers)
CHAR
NCHAR
VARCHAR (*)
VARCHAR2 (*)
Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Correct
14. 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
Correct
15. You need to change the name of the EMPLOYEE table to the EMP table. Which
statement should you use? Mark for Review
(1) Points
RENAME employee emp;
RENAME employee TO emp; (*)
ALTER TABLE employee TO emp;
ALTER TABLE employee RENAME TO emp;
Correct
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Correct
17. 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
18. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is not
empty. (*)
Correct
19. To do a logical delete of a column without the performance penalty of
rewriting all the table datablocks you can issue the following command: Mark for
Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Correct
20. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
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. Which statement about a column is NOT true? Mark for Review
(1) Points
You can increase the width of a CHAR column.
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.
You can decrease the width of a VARCHAR2 column.
Correct
22. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Correct
23. 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
Section 9 Lesson 1
(Answer all questions in this section)
24. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
10
You can have as many NOT NULL constraints as you have columns in your table.
(*)
Correct
25. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
address VARCHAR2(25),
city VARCHAR2(25),
region VARCHAR2(25),
postal_code VARCHAR2(11),
CONSTRAINT customer_id_un UNIQUE(customer_id),
CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct
26. 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
27. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Correct
28. 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
Correct
29. 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
Section 9 Lesson 2
(Answer all questions in this section)
30. 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) (*)
CHECK CONSTRAINT part_cost_ck (cost > 1.00)
CONSTRAINT CHECK part_cost_ck (cost > 1.00)
Correct
Page 3 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 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
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. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the same
datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Correct
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
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
35. 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
36. Which of the following types of constraints enforces uniqueness? Mark for
Review
(1) Points
CHECK
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct
37. 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.
Correct
Section 9 Lesson 3
(Answer all questions in this section)
38. 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
Correct
39. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct
40. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
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. Examine the structures of the PRODUCT and SUPPLIER tables.
PRODUCT
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIER table
LIST_PRICE NUMBER (7,2)
COST NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
REORDER_QTY NUMBER
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;
For which task would you issue this statement?
Mark for Review
(1) Points
To remove all constraint references to SUPPLIERS table
To drop the FOREIGN KEY constraint on the PRODUCTS table
To remove all constraint references to the PRODUCTS table
To disable any dependent integrity constraints on the SUPPLIER_ID column in the
PRODUCTS table
To disable any dependent integrity constraints on the SUPPLIER_ID column in the
SUPPLIERS table (*)
Incorrect. Refer to Section 9
42. 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 (*)
ENABLE
Correct
43. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
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
45. 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
Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES employees
(employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY BETWEEN salary (employee_id) AND
employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees (employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) = employees
(employee_id);
Correct
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 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
47. 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);
ALTER TABLE employee
ADD CONSTRAINT dept_id_fk FOREIGN KEY (dept_id) REFERENCES department(id);
(*)
ALTER TABLE employee
ADD FOREIGN KEY CONSTRAINT dept_id_fk ON (dept_id) REFERENCES department(id);
ALTER TABLE employee
ADD FOREIGN KEY department(id) REFERENCES (dept_id);
Correct
Section 10 Lesson 1
(Answer all questions in this section)
48. Which of the following keywords cannot be used when creating a view? Mark
for Review
(1) Points
HAVING
WHERE
ORDER BY (*)
They are all valid keywords when creating views.
Correct
49. Which statement about the CREATE VIEW statement is false? Mark for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
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.
Create a view. (*)
Create a subquery.
Create a trigger.
Correct
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. 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
52. 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
53. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Correct
54. 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
55. 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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct
Section 10 Lesson 2
(Answer all questions in this section)
56. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct
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 (*)
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. You cannot create a view if the view subquery contains an inline view. True
or False? Mark for Review
(1) Points
True
False (*)
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
Correct
Page 6 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 2
(Answer all questions in this section)
61. You cannot modify data in a view if the view contains ______. Mark for
Review
(1) Points
the DISTINCT keyword (*)
a WHERE clause
a subquery in the FROM clause
the WITH CHECK OPTION clause
Correct
62. 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
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
64. 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. (*)
Incorrect. Refer to Section 10
65. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
66. 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
67. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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
Section 11 Lesson 2
(Answer all questions in this section)
68. 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
Correct
69. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Correct
70. Which of the following best describes the function of the CURRVAL virtual
column? Mark for Review
(1) Points
The CURRVAL virtual column will display the integer that was most recently
supplied by a sequence. (*)
The CURRVAL virtual column will increment a sequence by a specified value.
The CURRVAL virtual column will display either the physical locations or the
logical locations of the rows in the table.
The CURRVAL virtual column will return a value of 1 for a parent record in a
hierarchical result set.
Incorrect. Refer to Section 11
Page 7 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 2
(Answer all questions in this section)
71. Creating a sequence with NOCACHE ensures that all numbers in the sequence's
range will be used successfully. True or False? Mark for Review
(1) Points
True
False (*)
Correct
72. 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 ; (*)
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
On which column is an index automatically created for the EMPLOYEES table?
Mark for Review
(1) Points
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct
74. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you own.
You created a public synonym on the EMPLOYEES table owned by user Sam.
You created a private synonym on the EMPLOYEES table owned by user Sam. (*)
Correct
75. 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.
An index can prevent users from viewing certain data in a table.
Correct
76. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
77. 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;
Incorrect. Refer to Section 11
78. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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
79. When creating an index on one or more columns of a table, which of the
following statements are true? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
You should create an index if the table is large and most queries are expected
to retrieve less than 2 to 4 percent of the rows. (*)
You should always create an index on tables that are frequently updated.
You should create an index if one or more columns are frequently used together
in a join condition. (*)
You should create an index if the table is very small.
Correct
80. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
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. 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
82. 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
83. 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. (*)
An index must be created by a database administrator when a PRIMARY KEY
constraint is created.
An index is never created for a unique constraint.
An index cannot be created before a PRIMARY KEY constraint is created.
Correct
84. 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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
85. 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 (*)
Incorrect. Refer to Section 11
Section 12 Lesson 2
(Answer all questions in this section)
86. 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
87. 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 (*)
Incorrect. Refer to Section 12
88. 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;
Correct
89. 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
90. Which of the following are system privileges? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE PROCEDURE (*)
INDEX
Correct
Page 9 of 10
Test: 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. 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;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
(*)
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
Correct
92. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
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
Correct
94. Which keyword would you use to grant an object privilege to all database
users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Correct
95. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other object privileges on the table to other users. True or False? Mark for
Review
(1) Points
True
False (*)
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. 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
Section 14 Lesson 1
(Answer all questions in this section)
99. 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
Correct
100. If a database crashes, all uncommitted changes are automatically rolled
back. True or False? Mark for Review
(1) Points
True (*)
False
Correct
Page 10 of 10
1. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
4 (*)
Incorrect. Refer to Section 8
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));
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Incorrect. Refer to Section 8
3. 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));
Correct
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
Correct
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.
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
Section 8 Lesson 2
(Answer all questions in this section)
6. 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 (*)
Correct
7. 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
8. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Correct
9. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
10. 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
Correct
11. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct
12. 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
Correct
Section 8 Lesson 3
(Answer all questions in this section)
13. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Correct
14. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
ALTER TABLE teams REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Incorrect. Refer to Section 8 Lesson 3
15. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
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
Incorrect. Refer to Section 8 Lesson 3
17. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct
18. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Correct
19. Examine the structure of the DONATIONS table.
DONATIONS:
PLEDGE_ID NUMBER
DONOR_ID NUMBER
PLEDGE_DT DATE
AMOUNT_PLEDGED NUMBER (7,2)
AMOUNT_PAID NUMBER (7,2)
PAYMENT_DT DATE
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
You CANNOT decrease the width of the AMOUNT_PLEDGED column.
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.
Incorrect. Refer to Section 8 Lesson 3
20. Which statement about a column is NOT true? Mark for Review
(1) Points
You can increase the width of a CHAR column.
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.
You can decrease the width of a VARCHAR2 column.
Incorrect. Refer to Section 8 Lesson 3
21. 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.
Incorrect. Refer to Section 8
22. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
23. 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. (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. 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
25. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
address VARCHAR2(25),
city VARCHAR2(25),
region VARCHAR2(25),
postal_code VARCHAR2(11),
CONSTRAINT customer_id_un UNIQUE(customer_id),
CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct
26. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
5
10
You can have as many NOT NULL constraints as you have columns in your table.
(*)
Correct
27. 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
28. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Correct
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE);
(*)
Correct
31. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
Correct
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
Correct
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
ON DELETE SET NULL
Incorrect. Refer to Section 9
34. How many PRIMARY KEY constraints can be created for each table? Mark for
Review
(1) Points
none
one and only one (*)
one or two
unlimited
Correct
35. 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
Correct
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. (*)
Incorrect. Refer to Section 9
37. 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.
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
39. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Correct
40. 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 (*)
ENABLE
Correct
41. 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
42. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct
43. 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;
Correct
44. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
Incorrect. Refer to Section 9
45. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Incorrect. Refer to Section 9
46. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Incorrect. Refer to Section 9
47. 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
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
WITH READ ONLY
Correct
49. 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
50. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Correct
51. 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
52. The FACULTY table contains these columns:
FACULTYID VARCHAR2(5) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(20)
LAST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
STATUS VARCHAR2(2) NOT NULL
The COURSE table contains these columns:
COURSEID VARCHAR2(5) NOT NULL PRIMARY KEY
SUBJECT VARCHAR2(5)
TERM VARCHAR2(6
FACULTYID VARCHAR2(5) NOT NULL FOREIGN KEY
You have been asked to compile a report that identifies all adjunct professors who
will be teaching classes in the upcoming term. You want to create a view that will
simplify the creation of this report. Which CREATE VIEW statements will accomplish
this task?
Mark for Review
(1) Points
CREATE VIEW
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty, course
WHERE facultyid = facultyid);
CREATE VIEW pt_view ON
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f and course c
WHERE f.facultyid = c.facultyid);
CREATE VIEW pt_view IN
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty course);
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
(*)
Incorrect. Refer to Section 10
53. 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
54. Which statement about the CREATE VIEW statement is false? Mark for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Incorrect. Refer to Section 10
55. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Incorrect. Refer to Section 10
Section 10 Lesson 2
(Answer all questions in this section)
56. 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
Correct
57. You create a view on the EMPLOYEES and DEPARTMENTS tables to display salary
information per department. What will happen if you issue the following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points
A complex view is created that returns the sum of salaries per department,
sorted by department name. (*)
A simple view is created that returns the sum of salaries per department,
sorted by department name.
A complex view is created that returns the sum of salaries per department,
sorted by department id.
Nothing, as the statement constains an error and will fail.
Correct
58. 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.
Correct
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 (*)
Correct
60. 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.
(*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in subquery
Correct
61. 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.
(*)
Incorrect. Refer to Section 10
62. 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
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 execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
64. 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
65. 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; (*)
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Correct
69. Which pseudocolumn returns the latest value supplied by a sequence? Mark
for Review
(1) Points
NEXTVAL
CURRVAL (*)
CURRENT
NEXT
Incorrect. Refer to Section 11
70. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Incorrect. Refer to Section 11
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 ; (*)
Incorrect. Refer to Section 11
72. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq CYCLE;
Which statement is true?
Mark for Review
(1) Points
The sequence cannot be used with more than one table.
The sequence preallocates values and retains them in memory.
The sequence cannot generate additional values after reaching its maximum
value.
The sequence will continue to generate values after the maximum sequence value
has been generated. (*)
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. 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
an index (*)
a FOREIGN KEY constraint
Correct
74. 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
75. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
76. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
77. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
78. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
79. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
80. Unique indexes are automatically created on columns that have which two
types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
81. 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
82. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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. (*)
Incorrect. Refer to Section 11
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
(1) Points
CREATE INDEX fl_idx ON employees(first_name || last_name);
CREATE INDEX fl_idx ON employees(first_name), employees(last_name);
CREATE INDEX fl_idx ON employees(first_name,last_name);
(*)
CREATE INDEX fl_idx ON employees(first_name);
CREATE INDEX fl_idx ON employees(last_name);
Correct
84. 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
85. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true?
Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index. (*)
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
87. 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
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
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
Incorrect. Refer to Section 12
89. 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
90. 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;
Correct
91. 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
Incorrect. Refer to Section 12
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.
GRANT SELECT ON employees_view TO public;
GRANT SELECT ON employees_view TO audrey; (*)
GRANT SELECT ON employees AND employees_view TO audrey;
Correct
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to grant privileges to a role? Mark for
Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
Correct
94. Which of the following simplifies the administration of privileges? Mark
for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
95. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other object privileges on the table to other users. True or False? Mark for
Review
(1) Points
True
False (*)
Correct
96. Which statement would you use to grant a role to users? Mark for Review
(1) Points
GRANT (*)
ALTER USER
CREATE USER
ASSIGN
Incorrect. Refer to Section 12
97. Which keyword would you use to grant an object privilege to all database
users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Correct
98. 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
Incorrect. Refer to Section 12
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
Incorrect. Refer to Section 14
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 (*)
None of the above
Correct
News
Travel
Finance
EntertainmentYahoo!My Yahoo!MailTutorialsMore Welcome, jibotean2002Sign OutHelp
Make Y! your home pageYahoo! SearchSearch:
Mail| Addresses | Calendar | Notepad Mail Upgrades - Options Check MailCompose
Search Mail: Search MailSearch the Web
Yahoo! Tech
Tech made easy
Folders[Add - Edit]
Inbox Draft Sent Bulk (5)[Empty] Trash[Empty]
Search Shortcuts
My Photos My Attachments
Yahoo! Autos
Find Your Next Car
Discover Smash
On Yahoo! Music
Yahoo! Travel
Plan Your Getaway
Watch Videos
On Yahoo! Music
Sorry, this feature is not yet available in your country.
You can still receive new mail alerts through Yahoo! Messenger, or automatically
manage your messages using filters.
Previous | Next | Back to Messages Call or Instant Message
DeleteReplyForwardSpamMove...
Printable View This message is not flagged. [ Flag Message - Mark as Unread ]
Date: Fri, 8 Jun 2007 00:54:26 -0700 (PDT)
From: jibotean2002@yahoo.com Add to Address Book Add Mobile Alert
Subject: feedback
To: jibotean2002@yahoo.com
Plain Text Attachment [ Scan and Save to Computer ]
Skip navigation elements to page contents
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
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);
Correct Correct
2. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary,
department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM
employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct Correct
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));
CREATE TABLE travel (destination_id number primary key, departure_date
date, return_date date, emp_id number(10) REFERENCES employees
(emp_id)); (*)
Correct Correct
4. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Incorrect Incorrect. Refer to Section 8
5. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
3
4 (*)
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 2
(Answer all questions in this section)
6. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or
a combination of both.
All employee identification values are only 6 digits so the column
should be variable in length.
Description values can range from 0 to 30 characters so the column
should be fixed in length.
Today's date should be used if no value is provided for the sale date.
(*)
Correct Correct
7. The TIMESTAMP data type allows what? Mark for Review
(1) Points
Time to be stored as an interval of years and months.
Time to be stored as a date with fractional seconds. (*)
Time to be stored as an interval of days to hours, minutes and
seconds.
None of the above.
Incorrect Incorrect. Refer to Section 8
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
Correct Correct
9. 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 Correct
10. 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 Correct
Page 1 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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
12. 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
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory'
statement.
Incorrect Incorrect. Refer to Section 8 Lesson 3
14. 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. (*)
Correct Correct
15. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct Correct
16. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2)
(*)
Correct Correct
17. 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
Correct Correct
18. To do a logical delete of a column without the performance
penalty of rewriting all the table datablocks you can issue the following
command: Mark for Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Incorrect Incorrect. Refer to Section 8 Lesson 3
19. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct Correct
20. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification
numbers. Business requirements have changed and you need to allow users
to include text characters in the identification values. Which
statement should you use to change this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the
table is not empty. (*)
Incorrect Incorrect. Refer to Section 8 Lesson 3
Previous Page 2 of 10 Next Summary
Skip navigation elements to page contents
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. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Incorrect Incorrect. Refer to Section 8 Lesson 3
22. 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 (*)
Correct 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
 address VARCHAR2(25),
 city VARCHAR2(25),
 region VARCHAR2(25),
 postal_code VARCHAR2(11),
 CONSTRAINT customer_id_un UNIQUE(customer_id),
 CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct Correct
25. 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 Correct
26. 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
Correct Correct
27. Which constraint can only be created at the column level? Mark
for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct Correct
28. A table can only have one unique key constraint defined. True or
False? Mark for Review
(1) Points
True
False (*)
Correct Correct
29. 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 Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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 automatically
increments by a value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of
the same datatype in another table.
Data that is entered into a primary key column is restricted to a
range of numbers that is defined by the local Oracle database.
Incorrect Incorrect. Refer to Section 9
Previous Page 3 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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 of the following types of constraints enforces uniqueness?
Mark for Review
(1) Points
CHECK
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct Correct
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.
Incorrect Incorrect. Refer to Section 9
33. 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 Correct
34. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk
REFERENCES donors(donor_id), pledge_date DATE, amount_pledged
NUMBER(7,2), amount_paid NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk
REFERENCES donors(donor_id), pledge_date DATE, amount_pledged
NUMBER(7,2), amount_paid NUMBER(7,2), payment_dt DATE);
(*)
Incorrect Incorrect. Refer to Section 9
35. 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
f
NOT NULL
FOREIGN KEY (*)
PRIMARY KEY
Correct Correct
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 (*)
Correct Correct
37. 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. (*)
Incorrect Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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
to activate a new constraint while preventing the creation of a
PRIMARY KEY index
to activate the previously disabled constraint on the EMP_ID column
while creating a PRIMARY KEY index (*)
Correct Correct
39. 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
Incorrect Incorrect. Refer to Section 9
40. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the
PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct Correct
Previous Page 4 of 10 Next Summary
Skip navigation elements to page contents
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. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a
manager must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting
manager ID to match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates
each employee ID must be unique.
Correct Correct
42. You need to display the names and definitions of constraints
only in your schema. Which data dictionary view should you query? Mark
for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct 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. (*)
Incorrect Incorrect. Refer to Section 9
44. 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;
Correct Correct
45. 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 (*)
ENABLE
Incorrect Incorrect. Refer to Section 9
46. What actions can be performed on or with Constraints? Mark
for
Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct Correct
47. 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);
ALTER TABLE employee
ADD CONSTRAINT dept_id_fk FOREIGN KEY (dept_id) REFERENCES
department(id);
(*)
ALTER TABLE employee
ADD FOREIGN KEY CONSTRAINT dept_id_fk ON (dept_id) REFERENCES
department(id);
ALTER TABLE employee
ADD FOREIGN KEY department(id) REFERENCES (dept_id);
Correct Correct
Section 10 Lesson 1
(Answer all questions in this section)
48. 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 Correct
49. 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 Correct
50. 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. (*)
Incorrect Incorrect. Refer to Section 10
Previous Page 5 of 10 Next Summary
Skip navigation elements to page contents
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 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are
achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not
exist. (*)
The statements will NOT return all of the desired results because the
WITH CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be
added to the CREATE VIEW statement: 'ORDER ON salary, last_name,
first_name'.
Correct Correct
54. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple (*)
inline
complex
Incorrect Incorrect. Refer to Section 10
55. Which statement about the CREATE VIEW statement is false? Mark
for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Incorrect Incorrect. Refer to Section 10
Section 10 Lesson 2
(Answer all questions in this section)
56. 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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 Correct
59. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN
j.lowest_sal and j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department",
e.salary "Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN
j.lowest_sal and j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department",
e.salary "Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN
j.lowest_sal and j.highest_sal);
Correct 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
Correct Correct
Previous Page 6 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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.
Correct Correct
62. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct Correct
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
SELECT (*)
Correct 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 Correct
65. Evaluate this SELECT statement:
SELECT ROWNUM "Rank", customer_id, new_balance
FROM
(SELECT customer_id, new_balance
FROM customer_finance
ORDER BY new_balance DESC)
WHERE ROWNUM <= 25;
Which type of query is this SELECT statement?
Mark for Review
(1) Points
A Top-n query (*)
A complex view
A simple view
A hierarchical view
Correct Correct
66. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view.
(*)
You can only insert records into the SALES table using the SALES_VIEW
view.
The CREATE VIEW statement generates an error.
Incorrect Incorrect. Refer to Section 10
67. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
JOB_ID NUMBER
MANAGER_ID NUMBER
SALARY NUMBER(9,2)
COMMISSOIN NUMBER(7,2)
HIRE_DATE DATE
Which SELECT statement could be used to display the 10 lowest paid
clerks that belong to department 70?
Mark for Review
(1) Points
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee",
salary "Salary"
FROM
(SELECT last_name, first_name, salary
FROM employees
ORDER BY salary)
WHERE ROWNUM <=10 AND job_id LIKE 'CLERK' AND department_id = 70;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee",
salary "Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Incorrect Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. You issue this statement:
ALTER SEQUENCE po_sequence INCREMENT BY 2;
Which statement is true?
Mark for Review
(1) Points
Sequence numbers will be cached.
Future sequence numbers generated will increase by 2 each time a
number is generated. (*)
If the PO_SEQUENCE sequence does not exist, it will be created.
The statement fails if the current value of the sequence is greater
than the START WITH value.
Correct Correct
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
Correct Correct
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct Correct
Previous Page 7 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq INCREMENT BY -1;
Which statement is true?
Mark for Review
(1) Points
The statement will not execute successfully.
The sequence will generate sequential descending values. (*)
The starting value of the LINE_ITEM_ID_SEQ sequence will by -1.
The minimum value of the LINE_ITEM_ID_SEQ will be the smallest
possible integer value.
Correct Correct
72. Evaluate this statement:
CREATE SEQUENCE sales_item_id_seq
START WITH 101 MAXVALUE 9000090 CYCLE;
Which statement about this CREATE SEQUENCE statement is true?
Mark for Review
(1) Points
The sequence will reuse numbers and will start with 101. (*)
The sequence will generate decrementing sequence numbers starting at
101.
The statement fails because no INCREMENT BY value is specified.
The sequence will generate sequence numbers starting with 101, but
will not reuse numbers.
Correct Correct
Section 11 Lesson 3
(Answer all questions in this section)
73. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or
concatenated index. (*)
Incorrect Incorrect. Refer to Section 11
74. The EMPLOYEES table has an index named LN_IDX on the LAST_NAME
column. You want to change this index so that it is on the FIRST_NAME
column instead. Which SQL statement will do this? Mark for Review
(1) Points
ALTER INDEX ln_idx ON employees(first_name);
ALTER INDEX ln_idx TO employees(first_name);
ALTER INDEX ln_idx TO fn_idx ON employees(first_name);
None of the above; you cannot ALTER an index. (*)
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 (*)
Incorrect Incorrect. Refer to Section 11
76. 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; (*)
Incorrect Incorrect. Refer to Section 11
77.
As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you
own.
You created a public synonym on the EMPLOYEES table owned by user
Sam.
You created a private synonym on the EMPLOYEES table owned by
user
Sam. (*)
Incorrect Incorrect. Refer to Section 11
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. (*)
An index must be created by a database administrator when a PRIMARY
KEY constraint is created.
An index is never created for a unique constraint.
An index cannot be created before a PRIMARY KEY constraint is created.
Correct 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct Correct
80. 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.
An index can prevent users from viewing certain data in a table.
Correct Correct
Previous Page 8 of 10 Next Summary
Skip navigation elements to page contents
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. 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 Correct
82. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically
dropped at the same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct Correct
83. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DEPARTMENT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCT
table
HIRE_DATE DATE DEFAULT SYSDATE
SALARY NUMBER (8,2) NOT NULL
On which column is an index automatically created for the EMPLOYEES
table?
Mark for Review
(1) Points
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct Correct
84. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE
columns of the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Incorrect Incorrect. Refer to Section 11
85. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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 Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. You want to grant privileges to user CHAN that will allow CHAN
to update the data in the EMPLOYEE table. Which type of privileges will
you grant to CHAN? Mark for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct Correct
87. 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
Incorrect Incorrect. Refer to Section 12
88. 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
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.
Incorrect Incorrect. Refer to Section 12
89. 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;
Incorrect Incorrect. Refer to Section 12
90. 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 Correct
Previous Page 9 of 10 Next Summary
Skip navigation elements to page contents
Test: 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 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;
Incorrect Incorrect. Refer to Section 12
92. 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Incorrect Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. 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 Correct
94. 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;
Incorrect Incorrect. Refer to Section 12
95. To join a table in your database to a table on a second (remote)
Oracle database, you need to use: Mark for Review
(1) Points
A remote procedure call
An Oracle gateway product
An ODBC driver
A database link (*)
Correct Correct
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.
Incorrect Incorrect. Refer to Section 12
97. Which of the following simplifies the administration of
privileges? Mark for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct 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;
Incorrect Incorrect. Refer to Section 12
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically
rolled back. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect Incorrect. Refer to Section 14
100. Examine the following statements:
UPDATE employees SET salary = 15000;
SAVEPOINT upd1_done;
UPDATE employees SET salary = 22000;
SAVEPOINT upd2_done;
DELETE FROM employees;
You want to retain all the employees with a salary of 15000; What
statement would you execute next?
Mark for Review
(1) Points
ROLLBACK;
ROLLBACK TO SAVEPOINT upd1_done; (*)
ROLLBACK TO SAVEPOINT upd2_done;
ROLLBACK TO SAVE upd1_done;
There is nothing you can do, either all changes must be rolled back,
or none of them can be rolled back.
Correct Correct
Previous Page 10 of 10 Summary
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk
(*) indicates a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. Which SQL function can be used to remove heading or trailing
characters (or both) from a character string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
Correct
2. Which SQL function is used to return the position where a
specific character string begins within a larger character string? Mark for
Review
(1) Points
CONCAT
INSTR (*)
LENGTH
SUBSTR
Correct
3. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Correct
4. What will the following SQL statemtent display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in
the value, size of 15 and the column labeled SALARY.
The last name and the format of the salary limited to 15 digits to
the left of the decimal and the column labeled SALARY.
The last name and salary for all employees with the format of the
salary 15 characters long, left-padded with the $ and the column labeled
SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not
found where expected."
Correct
5. You need to display the number of characters in each customer's
last name. Which function should you use? Mark for Review
(1) Points
LENGTH (*)
LPAD
COUNT
SUBSTR
Correct
6. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 12.00
You query the database and return the value 79. Which script did you
use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
(*)
Correct
7. You issue this SQL statement:
SELECT INSTR ('organizational sales', 'al')
FROM dual;
Which value is returned by this command?
Mark for Review
(1) Points
13 (*)
17
Correct
Section 1 Lesson 2
(Answer all questions in this section)
8. Which script displays '01-MAY-04' when the HIRE_DATE value is
'20-MAY-04'? Mark for Review
(1) Points
SELECT TRUNC(hire_date, 'MONTH')
FROM employee;
(*)
SELECT ROUND(hire_date, 'MONTH')
FROM employee;
SELECT ROUND(hire_date, 'MON')
FROM employee;
SELECT TRUNC(hire_date, 'MI')
FROM employee;
Correct
9. You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
Mark for Review
(1) Points
1200
1282
1282.25
1300 (*)
Correct
10. You issue this SQL statement:
SELECT TRUNC(751.367,-1)
FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
700
750 (*)
751
751.3
Correct
Page 1 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk
(*) indicates a correct answer.
Section 1 Lesson 3
(Answer all questions in this section)
11. Evaluate this SELECT statement:
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
Mark for Review
(1) Points
the current date plus 30 hours
the current date plus 30 days (*)
the current date plus 30 months
No value is returned because the SELECT statement generates an
error.
Correct
12. The EMPLOYEE table contains these columns:
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
HIRE_DATE DATE
EVAL_MONTHS NUMBER(3)
Evaluate this SELECT statement:
SELECT hire_date + eval_months
FROM employee;
The values returned by this SELECT statement will be of which data
type?
Mark for Review
(1) Points
DATE (*)
NUMBER
DATETIME
INTEGER
Correct
13. Which of the following Date Functions will add calendar months
to a date? Mark for Review
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Correct
14. You want to create a report that displays all orders and their
amounts that were placed during the month of January. You want the
orders with the highest amounts to appear first. Which query should you
issue? Mark for Review
(1) Points
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
ORDER BY total;
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
(*)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
Correct
15. You need to display the current year as a character value (for
example: Two Thousand and One). Which element would you use? Mark for
Review
(1) Points
RR
YY
YYYY
YEAR (*)
Correct
Section 2 Lesson 1
(Answer all questions in this section)
16. Which three statements concerning explicit data type conversions
are true? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
Use the TO_NUMBER function to convert a number to a character
string.
Use the TO_DATE function to convert a character string to a date
value. (*)
Use the TO_NUMBER function to convert a character string of digits
to a number. (*)
Use the TO_DATE function to convert a date value to character
string or number.
Use the TO_CHAR function to convert a number or date value to
character string. (*)
Correct
17. Which arithmetic operation will return a numeric value? Mark
for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
SYSDATE + 30 / 24
Correct
18. Which statement concerning single row functions is true? Mark
for Review
(1) Points
Single row functions can accept only one argument, but can return
multiple values.
Single row functions cannot modify a data type.
Single row functions can be nested. (*)
Single row functions return one or more results per row.
Incorrect. Refer to Section 2
19. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees.
Which script should you use to display the salaries in format:
"$45,000.00"?
Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees;
(*)
Incorrect. Refer to Section 2
20. Which functions allow you to perform explicit data type
conversions? Mark for Review
(1) Points
ROUND, TRUNC, ADD_MONTHS
LENGTH, SUBSTR, LPAD, TRIM
TO_CHAR, TO_DATE, TO_NUMBER (*)
NVL, NVL2, NULLIF
Correct
Page 2 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk
(*) indicates a correct answer.
Section 2 Lesson 1
(Answer all questions in this section)
21. If you use the RR format when writing a query using the date
27-OCT-17 and the year is 2001, what year would be the result? Mark for
Review
(1) Points
2001
1901
2017 (*)
1917
Correct
Section 2 Lesson 2
(Answer all questions in this section)
22. Which of the following General Functions will return the first
non-null expression in the expression list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
COALESCE (*)
Incorrect. Refer to Section 2
23. You need to replace null values in the DEPT_ID column with the
text "N/A". Which functions should you use? Mark for Review
(1) Points
TO_CHAR and NVL (*)
TO_CHAR and NULL
TO_CHAR and NULLIF
TO_NUMBER and NULLIF
Correct
24. When executed, which statement displays a zero if the
TUITION_BALANCE value is zero and the HOUSING_BALANCE value is null? Mark for
Review
(1) Points
SELECT NVL (tuition_balance + housing_balance, 0) "Balance Due"
FROM student_accounts;
(*)
SELECT NVL(tuition_balance, 0), NVL (housing_balance),
tuition_balance + housing_balance "Balance Due"
FROM student_accounts;
SELECT tuition_balance + housing_balance
FROM student_accounts;
SELECT TO_NUMBER(tuition_balance, 0), TO_NUMBER (housing_balance,
0), tutition_balance + housing_balance "Balance Due"
FROM student_accounts;
Correct
Section 3 Lesson 2
(Answer all questions in this section)
25. Your company stores its business information in an Oracle9i
database. The EMPLOYEES table includes the following columns:
EMP_ID NUMBER(5) NOT NULL PRIMARY KEY
FNAME VARCHAR2(25)
LNAME VARCHAR2(25)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(25)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
DEPT_ID NUMBER(5) NOT NULL FOREIGN KEY
The BONUS table includes the following columns:
BONUS_ID NUMBER(5) NOT NULL PRIMARY KEY
ANNUAL_SALARY NUMBER(10)
BONUS_PCT NUMBER(3, 2)
EMP_ID VARCHAR2(5) NOT NULL FOREIGN KEY
You want to determine the amount of each employee's bonus. Which of the
following queries should you issue?
Mark for Review
(1) Points
SELECT e.fname, e.lname, b.annual_salary * b. bonus_pct
FROM employees e, bonus b
WHERE e.emp_id = b.emp_id;
(*)
SELECT e.fname, e.lname, b.annual_salary, b. bonus_pct
FROM employees e, bonus b
WHERE e.emp_id = b.emp_id;
SELECT e.fname, e.lname, b.annual_salary, b. bonus_pct
FROM employees, bonus
WHERE e.emp_id = b.emp_id;
SELECT fname, lname, annual_salary * bonus_pct
FROM employees, bonus NATURAL JOIN;
Correct
26. What is the minimum number of join conditions required to join 5
tables together? Mark for Review
(1) Points
4 (*)
One more than the number of tables
Correct
27. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id >
5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
Correct
28. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the
total sales?
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
Correct
29. What is produced when a join condition is not specified in a
multiple-table query? Mark for Review
(1) Points
a self-join
an outer join
an equijoin
a Cartesian product (*)
Correct
30. You need to provide a list of the first and last names of all
employees who work in the Sales department who earned a bonus and had
sales over $50,000. The company president would like the sales listed
starting with the highest amount first. The EMPLOYEES table and the
SALES_DEPT table contain the following columns:
EMPLOYEES
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
SALES_DEPT
SALES_ID NUMBER(10) PRIMARY KEY
SALES NUMBER(20)
QUOTA NUMBER(20)
MGR VARCHAR2(30)
BONUS NUMBER(10)
EMP_ID NUMBER(10) FOREIGN KEY
Which SELECT statement will accomplish this task?
Mark for Review
(1) Points
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s.sales
FROM employees e, sales_dept s
ORDER BY sales DESC
WHERE e.emp_id = s.emp_id AND sales > 50000 AND s.bonus IS NOT NULL;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
ORDER BY sales DESC
FROM employees e, sales_dept s
WHERE e.emp_id = s.emp_id AND s.bonus IS NOT NULL AND sales > 50000;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
WHERE e.emp_id = s.emp_id
FROM employees e, sales_dept s AND s.bonus IS NOT NULL AND sales >
50000
ORDER BY sales DESC;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
FROM employees e, sales_dept s
WHERE e.emp_id = s.emp_id AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
(*)
Correct
Page 3 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk
(*) indicates a correct answer.
Section 3 Lesson 4
(Answer all questions in this section)
31. Evaluate this SELECT statement:
SELECT p.player_id, m.last_name, m.first_name, t.team_name
FROM player p
LEFT OUTER JOIN player m ON (p.manager_id = m.player_id)
LEFT OUTER JOIN team t ON (p.team_id = t.team_id);
Which join is evaluated first?
Mark for Review
(1) Points
the self-join of the player table (*)
the join between the player table and the team table on TEAM_ID
the join between the player table and the team table on MANAGER_ID
the join between the player table and the team table on PLAYER_ID
Correct
32. Which of the following best describes the function of an outer
join? Mark for Review
(1) Points
An outer join will return only those rows that do not meet the join
criteria.
An outer join will return only data from the far left column in one
table and the far right column in the other table.
An outer join will return data only if both tables contain an
identical pair of columns.
An outer join will return all rows that meet the join criteria and
will return NULL values from one table if no rows from the other table
satisfy the join criteria. (*)
Correct
33. Which statement about outer joins is true? Mark for Review
(1) Points
The tables must be aliased.
The FULL, RIGHT, or LEFT keyword must be included.
The OR operator cannot be used to link outer join conditions. (*)
Outer joins are always evaluated before other types of joins in the
query.
Incorrect. Refer to Section 3
Section 4 Lesson 2
(Answer all questions in this section)
34. Which of the following best describes a natural join? Mark for
Review
(1) Points
A join between two tables that includes columns that share the same
name, datatypes and lengths (*)
A join that produces a Cartesian product
A join between tables where matching fields do not exist
A join that uses only one table
Correct
35. Which of the following conditions will cause an error on a
NATURAL JOIN? Mark for Review
(1) Points
When you attempt to write it as an equijoin.
When the NATURAL JOIN clause is based on all columns in the two
tables that have the same name.
If it selects rows from the two tables that have equal values in
all matched columns.
If the columns having the same names have different data types,
then an error is returned. (*)
Correct
36. You need to join all the rows in the EMPLOYEE table to all the
rows in the EMP_REFERENCE table. Which type of join should you create?
Mark for Review
(1) Points
An equijoin
A cross join (*)
An inner join
A full outer join
Correct
Section 4 Lesson 3
(Answer all questions in this section)
37. Which of the following statements is the simplest description of
a nonequijoin? Mark for Review
(1) Points
A join condition containing something other than an equality
operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
A join that joins a table to itself
Correct
38. You created the CUSTOMERS and ORDERS tables by issuing these
CREATE TABLE statements in sequence:
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information
about orders placed by customers who reside in Nashville . Which query
should you issue to achieve the desired results?
Mark for Review
(1) Points
SELECT custid, companyname
FROM customers
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
(*)
SELECT orderid, orderdate, total
FROM orders
WHERE city = 'Nashville';
Incorrect. Refer to Section 4
39. The primary advantage of using JOIN ON is: Mark for Review
(1) Points
The join happens automatically based on matching column names and
data types
It will display rows that do not meet the join condition
It permits columns with different names to be joined (*)
It permits columns that don't have matching data types to be joined
Incorrect. Refer to Section 4
40. Evaluate this SELECT statement:
SELECT a.lname || ', ' || a.fname as "Patient", b.lname || ', ' ||
b.fname as "Physician", c.admission
FROM patient a
JOIN physician b
ON (b.physician_id = c.physician_id);
JOIN admission c
ON (a.patient_id = c.patient_id);
Which clause generates an error?
Mark for Review
(1) Points
JOIN physician b
ON (b.physician_id = c.physician_id); (*)
JOIN admission c
ON (a.patient_id = c.patient_id)
Correct
Page 4 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk
(*) indicates a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. What should be included in a SELECT statement to return NULL
values from all tables? Mark for Review
(1) Points
natural joins
left outer joins
full outer joins (*)
right outer joins
Correct
42. You need to join the EMPLOYEE_HIST and EMPLOYEE tables. The
EMPLOYEE_HIST table will be the first table in the FROM clause. All the
matched and unmatched rows in the EMPLOYEE table need to be displayed.
Which type of join will you use? Mark for Review
(1) Points
a cross join
an inner join
a left outer join
a right outer join (*)
Correct
43. Which two sets of join keywords create a join that will include
unmatched rows from the first table specified in the SELECT statement?
Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
Incorrect. Refer to Section 4
Section 5 Lesson 1
(Answer all questions in this section)
44. What is the best explanation as to why this SQL statement will
NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
Mark for Review
(1) Points
Salaries cannot be averaged as not all the numbers will divide
evenly.
You cannot use a column alias in the GROUP BY clause. (*)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Correct
45. Evaluate this SELECT statement:
SELECT MAX(salary), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The highest salary for all employees.
The highest salary in each department. (*)
The employees with the highest salaries.
The employee with the highest salary for each department.
Correct
46. Which statement about group functions is true? Mark for Review
(1) Points
Group functions ignore null values. (*)
Group functions can only be used in a SELECT list.
Group functions can be used in a WHERE clause.
A query that includes a group function in the SELECT list must
include a GROUP BY clause.
Correct
47. Evaluate this SELECT statement:
SELECT MIN(hire_date), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEE table.
The latest hire date in the EMPLOYEE table.
The hire dates in the EMPLOYEE table that contain NULL values.
Correct
Section 5 Lesson 2
(Answer all questions in this section)
48. The CUSTOMER table contains these columns:
CUSTOMER_ID NUMBER(9)
FNAME VARCHAR2(25)
LNAME VARCHAR2(30)
CREDIT_LIMIT NUMBER (7,2)
CATEGORY VARCHAR2(20)
You need to calculate the average credit limit for all the customers in
each category. The average should be calculated based on all the rows
in the table excluding any customers who have not yet been assigned a
credit limit value. Which group function should you use to calculate this
value?
Mark for Review
(1) Points
AVG (*)
SUM
COUNT
STDDEV
Correct
49. Group functions return a value for ________________ and
________________ null values in their computations. Mark for Review
(1) Points
a row set, ignore (*)
each row, ignore
a row set, include
each row, include
Incorrect. Refer to Section 5
50. You need to calculate the average salary of employees in each
department. Which group function will you use? Mark for Review
(1) Points
AVG (*)
MEAN
MEDIAN
AVERAGE
Correct
Page 5 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk
(*) indicates a correct answer.
Section 5 Lesson 2
(Answer all questions in this section)
51. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
FROM products;
What happens when this statement is issued?
Mark for Review
(1) Points
Both the average price and the average quantity of the products are
returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are
averaged together.
An error occurs. (*)
Correct
52. The TRUCKS table contains these columns:
TRUCKS
TYPE VARCHAR2(30)
YEAR DATE
MODEL VARCHAR2(20)
PRICE NUMBER(10)
Which SELECT statement will return the average price for the 4x4 model?
Mark for Review
(1) Points
SELECT AVG (price) FROM trucks WHERE model = '4x4'; (*)
SELECT AVG (price) FROM trucks WHERE model IS '4x4';
SELECT AVG(price) FROM trucks WHERE model IS 4x4;
SELECT AVG(price), model FROM trucks WHERE model IS '4x4';
Correct
53. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer
in January, February and March of 2003. Which SELECT statement should
you use?
Mark for Review
(1) Points
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct
54. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(9,2)
HIRE_DATE DATE
BONUS NUMBER(7,2)
COMM_PCT NUMBER(4,2)
Which three functions could be used with the HIRE_DATE, LAST_NAME, or
SALARY columns? (Choose three.)
Mark for Review
(1) Points
(Choose all correct answers)
MAX (*)
SUM
AVG
MIN (*)
COUNT (*)
Correct
55. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
NAME VARCHAR2(30)
LOCATION_ID NUMBER
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
Which two clauses represent valid uses of aggregate functions for this
table?
Mark for Review
(1) Points
(Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT location_id, MIN(AVG(order_amount)) (*)
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater
than $50,000? Which SELECT would you use?
Mark for Review
(1) Points
SELECT * FROM employees
WHERE salary > 50000;
SELECT * FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary > 50000;
(*)
SELECT COUNT(*) FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
Correct
57. Which statement about the COUNT function is true? Mark for
Review
(1) Points
The COUNT function ignores duplicates by default.
The COUNT function always ignores null values by default. (*)
The COUNT function can be used to find the maximum value in each
column.
The COUNT function can be used to determine the number of unique,
non-null values in a column.
Incorrect. Refer to Section 5
58. Evaluate this SQL statement:
SELECT COUNT (amount)
FROM inventory;
What will occur when the statement is issued?
Mark for Review
(1) Points
The statement will return the greatest value in the INVENTORY
table.
The statement will return the total number of rows in the AMOUNT
column.
The statement will replace all NULL values that exist in the AMOUNT
column.
The statement will count the number of rows in the INVENTORY table
where the AMOUNT column is not null. (*)
Correct
59. Which SELECT statement will calculate the number of rows in the
PRODUCTS table? Mark for Review
(1) Points
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
Correct
Section 6 Lesson 1
(Answer all questions in this section)
60. The PLAYERS table contains these columns:
PLAYER_ID NUMBER PK
PLAYER_NAME VARCHAR2 (30)
TEAM_ID NUMBER
HIRE_DATE DATE
SALARY NUMBER (8,2)
Which two clauses represent valid uses of aggregate functions? (Choose
three.)
Mark for Review
(1) Points
(Choose all correct answers)
ORDER BY AVG(salary)
GROUP BY MAX(salary) (*)
SELECT AVG(NVL(salary, 0)) (*)
HAVING MAX(salary) > 10000 (*)
WHERE hire_date > AVG(hire_date)
Incorrect. Refer to Section 6
Page 6 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk
(*) indicates a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. Evaluate this SELECT statement:
SELECT COUNT(emp_id), dept_id
FROM employee
GROUP BY dept_id;
You only want to include employees who earn more than 15000.
Which clause should you include in the SELECT statement?
Mark for Review
(1) Points
WHERE salary > 15000 (*)
HAVING salary > 15000
WHERE SUM(salary) > 15000
HAVING SUM(salary) > 15000
Incorrect. Refer to Section 6
62. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id
FROM employee
GROUP BY dept_id;
How are the results of this statement sorted?
Mark for Review
(1) Points
Ascending order by dept_id (*)
Descending order by dept_id
Ascending order by cumulative salary
Descending order by cumulative salary
Correct
63. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product
category.
Which statement could you use to accomplish this task?
Mark for Review
(1) Points
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_price;
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_cat;
(*)
SELECT MIN (prod_price), prod_cat
FROM products
GROUP BY MIN (prod_price), prod_cat;
SELECT prod_price, MIN (prod_cat)
FROM products
GROUP BY prod_cat;
Correct
64. Evaluate this statement:
SELECT department_id, AVG(salary)
FROM employees
WHERE job_id <> 69879
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000
ORDER BY department_id;
Which clauses restricts the result? Choose two.
Mark for Review
(1) Points
(Choose all correct answers)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Correct
65. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, mgr_id
FROM employee
GROUP BY dept_id, mgr_id;
Which SELECT statement clause allows you to restrict the rows returned,
based on a group function?
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
WHERE salary > 100000
HAVING salary > 100000
Correct
66. The PLAYERS and TEAMS tables contain these columns:
PLAYERS
PLAYER_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
TEAM_ID NUMBER
POSITION VARCHAR2 (25)
TEAMS
TEAM_ID NUMBER NOT NULL, Primary Key
TEAM_NAME VARCHAR2 (25)
You need to create a report that lists the names of each team with more
than five pitchers.
Which SELECT statement will produce the desired result?
Mark for Review
(1) Points
SELECT t.team_name, COUNT(p.player_id)
FROM players p, teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name;
SELECT t.team_name, COUNT(p.player_id)
FROM players JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER' HAVING COUNT(p.player_id) > 5;
SELECT t.team_name, COUNT(p.player_id)
FROM players p, teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 5;
SELECT t.team_name, COUNT(p.player_id)
FROM players p JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 5;
(*)
Correct
67. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER(9) PK
CATEGORY_ID VARCHAR2(10)
LOCATION_ID NUMBER(9)
DESCRIPTION VARCHAR2(30)
COST NUMBER(7,2)
PRICE NUMBER(7,2)
QUANTITY NUMBER
You display the total of the extended costs for each product category
by location. You need to include only the products that have a price
less than $25.00. The extended cost of each item equals the quantity value
multiplied by the cost value.
Which SQL statement will display the desired result?
Mark for Review
(1) Points
SELECT category_id, SUM(cost * quantity) TOTAL,location_id
FROM products
WHERE price > 25.00
GROUP BY category_id, location_id;
SELECT SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY location_id;
SELECT category_id, SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY category_id, location_id;
(*)
SELECT SUM(cost * quantity) TOTAL
FROM products
WHERE price < 25.00;
Incorrect. Refer to Section 6
Section 6 Lesson 2
(Answer all questions in this section)
68. If you use the equality operator (=) with a subquery, how many
values can the subquery return? Mark for Review
(1) Points
only 1 (*)
up to 2
up to 5
unlimited
Correct
69. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements
correctly use subqueries? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE
class_id = 45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE
max_capacity > 0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE
max_capacity > 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments
GROUP BY teacher_id);
Incorrect. Refer to Section 6
70. You need to display all the players whose salaries are greater
than or equal to John Brown's salary. Which comparison operator should
you use? Mark for Review
(1) Points
>
<=
>= (*)
Correct
Page 7 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk
(*) indicates a correct answer.
Section 6 Lesson 2
(Answer all questions in this section)
71. You need to create a report to display the names of products
with a cost value greater than the average cost of all products. Which
SELECT statement should you use? Mark for Review
(1) Points
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost) FROM product);
(*)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
SELECT AVG(cost), product_name
FROM products
WHERE cost > AVG(cost)
GROUP by product_name;
SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
Correct
72. Which operator can be used with a multiple-row subquery? Mark
for Review
(1) Points
IN (*)
<>
LIKE
Correct
Section 6 Lesson 3
(Answer all questions in this section)
73. If a single-row subquery returns a null value and uses the
equality comparison operator, what will the outer query return? Mark for
Review
(1) Points
no rows (*)
all the rows in the table
a null value
an error
Correct
74. Examine the structure of the EMPLOYEE, DEPARTMENT, and ORDERS
tables.
EMPLOYEE
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
DEPARTMENT
DEPARTMENT_ID NUMBER(9)
DEPARTMENT_NAME VARCHAR2(25)
CREATION_DATE DATE
ORDERS
ORDER_ID NUMBER(9)
EMPLOYEE_ID NUMBER(9)
DATE DATE
CUSTOMER_ID NUMBER(9)
You want to display all employees who had an order after the Sales
department was established. Which of the following constructs would you
use?
Mark for Review
(1) Points
a group function
a single-row subquery (*)
the HAVING clause
a MERGE statement
Correct
75. Which comparison operator can only be used with a single-row
subquery? Mark for Review
(1) Points
ANY
ALL
<> (*)
IN
Correct
Section 6 Lesson 4
(Answer all questions in this section)
76. You need to display all the products that cost more than the
maximum cost of every product produced in Japan. Which multiple-row
comparison operator could you use? Mark for Review
(1) Points
>ANY (*)
NOT=ALL
IN
>IN
Incorrect. Refer to Section 6
77. Which statement about the ANY operator when used with a
multiple-row subquery is true? Mark for Review
(1) Points
The ANY operator compares every value returned by the subquery. (*)
The ANY operator can be used with the DISTINCT keyword.
The ANY operator is a synonym for the ALL operator.
The ANY operator can be used with the LIKE and IN operators.
Correct
78. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more
than $30,000 and more than $50,000.
All employees who work in a department with employees who earn more
than $30,000, but less than $50,000. (*)
Correct
79. Evaluate the structure of the EMPLOYEE and DEPART_HIST tables:
EMPLOYEE:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
DEPART_HIST:
EMPLOYEE_ID NUMBER(9)
OLD_DEPT_ID NUMBER(9)
NEW_DEPT_ID NUMBER(9)
CHANGE_DATE DATE
You want to generate a list of employees who are in department 10, but
used to be in department 15.
Which query should you use?
Mark for Review
(1) Points
SELECT employee_id, emp_lname, emp_fname, dept_id
FROM employee
WHERE (employee_id, dept_id) IN
(SELECT employee_id, dept_id
FROM department_hist
WHERE dept_id = 15) AND dept_id = 10;
(*)
SELECT employee_id, emp_lname, emp_fname, dept_id
FROM employee
WHERE (employee_id) IN
(SELECT employee_id
FROM employee_hist
WHERE dept_id = 15);
SELECT employee_id, emp_lname, emp_fname, dept_id
FROM employee
WHERE (employee_id, dept_id) =
(SELECT employee_id, dept_id
FROM employee_hist
WHERE dept_id = 15);
SELECT employee_id, emp_lname, emp_fname, dept_id
FROM employee
WHERE (employee_id, dept_id) IN
(SELECT employee_id, dept_id
FROM employee
WHERE dept_id = 15);
Incorrect. Refer to Section 6
80. Evaluate this SELECT statement that includes a subquery:
SELECT last_name, first_name
FROM customer
WHERE area_code IN
(SELECT area_code FROM sales WHERE salesperson_id = 20);
Which statement is true about the given subquery?
Mark for Review
(1) Points
The outer query executes before the nested subquery.
The results of the inner query are returned to the outer query. (*)
An error occurs if the either the inner or outer queries do not
return a value.
Both the inner and outer queries must return a value, or an error
occurs.
Correct
Page 8 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk
(*) indicates a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. Evaluate this SELECT statement:
SELECT student_id, last_name, first_name
FROM student
WHERE major_id NOT IN
(SELECT major_id
FROM majors
WHERE department_head_id = 30 AND title = 'ADJUNCT');
What would happen if the inner query returned a NULL value row?
Mark for Review
(1) Points
A syntax error would be returned.
No rows would be returned from the STUDENT table. (*)
All the rows in the STUDENT table would be displayed.
Only the rows with STUDENT_ID values equal to NULL would be
displayed.
Correct
82. Which comparison operator would you use to compare a value to
every value returned by a subquery? Mark for Review
(1) Points
SOME
ANY
ALL (*)
IN
Correct
83. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison
operator is used. (*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Correct
84. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT payment_date, customer_id, payment_amount
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?
Mark for Review
(1) Points
Remove the subquery WHERE clause.
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Include the PAYMENT_ID column in the select list of the outer
query.
Remove the single quotes around the date value in the inner query
WHERE clause.
Correct
85. Examine the structures of the PARTS and MANUFACTURERS tables:
PARTS:
PARTS_ID VARCHAR2(25)
PK PARTS_NAME VARCHAR2(50)
MANUFACTURERS_ID NUMBER
COST NUMBER(5,2)
PRICE NUMBER(5,2)
MANUFACTURERS:
ID NUMBER
PK NAME VARCHAR2(30)
LOCATION VARCHAR2(20)
Which SQL statement correctly uses a subquery?
Mark for Review
(1) Points
UPDATE parts SET price = price * 1.15
WHERE manufacturers_id =
(SELECT id
FROM manufacturers
WHERE UPPER(location) IN('ATLANTA ', 'BOSTON ', 'DALLAS '));
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id !=
(SELECT id
FROM manufacturers
WHERE LOWER(name) = 'cost plus');
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id IN
(SELECT id
FROM manufacturers m
JOIN part p ON (m.id = p.manufacturers_id));
(*)
SELECT parts_name
FROM
(SELECT AVG(cost)
FROM manufacturers)
WHERE cost > AVG(cost);
Correct
86. Evaluate this SELECT statement:
SELECT player_id, name
FROM players
WHERE team_id IN
(SELECT team_id
FROM teams
WHERE team_id > 300 AND salary_cap > 400000);
What would happen if the inner query returned a NULL value?
Mark for Review
(1) Points
No rows would be returned by the outer query. (*)
A syntax error in the outer query would be returned.
A syntax error in the inner query would be returned.
All the rows in the PLAYER table would be returned by the outer
query.
Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. Which statement about the VALUES clause of an INSERT statement
is true? Mark for Review
(1) Points
If no column list is specified, then the values must be in the
order the columns are specified in the table. (*)
The VALUES clause in an INSERT statement is optional.
Character, date, and numeric data must be enclosed within single
quotes in the VALUES clause.
To specify a null value in the VALUES clause, use an empty string
(' ').
Correct
88. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(25)
PROD_PRICE NUMBER(3)
You want to add the following row data to the PRODUCTS table:
(1) a NULL value in the PROD_ID column
(2) "6-foot nylon leash" in the PROD_NAME column
(3) "10" in the PROD_PRICE column
You issue this statement:
INSERT INTO products
VALUES (null,'6-foot nylon leash', 10);
What row data did you add to the table?
Mark for Review
(1) Points
The row was created with the correct data in all three columns. (*)
The row was created with the correct data in two of three columns.
The row was created with the correct data in one of the three
columns.
The row was created completely wrong. No data ended up in the
correct columns.
Correct
89. Using the INSERT statement, and assuming that a column can
accept null values, how can you implicitly insert a null value in a column?
Mark for Review
(1) Points
Use the NULL keyword.
Use the ON clause
Omit the column in the column list. (*)
It is not possible to implicitly insert a null value in a column.
Correct
90. You need to copy rows from the EMPLOYEE table to the
EMPLOYEE_HIST table. What could you use in the INSERT statement to accomplish this
task? Mark for Review
(1) Points
an ON clause
a SET clause
a subquery (*)
a function
Incorrect. Refer to Section 7
Page 9 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk
(*) indicates a correct answer.
Section 7 Lesson 2
(Answer all questions in this section)
91. What would happen if you issued a DELETE statement without a
WHERE clause? Mark for Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
Correct
92. When the WHERE clause is missing in a DELETE statement, what is
the result? Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Correct
93. Which two commands can be used to modify existing data in a
database row? Mark for Review
(1) Points
(Choose all correct answers)
DELETE
INSERT (*)
SELECT
UPDATE (*)
Correct
94. You need to remove a row from the EMPLOYEE table. Which
statement would you use? Mark for Review
(1) Points
UPDATE with a WHERE clause
INSERT with a WHERE clause
DELETE with a WHERE clause (*)
MERGE with a WHERE clause
Correct
95. You need to update both the DEPARTMENT_ID and LOCATION_ID
columns in the EMPLOYEE table using one UPDATE statement. Which clause should
you include in the UPDATE statement to update multiple columns? Mark
for Review
(1) Points
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
Correct
96. You need to update the expiration date of products manufactured
before June 30th . In which clause of the UPDATE statement will you
specify this condition? Mark for Review
(1) Points
the ON clause
the WHERE clause (*)
the SET clause
the USING clause
Incorrect. Refer to Section 7
97. The PLAYERS table contains these columns:
PLAYER_ID NUMBER NOT NULL
PLAYER_LNAME VARCHAR2(20) NOT NULL
PLAYER_FNAME VARCHAR2(10) NOT NULL
TEAM_ID NUMBER
SALARY NUMBER(9,2)
You need to increase the salary of each player for all players on the
Tiger team by 12.5 percent. The TEAM_ID value for the Tiger team is
5960. Which statement should you use?
Mark for Review
(1) Points
UPDATE players (salary) SET salary = salary * 1.125;
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960;
(*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id =
5960;
Correct
98. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located
in Atlanta. Which script should you use?
Mark for Review
(1) Points
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
(*)
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
DELETE FROM products
WHERE supplier_id =
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ALANTA');
Correct
99. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5)
NAME VARCHAR2(25)
SUBJECT_ID NUMBER(5)
HIRE_DATE DATE
SALARY NUMBER(9,2)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER(5)
TEACHER_ID NUMBER(5)
START_DATE DATE
MAX_CAPACITY NUMBER(3)
Which scenario would require a subquery to return the desired results?
Mark for Review
(1) Points
You need to display the start date for each class taught by a given
teacher.
You need to create a report to display the teachers who were hired
more than five years ago.
You need to display the names of the teachers who teach classes
that start within the next week.
You need to create a report to display the teachers who teach more
classes than the average number of classes taught by each teacher. (*)
Incorrect. Refer to Section 7
100. One of the sales representatives, Janet Roper, has informed you
that she was recently married, and she has requested that you update
her name in the employee database. Her new last name is Cooper. Janet is
the only person with the last name of Roper that is employed by the
company. The EMPLOYEES table contains these columns and all data is stored
in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
Correct
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 statement about creating a table is true? Mark for Review
(1) Points
With a CREATE TABLE statement, a table will always be created in
the current user's schema.
If no schema is explicitly included in a CREATE TABLE statement,
the table is created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE statement,
the CREATE TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE statement and
the schema does not exist, it will be created.
Correct
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);
Correct
3. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Correct
4. 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));
Incorrect. Refer to Section 8
5. 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
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
Incorrect. Refer to Section 8
7. 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
8. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters,
or a combination of both.
All employee identification values are only 6 digits so the column
should be variable in length.
Description values can range from 0 to 30 characters so the column
should be fixed in length.
Today's date should be used if no value is provided for the sale
date. (*)
Incorrect. Refer to Section 8
9. 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
Incorrect. Refer to Section 8
10. 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. (*)
Incorrect. Refer to Section 8
Page 1 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 2
(Answer all questions in this section)
11. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in
the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character
data.
The CHAR data type requires that a minimum size be specified when
defining a column of this type. (*)
Incorrect. Refer to Section 8
12. 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
Section 8 Lesson 3
(Answer all questions in this section)
13. You need to change the name of the EMPLOYEE table to the EMP
table. Which statement should you use? Mark for Review
(1) Points
RENAME employee emp;
RENAME employee TO emp; (*)
ALTER TABLE employee TO emp;
ALTER TABLE employee RENAME TO emp;
Correct
14. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01
PRIMARY KEY,customerid varchar2(5) REFERENCES customers (customerid),
orderdate date, amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01
PRIMARY KEY, customerid varchar2(5) REFERENCES customers (customerid),
orderdate date, amount DEFAULT 250)
Incorrect. Refer to Section 8 Lesson 3
15. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory'
statement.
Incorrect. Refer to Section 8 Lesson 3
17. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification
numbers. Business requirements have changed and you need to allow users
to include text characters in the identification values. Which
statement should you use to change this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the
table is not empty. (*)
Incorrect. Refer to Section 8 Lesson 3
18. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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 drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Incorrect. Refer to Section 8 Lesson 3
19. 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct
20. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to
NUMBER(8,2) (*)
Correct
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. 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. (*)
Correct
22. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
23. 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 (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. A table can only have one unique key constraint defined. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. 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 (*)
Incorrect. Refer to Section 9
28. You need to add a NOT NULL constraint to the COST column in the
PART table. Which statement should you use to complete this task? Mark
for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL);
(*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Incorrect. Refer to Section 9
29. Which constraint can only be created at the column level? Mark
for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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.
Incorrect. Refer to Section 9
Page 3 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 2
(Answer all questions in this section)
31. 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
32. Which of the following best describes the function of a CHECK
constraint? Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be
entered in a column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be
entered in a column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY
constraint is created.
Incorrect. Refer to Section 9
33. 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
34. How many PRIMARY KEY constraints can be created for each table?
Mark for Review
(1) Points
none
one and only one (*)
one or two
unlimited
Incorrect. Refer to Section 9
35. 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
Correct
36. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
Correct
37. 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 (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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);
Incorrect. Refer to Section 9
39. You need to display the names and definitions of constraints
only in your schema. Which data dictionary view should you query? Mark
for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
40. 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
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. 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);
(*)
ALTER TABLE employee
MODIFY emp_id PRIMARY KEY;
ALTER TABLE employee
MODIFY CONSTRAINT PRIMARY KEY (emp_id);
Correct
42. What actions can be performed on or with Constraints? Mark for
Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct
43. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS
table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
44. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Incorrect. Refer to Section 9
45. Which of the following would always cause an integrity
constraint error? Mark for Review
(1) Points
Using a subquery in an INSERT statement.
Using the MERGE statement to conditionally insert or update rows.
Using the DELETE command on a row that contains a primary key with
a dependent foreign key. (*)
Using the UPDATE command on rows based in another table.
Incorrect. Refer to Section 9
46. 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 Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES
employees (employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY BETWEEN salary (employee_id)
AND employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees
(employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) =
employees (employee_id);
Incorrect. Refer to Section 9
47. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk
constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that
a manager must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting
manager ID to match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that
indicates each employee ID must be unique.
Incorrect. Refer to Section 9
Section 10 Lesson 1
(Answer all questions in this section)
48. 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
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. (*)
Correct
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.
Incorrect. Refer to Section 10
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. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Incorrect. Refer to Section 10
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 (*)
Incorrect. Refer to Section 10
53. 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
Incorrect. Refer to Section 10
54. Views must be used to select data from a table if one exist. As
soon as a view is created on a table, you can no longer select direct
from the table. True or False? Mark for Review
(1) Points
True
False (*)
Correct
55. 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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are
achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not
exist. (*)
The statements will NOT return all of the desired results because
the WITH CHECK OPTION clause is NOT included in the CREATE VIEW
statement.
To achieve all of the desired results this ORDER ON clause should
be added to the CREATE VIEW statement: 'ORDER ON salary, last_name,
first_name'.
Correct
Section 10 Lesson 2
(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. (*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in
subquery
Incorrect. Refer to Section 10
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.
Correct
58. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN
j.lowest_sal and j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department",
e.salary "Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN
j.lowest_sal and j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department",
e.salary "Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN
j.lowest_sal and j.highest_sal);
Correct
59. You create a view on the EMPLOYEES and DEPARTMENTS tables to
display salary information per department. What will happen if you issue
the following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points
A complex view is created that returns the sum of salaries per
department, sorted by department name. (*)
A simple view is created that returns the sum of salaries per
department, sorted by department name.
A complex view is created that returns the sum of salaries per
department, sorted by department id.
Nothing, as the statement constains an error and will fail.
Incorrect. Refer to Section 10
60. 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
Page 6 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 2
(Answer all questions in this section)
61. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
62. 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
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
64. 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
SELECT (*)
Correct
65. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new
balance values. (*)
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.
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW
view. (*)
You can only insert records into the SALES table using the
SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its
maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. A gap can occur in a sequence because a user generated a number
from the sequence and then rolled back the transaction. True or False?
Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 11
70. The ALTER SEQUENCE statement can be used to: Mark for Review
(1) Points
Change the START WITH value of a sequence
Change the maximum value to a lower number than was last used
Change the name of the sequence
Change how much a sequence increments by each time a number is
generated (*)
Correct
Page 7 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 2
(Answer all questions in this section)
71. Sequences can be used to: (choose three) Mark for Review
(1) Points
(Choose all correct answers)
Ensure primary key values will be unique and consecutive
Ensure primary key values will be unique even though gaps may exist
(*)
Generate a range of numbers and optionally cycle through them again
(*)
Set a fixed interval between successively generated numbers. (*)
Guarantee that no primary key values are unused
Incorrect. Refer to Section 11
72. 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.
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE
columns of the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE
columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Correct
74. 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.
Incorrect. Refer to Section 11
75. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or
concatenated index. (*)
Correct
76. 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.
An index can prevent users from viewing certain data in a table.
Correct
77. 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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
78. 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
79. 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
80. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Incorrect. Refer to Section 11
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. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true?
Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index. (*)
Incorrect. Refer to Section 11
82. The CUSTOMERS table exists in user Mary's schema. Which
statement should you use to create a synonym for all database users on the
CUSTOMERS table? Mark for Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
83. When creating an index on one or more columns of a table, which
of the following statements are true? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
You should create an index if the table is large and most queries
are expected to retrieve less than 2 to 4 percent of the rows. (*)
You should always create an index on tables that are frequently
updated.
You should create an index if one or more columns are frequently
used together in a join condition. (*)
You should create an index if the table is very small.
Incorrect. Refer to Section 11
84. 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.
Incorrect. Refer to Section 11
85. 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
an index (*)
a FOREIGN KEY constraint
Incorrect. Refer to Section 11
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;
Incorrect. Refer to Section 12
87. Which of the following are system privileges? (Choose two) Mark
for Review
(1) Points
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE PROCEDURE (*)
INDEX
Correct
88. 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
89. You want to grant privileges to user CHAN that will allow CHAN
to update the data in the EMPLOYEE table. Which type of privileges will
you grant to CHAN? Mark for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct
90. 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;
Correct
Page 9 of 10
Test: 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 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Correct
92. 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;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
(*)
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to grant privileges to a role?
Mark for Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
Incorrect. Refer to Section 12
94. 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
Incorrect. Refer to Section 12
95. Which keyword would you use to grant an object privilege to all
database users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Incorrect. Refer to Section 12
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.
Correct
97. Which statement would you use to remove an object privilege
granted to a user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
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
Section 14 Lesson 1
(Answer all questions in this section)
99. 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
Incorrect. Refer to Section 14
100. 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;
What result will JANE see?
Mark for Review
(1) Points
22
20 (*)
JANE will receive an error message because she is not allowed to
query the table while BOB is updating it.
Incorrect. Refer to Section 14
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 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));
Incorrect. Refer to Section 8
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));
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));
CREATE TABLE travel (destination_id number primary key,
departure_date date, return_date date, emp_id number(10) REFERENCES employees
(emp_id)); (*)
Correct
3. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary,
department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM
employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct
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.
Correct
5. 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
Correct
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
INTERVAL YEAR TO MONTH
TIMESTAMP (*)
INTERVAL DAY TO SECOND
Correct
7. 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 (*)
Correct
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 1. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
4 (*)
Incorrect. Refer to Section 8
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));
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));
CREATE TABLE travel (destination_id number primary key,
departure_date date, return_date date, emp_id number(10) REFERENCES employees
(emp_id)); (*)
Incorrect. Refer to Section 8
3. 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));
Correct
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
Correct
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.
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
Section 8 Lesson 2
(Answer all questions in this section)
6. 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 (*)
Correct
7. 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
8. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in
the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character
data.
The CHAR data type requires that a minimum size be specified when
defining a column of this type. (*)
Correct
9. A column that will be used to store binary data up to 4 Gigabyes
in size should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
10. 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
Correct
11. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters,
or a combination of both.
All employee identification values are only 6 digits so the column
should be variable in length.
Description values can range from 0 to 30 characters so the column
should be fixed in length.
Today's date should be used if no value is provided for the sale
date. (*)
Correct
12. 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
Correct
Section 8 Lesson 3
(Answer all questions in this section)
13. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Correct
14. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
ALTER TABLE teams REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Incorrect. Refer to Section 8 Lesson 3
15. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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 drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
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
Incorrect. Refer to Section 8 Lesson 3
17. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct
18. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory'
statement.
Correct
19. Examine the structure of the DONATIONS table.
DONATIONS:
PLEDGE_ID NUMBER
DONOR_ID NUMBER
PLEDGE_DT DATE
AMOUNT_PLEDGED NUMBER (7,2)
AMOUNT_PAID NUMBER (7,2)
PAYMENT_DT DATE
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
You CANNOT decrease the width of the AMOUNT_PLEDGED column.
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.
Incorrect. Refer to Section 8 Lesson 3
20. Which statement about a column is NOT true? Mark for Review
(1) Points
You can increase the width of a CHAR column.
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.
You can decrease the width of a VARCHAR2 column.
Incorrect. Refer to Section 8 Lesson 3
21. 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.
Incorrect. Refer to Section 8
22. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
23. 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. (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. 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
25. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
address VARCHAR2(25),
city VARCHAR2(25),
region VARCHAR2(25),
postal_code VARCHAR2(11),
CONSTRAINT customer_id_un UNIQUE(customer_id),
CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct
26. What is the highest number of NOT NULL constraints you can have
on a table? Mark for Review
(1) Points
10
You can have as many NOT NULL constraints as you have columns in
your table. (*)
Correct
27. 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
28. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Correct
29. Which constraint can only be created at the column level? Mark
for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk
REFERENCES donors(donor_id), pledge_date DATE, amount_pledged
NUMBER(7,2), amount_paid NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk
REFERENCES donors(donor_id), pledge_date DATE, amount_pledged
NUMBER(7,2), amount_paid NUMBER(7,2), payment_dt DATE);
(*)
Correct
31. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
Correct
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
Correct
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
ON DELETE SET NULL
Incorrect. Refer to Section 9
34. How many PRIMARY KEY constraints can be created for each table?
Mark for Review
(1) Points
none
one and only one (*)
one or two
unlimited
Correct
35. 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
Correct
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. (*)
Incorrect. Refer to Section 9
37. 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.
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
39. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS
table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Correct
40. 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 (*)
ENABLE
Correct
41. 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
42. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk
constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that
a manager must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting
manager ID to match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that
indicates each employee ID must be unique.
Correct
43. 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;
Correct
44. 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
to activate a new constraint while preventing the creation of a
PRIMARY KEY index
to activate the previously disabled constraint on the EMP_ID column
while creating a PRIMARY KEY index (*)
Incorrect. Refer to Section 9
45. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the
PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Incorrect. Refer to Section 9
46. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Incorrect. Refer to Section 9
47. 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
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
WITH READ ONLY
Correct
49. 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
50. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Correct
51. 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
52. The FACULTY table contains these columns:
FACULTYID VARCHAR2(5) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(20)
LAST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
STATUS VARCHAR2(2) NOT NULL
The COURSE table contains these columns:
COURSEID VARCHAR2(5) NOT NULL PRIMARY KEY
SUBJECT VARCHAR2(5)
TERM VARCHAR2(6
FACULTYID VARCHAR2(5) NOT NULL FOREIGN KEY
You have been asked to compile a report that identifies all adjunct
professors who will be teaching classes in the upcoming term. You want to
create a view that will simplify the creation of this report. Which
CREATE VIEW statements will accomplish this task?
Mark for Review
(1) Points
CREATE VIEW
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty, course
WHERE facultyid = facultyid);
CREATE VIEW pt_view ON
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f and course c
WHERE f.facultyid = c.facultyid);
CREATE VIEW pt_view IN
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty course);
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
(*)
Incorrect. Refer to Section 10
53. 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
54. Which statement about the CREATE VIEW statement is false? Mark
for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Incorrect. Refer to Section 10
55. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Incorrect. Refer to Section 10
Section 10 Lesson 2
(Answer all questions in this section)
56. 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
Correct
57. You create a view on the EMPLOYEES and DEPARTMENTS tables to
display salary information per department. What will happen if you issue
the following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points
A complex view is created that returns the sum of salaries per
department, sorted by department name. (*)
A simple view is created that returns the sum of salaries per
department, sorted by department name.
A complex view is created that returns the sum of salaries per
department, sorted by department id.
Nothing, as the statement constains an error and will fail.
Correct
58. 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.
Correct
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 (*)
Correct
60. 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. (*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in
subquery
Correct
61. 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. (*)
Incorrect. Refer to Section 10
62. 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
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 execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new
balance values. (*)
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.
Incorrect. Refer to Section 10
64. 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
65. 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; (*)
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW
view. (*)
You can only insert records into the SALES table using the
SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its
maximum value.
The sequence will start with 1. (*)
Correct
69. Which pseudocolumn returns the latest value supplied by a
sequence? Mark for Review
(1) Points
NEXTVAL
CURRVAL (*)
CURRENT
NEXT
Incorrect. Refer to Section 11
70. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Incorrect. Refer to Section 11
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 ; (*)
Incorrect. Refer to Section 11
72. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq CYCLE;
Which statement is true?
Mark for Review
(1) Points
The sequence cannot be used with more than one table.
The sequence preallocates values and retains them in memory.
The sequence cannot generate additional values after reaching its
maximum value.
The sequence will continue to generate values after the maximum
sequence value has been generated. (*)
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. 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
an index (*)
a FOREIGN KEY constraint
Correct
74. 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
75. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
76. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or
concatenated index. (*)
Correct
77. The CUSTOMERS table exists in user Mary's schema. Which
statement should you use to create a synonym for all database users on the
CUSTOMERS table? Mark for Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
78. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically
dropped at the same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
79. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
80. Unique indexes are automatically created on columns that have
which two types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
81. 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
82. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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. (*)
Incorrect. Refer to Section 11
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
(1) Points
CREATE INDEX fl_idx ON employees(first_name || last_name);
CREATE INDEX fl_idx ON employees(first_name), employees(last_name);
CREATE INDEX fl_idx ON employees(first_name,last_name);
(*)
CREATE INDEX fl_idx ON employees(first_name);
CREATE INDEX fl_idx ON employees(last_name);
Correct
84. 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
85. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true?
Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index. (*)
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
87. 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
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
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
Incorrect. Refer to Section 12
89. 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
90. 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;
Correct
91. 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
Incorrect. Refer to Section 12
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.
GRANT SELECT ON employees_view TO public;
GRANT SELECT ON employees_view TO audrey; (*)
GRANT SELECT ON employees AND employees_view TO audrey;
Correct
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to grant privileges to a role?
Mark for Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
Correct
94. Which of the following simplifies the administration of
privileges? Mark for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
95. Granting an object privilege WITH GRANT OPTION allows the
recipient to grant other object privileges on the table to other users. True
or False? Mark for Review
(1) Points
True
False (*)
Correct
96. Which statement would you use to grant a role to users? Mark
for Review
(1) Points
GRANT (*)
ALTER USER
CREATE USER
ASSIGN
Incorrect. Refer to Section 12
97. Which keyword would you use to grant an object privilege to all
database users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Correct
98. 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
Incorrect. Refer to Section 12
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
Incorrect. Refer to Section 14
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 (*)
None of the above
Correct
INTERVAL YEAR TO MONTH
Correct
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
Correct
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 column? Mark for Review
(1) Points
CHAR
DATE
NUMBER (*)
VARCHAR2
Correct
Page 1 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 2
(Answer all questions in this section)
11. A column that will be used to store binary data up to 4 Gigabyes
in size should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
12. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in
the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character
data.
The CHAR data type requires that a minimum size be specified when
defining a column of this type. (*)
Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
14. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to
NUMBER(8,2) (*)
Correct
15. 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
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory'
statement.
Incorrect. Refer to Section 8 Lesson 3
17. 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. (*)
Correct
18. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct
19. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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 drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
20. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01
PRIMARY KEY,customerid varchar2(5) REFERENCES customers (customerid),
orderdate date, amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01
PRIMARY KEY, customerid varchar2(5) REFERENCES customers (customerid),
orderdate date, amount DEFAULT 250)
Correct
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. 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
22. To do a logical delete of a column without the performance
penalty of rewriting all the table datablocks you can issue the following
command: Mark for Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Correct
23. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
ALTER TABLE teams REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. What is the highest number of NOT NULL constraints you can have
on a table? Mark for Review
(1) Points
10
3
You can have as many NOT NULL constraints as you have columns in
your table. (*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. You need to add a NOT NULL constraint to the COST column in the
PART table. Which statement should you use to complete this task? Mark
for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL);
(*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Correct
28. A table can only have one unique key constraint defined. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
29. Which constraint can only be created at the column level? Mark
for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
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
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct
Page 3 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 2
(Answer all questions in this section)
31. 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 (*)
Correct
32. 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 automatically
increments by a value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column
of the same datatype in another table.
Data that is entered into a primary key column is restricted to a
range of numbers that is defined by the local Oracle database.
Correct
33. 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 differfent data type from the
primary key column that it references.
Correct
34. Which of the following best describes the function of a CHECK
constraint? Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be
entered in a column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be
entered in a column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY
constraint is created.
Incorrect. Refer to Section 9
35. 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
36. 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) (*)
CHECK CONSTRAINT part_cost_ck (cost > 1.00)
CONSTRAINT CHECK part_cost_ck (cost > 1.00)
Correct
37. 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. (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS
table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
39. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
40. 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
to activate a new constraint while preventing the creation of a
PRIMARY KEY index
to activate the previously disabled constraint on the EMP_ID column
while creating a PRIMARY KEY index (*)
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. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Incorrect. Refer to Section 9
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';
ALTER TABLE employees DISABLE fk_dept_id_01;
ALTER TABLE employees DISABLE CONSTRAINT fk_dept_id_01; (*)
Correct
43. You need to display the names and definitions of constraints
only in your schema. Which data dictionary view should you query? Mark
for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
44. 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
Correct
45. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk
constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that
a manager must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting
manager ID to match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that
indicates each employee ID must be unique.
Correct
46. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the
PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct
47. 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
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. (*)
Correct
49. 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
50. 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.
Incorrect. Refer to Section 10
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. 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
52. Evaluate this view definition:
CREATE OR REPLACE VIEW part_name_v
AS SELECT DISTINCT part_name
FROM parts
WHERE cost >= 45;
Which of the following statements using the PART_NAME_V view will
execute successfully?
Mark for Review
(1) Points
SELECT *
FROM part_name_v;
(*)
UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;
DELETE FROM part_name_v
WHERE part_id = 56897;
INSERT INTO part_name_v (part_id, part_name, product_id, cost)
VALUES (857986, 'cylinder', 8790, 3.45);
Correct
53. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Incorrect. Refer to Section 10
54. Which of the following keywords cannot be used when creating a
view? Mark for Review
(1) Points
HAVING
WHERE
ORDER BY (*)
They are all valid keywords when creating views.
Correct
55. Which statement about the CREATE VIEW statement is false? Mark
for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Correct
Section 10 Lesson 2
(Answer all questions in this section)
56. 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
Correct
57. You cannot create a view if the view subquery contains an inline
view. True or False? Mark for Review
(1) Points
True
False (*)
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. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
60. 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
Incorrect. Refer to Section 10
Page 6 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 2
(Answer all questions in this section)
61. 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
62. 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. (*)
Incorrect. Refer to Section 10
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;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee",
salary "Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee",
salary "Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Correct
64. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new
balance values. (*)
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.
Incorrect. Refer to Section 10
65. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW
view. (*)
You can only insert records into the SALES table using the
SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
66. The EMP_HIST_V view is no longer needed. Which statement should
you use to the remove this view? Mark for Review
(1) Points
DROP emp_hist_v;
DELETE emp_hist_v;
REMOVE emp_hist_v;
DROP VIEW emp_hist_v; (*)
Correct
67. 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
SELECT (*)
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its
maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Incorrect. Refer to Section 11
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct
Page 7 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 2
(Answer all questions in this section)
71. You need to retrieve the next available value for the SALES_IDX
sequence. Which would you include in your SQL statement? Mark for
Review
(1) Points
sales_idx
sales_idx.NEXT
sales_idx.NEXTVAL (*)
sales_idx.CURRVAL
Correct
72. 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 ; (*)
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. 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 (*)
Incorrect. Refer to Section 11
74. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or
concatenated index. (*)
Correct
75. Unique indexes are automatically created on columns that have
which two types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
76. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
77. The CUSTOMERS table exists in user Mary's schema. Which
statement should you use to create a synonym for all database users on the
CUSTOMERS table? Mark for Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
78. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically
dropped at the same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
79. 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
80. 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.
An index can prevent users from viewing certain data in a table.
Correct
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. You want to speed up the following query by creating an index:
SELECT * FROM employees WHERE (salary * 12) > 100000;
Which of the following will achieve this?
Mark for Review
(1) Points
Create a composite index on (salary,12).
Create a function-based index on (salary * 12). (*)
Create an index on (salary).
Create a function_based index on ((salary * 12) > 100000).
Correct
82. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
83. 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; (*)
Correct
84. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you own.
You created a public synonym on the EMPLOYEES table owned by user
Sam.
You created a private synonym on the EMPLOYEES table owned by user
Sam. (*)
Correct
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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
87. 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;
Correct
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
Incorrect. Refer to Section 12
89. 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
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.
A role is a name for a group of privileges. (*)
A role is an object privilege which allows a user to update a
table.
Correct
Page 9 of 10
Test: 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 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;
Correct
92. 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
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
Section 12 Lesson 3
(Answer all questions in this section)
93. 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
Correct
94. Which statement would you use to remove an object privilege
granted to a user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
Correct
95. Which of the following simplifies the administration of
privileges? Mark for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
96. Granting an object privilege WITH GRANT OPTION allows the
recipient to grant other object privileges on the table to other users. True
or False? Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 12
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;
Incorrect. Refer to Section 12
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.
Correct
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically
rolled back. True or False? Mark for Review
(1) Points
True (*)
False
Correct
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
Correct
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. 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
Correct
2. 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 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)
Incorrect. Refer to Section 8
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
4. 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);
Correct
5. Which statement about creating a table is true? Mark for
Review
(1) Points
With a CREATE TABLE statement, a table will always be
created in
the current user's schema.
If no schema is explicitly included in a CREATE TABLE
statement,
the table is created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE
statement,
the CREATE TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE
statement and
the schema does not exist, it will be created.
Correct
Section 8 Lesson 2
(Answer all questions in this section)
6. 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
7. 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 (*)
Correct
8. 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
Correct
9. 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
10. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish? Mark for
Review
(1) Points
Sales identification values could be either numbers
or characters,
or a combination of both.
All employee identification values are only 6 digits
so the column
should be variable in length.
Description values can range from 0 to 30 characters
so the column
should be fixed in length.
Today's date should be used if no value is provided
for the sale
date. (*)
Correct
Page 1 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 2
(Answer all questions in this section)
11. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four
gigabytes in
the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-
length character
data.
The CHAR data type requires that a minimum size be
specified when
defining a column of this type. (*)
Incorrect. Refer to Section 8
12. 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
Correct
Section 8 Lesson 3
(Answer all questions in this section)
13. Examine the structure of the DONATIONS table.
DONATIONS:
PLEDGE_ID NUMBER
DONOR_ID NUMBER
PLEDGE_DT DATE
AMOUNT_PLEDGED NUMBER (7,2)
AMOUNT_PAID NUMBER (7,2)
PAYMENT_DT DATE
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
You CANNOT decrease the width of the AMOUNT_PLEDGED
column.
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.
Incorrect. Refer to Section 8 Lesson 3
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
15. Evaluate this statement:
ALTER TABLE inventory
MODIFY backorder_amount NUMBER(8,2);
Which task will this statement accomplish? Mark for Review
(1) Points
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);
Incorrect. Refer to Section 8 Lesson 3
22. 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. (*)
Correct
23. 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 (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. 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
25. What is the highest number of NOT NULL constraints you can have
on a table? Mark for Review
(1) Points
10
You can have as many NOT NULL constraints as you have
columns in
your table. (*)
Correct
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the
column level.
NOT NULL constraints can only be specified at the
column level.
(*)
UNIQUE constraints are identical to PRIMARY KEY
constraints.
Correct
27. A table can only have one unique key constraint defined. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
28. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
 address VARCHAR2(25),
 city VARCHAR2(25),
 region VARCHAR2(25),
 postal_code VARCHAR2(11),
 CONSTRAINT customer_id_un UNIQUE(customer_id),
 CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed? Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column
level.
The CREATE TABLE statement does NOT define a PRIMARY
KEY.
NOT NULL constraints CANNOT be defined at the table
level. (*)
Correct
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.
Correct
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
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct
Page 3 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 2
(Answer all questions in this section)
31. 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
32. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk
REFERENCES donors(donor_id), pledge_date DATE, amount_pledged
NUMBER(7,2), amount_paid NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk
REFERENCES donors(donor_id), pledge_date DATE, amount_pledged
NUMBER(7,2), amount_paid NUMBER(7,2), payment_dt DATE);
(*)
Correct
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
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
35. Which of the following best describes the function of a CHECK
constraint? Mark for Review
(1) Points
A CHECK constraint enforces referential data
integrity.
A CHECK constraint defines restrictions on the values
that can be
entered in a column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values
that can be
entered in a column or combination of columns.
A CHECK constraint is created automatically when a
PRIMARY KEY
constraint is created.
Incorrect. Refer to Section 9
36. 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
37. 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.
Correct
Section 9 Lesson 3
(Answer all questions in this section)
38. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS
table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement? Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM
column
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
Correct
39. 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 Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES
employees (employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY BETWEEN salary (employee_id)
AND employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees
(employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) =
employees (employee_id);
Correct
40. 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 (*)
ENABLE
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. 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;
Correct
42. 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
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. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id); Mark for Review
(1) Points
Alter the table employees and disable the
emp_manager_fk
constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table
indicating
that a manager must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table
restricting
manager ID to match every employee ID.
Alter table employees and add a FOREIGN KEY
constraint that
indicates each employee ID must be unique.
Incorrect. Refer to Section 9
45. Examine the structures of the PRODUCT and SUPPLIER tables.
PRODUCT
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIER table
LIST_PRICE NUMBER (7,2)
COST NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
REORDER_QTY NUMBER
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;
For which task would you issue this statement? Mark for Review
(1) Points
To remove all constraint references to SUPPLIERS
table
To drop the FOREIGN KEY constraint on the PRODUCTS
table
To remove all constraint references to the PRODUCTS
table
To disable any dependent integrity constraints on the
SUPPLIER_ID
column in the PRODUCTS table
To disable any dependent integrity constraints on the
SUPPLIER_ID
column in the SUPPLIERS table (*)
Incorrect. Refer to Section 9
46. 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);
(*)
ALTER TABLE employee
MODIFY emp_id PRIMARY KEY;
ALTER TABLE employee
MODIFY CONSTRAINT PRIMARY KEY (emp_id);
Incorrect. Refer to Section 9
47. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the
PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT
product_id_fk;
Correct
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. (*)
Correct
49. 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
Incorrect. Refer to Section 10
50. 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
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. 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, 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;
Which statement is true? Mark for Review
(1) Points
When both statements are executed all of the desired
results are
achieved.
The CREATE VIEW statement will fail if the EMPLOYEE
table does not
exist. (*)
The statements will NOT return all of the desired
results because
the WITH CHECK OPTION clause is NOT included in the CREATE VIEW
statement.
To achieve all of the desired results this ORDER ON
clause should
be added to the CREATE VIEW statement: 'ORDER ON salary, last_name,
first_name'.
Correct
52. Views must be used to select data from a table if one exist. As
soon as a view is created on a table, you can no longer select direct
from the table. True or False? Mark for Review
(1) Points
True
False (*)
Correct
53. Evaluate this view definition:
CREATE OR REPLACE VIEW part_name_v
AS SELECT DISTINCT part_name
FROM parts
WHERE cost >= 45;
Which of the following statements using the PART_NAME_V view will
execute successfully? Mark for Review
(1) Points
SELECT *
FROM part_name_v;
(*)
UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;
DELETE FROM part_name_v
WHERE part_id = 56897;
INSERT INTO part_name_v (part_id, part_name,
product_id, cost)
VALUES (857986, 'cylinder', 8790, 3.45);
Correct
54. 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
55. Which statement about the CREATE VIEW statement is false? Mark
for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query.
(*)
A CREATE VIEW statement can contain an ORDER BY
clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY
clause.
Correct
Section 10 Lesson 2
(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. (*)
Prohibits DML actions without administrator CHECK
approval
Allows for DELETES from other tables, including ones
not listed in
subquery
Incorrect. Refer to Section 10
57. 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.
Incorrect. Refer to Section 10
58. 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
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
Incorrect. Refer to Section 10
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
Correct
Page 6 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 2
(Answer all questions in this section)
61. 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.
Correct
62. 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. (*)
Incorrect. Refer to Section 10
Section 10 Lesson 3
(Answer all questions in this section)
63. 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; (*)
Incorrect. Refer to Section 10
64. 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
SELECT (*)
Correct
65. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true? Mark for Review
(1) Points
You can modify data in the SALES table using the
SALES_VIEW view.
You cannot modify data in the SALES table using the
SALES_VIEW
view. (*)
You can only insert records into the SALES table
using the
SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
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 (*)
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct
69. Evaluate this statement:
DROP SEQUENCE line_item_id_seq;
What does this statement accomplish? Mark for Review
(1) Points
It sets the next value of the sequence to 1.
It sets the next value of the sequence to 0.
It sets the current value of the sequence to 0.
It removes the sequence from the data dictionary. (*)
Incorrect. Refer to Section 11
70. 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. (*)
Incorrect. Refer to Section 11
Page 7 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 2
(Answer all questions in this section)
71. When creating a sequence, which keyword or option specifies the
minimum sequence value? Mark for Review
(1) Points
MAXVALUE
MINVALUE (*)
NOMAXVALUE
CYCLE
Incorrect. Refer to Section 11
72. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq CYCLE;
Which statement is true? Mark for Review
(1) Points
The sequence cannot be used with more than one table.
The sequence preallocates values and retains them in
memory.
The sequence cannot generate additional values after
reaching its
maximum value.
The sequence will continue to generate values after
the maximum
sequence value has been generated. (*)
Incorrect. Refer to Section 11
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
On which column is an index automatically created for the EMPLOYEES
table? Mark for Review
(1) Points
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct
74. 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
75. 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. (*)
An index must be created by a database administrator
when a
PRIMARY KEY constraint is created.
An index is never created for a unique constraint.
An index cannot be created before a PRIMARY KEY
constraint is
created.
Correct
76. 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
77. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically
dropped at the same time? Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
78. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement? Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you
own.
You created a public synonym on the EMPLOYEES table owned by user
Sam.
You created a private synonym on the EMPLOYEES table owned by
user
Sam. (*)
Incorrect. Refer to Section 11
79. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE
columns of the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish? Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY
and STATE
columns.
An index named CLIENTS is created on the CITY and
STATE columns.
An index named CLIENTS_INDEX is created on the
CLIENTS table.
An error message is produced, and no index is
created. (*)
Correct
80. 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;
Incorrect. Refer to Section 11
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. 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
82. 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.
An index can prevent users from viewing certain data
in a table.
Correct
83. 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; (*)
Correct
84. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true? Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index.
(*)
Incorrect. Refer to Section 11
85. 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
an index (*)
a FOREIGN KEY constraint
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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;
Correct
87. 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
88. 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;
Correct
89. 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;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
(*)
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
Incorrect. Refer to Section 12
90. 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
Page 9 of 10
Test: 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 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Incorrect. Refer to Section 12
92. 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 (*)
Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. 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
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
Correct
95. Which keyword would you use to grant an object privilege to all
database users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Correct
96. Which statement would you use to remove an object privilege
granted to a user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
Incorrect. Refer to Section 12
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;
Incorrect. Refer to Section 12
98. Which statement would you use to grant a role to users? Mark
for Review
(1) Points
GRANT (*)
ALTER USER
CREATE USER
ASSIGN
Correct
Section 14 Lesson 1
(Answer all questions in this section)
99. Examine the following statements:
UPDATE employees SET salary = 15000;
SAVEPOINT upd1_done;
UPDATE employees SET salary = 22000;
SAVEPOINT upd2_done;
DELETE FROM employees;
You want to retain all the employees with a salary of 15000; What
statement would you execute next? Mark for Review
(1) Points
ROLLBACK;
ROLLBACK TO SAVEPOINT upd1_done; (*)
ROLLBACK TO SAVEPOINT upd2_done;
ROLLBACK TO SAVE upd1_done;
There is nothing you can do, either all changes must
be rolled
back, or none of them can be rolled back.
Correct
100. 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
Incorrect. Refer to Section 14
Page 10 of 10
Plain Text Attachment [ Scan and Save to Computer ]
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 statement about creating a table is true? Mark for Review
(1) Points
With a CREATE TABLE statement, a table will always be created in
the current user's schema.
If no schema is explicitly included in a CREATE TABLE statement,
the table is created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE statement,
the CREATE TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE statement and
the schema does not exist, it will be created.
Correct
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);
Correct
3. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Correct
4. 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));
Incorrect. Refer to Section 8
5. 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
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
Incorrect. Refer to Section 8
7. 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
8. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters,
or a combination of both.
All employee identification values are only 6 digits so the column
should be variable in length.
Description values can range from 0 to 30 characters so the column
should be fixed in length.
Today's date should be used if no value is provided for the sale
date. (*)
Incorrect. Refer to Section 8
9. 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
Incorrect. Refer to Section 8
10. 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. (*)
Incorrect. Refer to Section 8
Page 1 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 2
(Answer all questions in this section)
11. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in
the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character
data.
The CHAR data type requires that a minimum size be specified when
defining a column of this type. (*)
Incorrect. Refer to Section 8
12. 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
Section 8 Lesson 3
(Answer all questions in this section)
13. You need to change the name of the EMPLOYEE table to the EMP
table. Which statement should you use? Mark for Review
(1) Points
RENAME employee emp;
RENAME employee TO emp; (*)
ALTER TABLE employee TO emp;
ALTER TABLE employee RENAME TO emp;
Correct
14. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01
PRIMARY KEY,customerid varchar2(5) REFERENCES customers (customerid),
orderdate date, amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01
PRIMARY KEY, customerid varchar2(5) REFERENCES customers (customerid),
orderdate date, amount DEFAULT 250)
Incorrect. Refer to Section 8 Lesson 3
15. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory'
statement.
Incorrect. Refer to Section 8 Lesson 3
17. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification
numbers. Business requirements have changed and you need to allow users
to include text characters in the identification values. Which
statement should you use to change this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the
table is not empty. (*)
Incorrect. Refer to Section 8 Lesson 3
18. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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 drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Incorrect. Refer to Section 8 Lesson 3
19. 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct
20. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to
NUMBER(8,2) (*)
Correct
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. 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. (*)
Correct
22. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
23. 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 (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. A table can only have one unique key constraint defined. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. 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 (*)
Incorrect. Refer to Section 9
28. You need to add a NOT NULL constraint to the COST column in the
PART table. Which statement should you use to complete this task? Mark
for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL);
(*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Incorrect. Refer to Section 9
29. Which constraint can only be created at the column level? Mark
for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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.
Incorrect. Refer to Section 9
Page 3 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 2
(Answer all questions in this section)
31. 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
32. Which of the following best describes the function of a CHECK
constraint? Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be
entered in a column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be
entered in a column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY
constraint is created.
Incorrect. Refer to Section 9
33. 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
34. How many PRIMARY KEY constraints can be created for each table?
Mark for Review
(1) Points
none
one and only one (*)
one or two
unlimited
Incorrect. Refer to Section 9
35. 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
Correct
36. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
Correct
37. 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 (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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);
Incorrect. Refer to Section 9
39. You need to display the names and definitions of constraints
only in your schema. Which data dictionary view should you query? Mark
for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
40. 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
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. 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);
(*)
ALTER TABLE employee
MODIFY emp_id PRIMARY KEY;
ALTER TABLE employee
MODIFY CONSTRAINT PRIMARY KEY (emp_id);
Correct
42. What actions can be performed on or with Constraints? Mark for
Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct
43. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS
table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
44. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Incorrect. Refer to Section 9
45. Which of the following would always cause an integrity
constraint error? Mark for Review
(1) Points
Using a subquery in an INSERT statement.
Using the MERGE statement to conditionally insert or update rows.
Using the DELETE command on a row that contains a primary key with
a dependent foreign key. (*)
Using the UPDATE command on rows based in another table.
Incorrect. Refer to Section 9
46. 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 Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES
employees (employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY BETWEEN salary (employee_id)
AND employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees
(employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) =
employees (employee_id);
Incorrect. Refer to Section 9
47. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk
constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that
a manager must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting
manager ID to match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that
indicates each employee ID must be unique.
Incorrect. Refer to Section 9
Section 10 Lesson 1
(Answer all questions in this section)
48. 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
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. (*)
Correct
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.
Incorrect. Refer to Section 10
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. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Incorrect. Refer to Section 10
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 (*)
Incorrect. Refer to Section 10
53. 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
Incorrect. Refer to Section 10
54. Views must be used to select data from a table if one exist. As
soon as a view is created on a table, you can no longer select direct
from the table. True or False? Mark for Review
(1) Points
True
False (*)
Correct
55. 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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are
achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not
exist. (*)
The statements will NOT return all of the desired results because
the WITH CHECK OPTION clause is NOT included in the CREATE VIEW
statement.
To achieve all of the desired results this ORDER ON clause should
be added to the CREATE VIEW statement: 'ORDER ON salary, last_name,
first_name'.
Correct
Section 10 Lesson 2
(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. (*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in
subquery
Incorrect. Refer to Section 10
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.
Correct
58. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN
j.lowest_sal and j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department",
e.salary "Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN
j.lowest_sal and j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department",
e.salary "Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN
j.lowest_sal and j.highest_sal);
Correct
59. You create a view on the EMPLOYEES and DEPARTMENTS tables to
display salary information per department. What will happen if you issue
the following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points
A complex view is created that returns the sum of salaries per
department, sorted by department name. (*)
A simple view is created that returns the sum of salaries per
department, sorted by department name.
A complex view is created that returns the sum of salaries per
department, sorted by department id.
Nothing, as the statement constains an error and will fail.
Incorrect. Refer to Section 10
60. 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
Page 6 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 2
(Answer all questions in this section)
61. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
62. 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
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
64. 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
SELECT (*)
Correct
65. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new
balance values. (*)
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.
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW
view. (*)
You can only insert records into the SALES table using the
SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its
maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. A gap can occur in a sequence because a user generated a number
from the sequence and then rolled back the transaction. True or False?
Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 11
70. The ALTER SEQUENCE statement can be used to: Mark for Review
(1) Points
Change the START WITH value of a sequence
Change the maximum value to a lower number than was last used
Change the name of the sequence
Change how much a sequence increments by each time a number is
generated (*)
Correct
Page 7 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 2
(Answer all questions in this section)
71. Sequences can be used to: (choose three) Mark for Review
(1) Points
(Choose all correct answers)
Ensure primary key values will be unique and consecutive
Ensure primary key values will be unique even though gaps may exist
(*)
Generate a range of numbers and optionally cycle through them again
(*)
Set a fixed interval between successively generated numbers. (*)
Guarantee that no primary key values are unused
Incorrect. Refer to Section 11
72. 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.
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE
columns of the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE
columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Correct
74. 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.
Incorrect. Refer to Section 11
75. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or
concatenated index. (*)
Correct
76. 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.
An index can prevent users from viewing certain data in a table.
Correct
77. 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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
78. 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
79. 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
80. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Incorrect. Refer to Section 11
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. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true?
Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index. (*)
Incorrect. Refer to Section 11
82. The CUSTOMERS table exists in user Mary's schema. Which
statement should you use to create a synonym for all database users on the
CUSTOMERS table? Mark for Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
83. When creating an index on one or more columns of a table, which
of the following statements are true? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
You should create an index if the table is large and most queries
are expected to retrieve less than 2 to 4 percent of the rows. (*)
You should always create an index on tables that are frequently
updated.
You should create an index if one or more columns are frequently
used together in a join condition. (*)
You should create an index if the table is very small.
Incorrect. Refer to Section 11
84. 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.
Incorrect. Refer to Section 11
85. 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
an index (*)
a FOREIGN KEY constraint
Incorrect. Refer to Section 11
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;
Incorrect. Refer to Section 12
87. Which of the following are system privileges? (Choose two) Mark
for Review
(1) Points
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE PROCEDURE (*)
INDEX
Correct
88. 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
89. You want to grant privileges to user CHAN that will allow CHAN
to update the data in the EMPLOYEE table. Which type of privileges will
you grant to CHAN? Mark for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct
90. 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;
Correct
Page 9 of 10
Test: 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 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Correct
92. 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;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
(*)
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to grant privileges to a role?
Mark for Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
Incorrect. Refer to Section 12
94. 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
Incorrect. Refer to Section 12
95. Which keyword would you use to grant an object privilege to all
database users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Incorrect. Refer to Section 12
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.
Correct
97. Which statement would you use to remove an object privilege
granted to a user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
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
Section 14 Lesson 1
(Answer all questions in this section)
99. 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
Incorrect. Refer to Section 14
100. 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;
What result will JANE see?
Mark for Review
(1) Points
22
20 (*)
JANE will receive an error message because she is not allowed to
query the table while BOB is updating it.
Incorrect. Refer to Section 14
Page 10 of 10
Plain Text Attachment [ Scan and Save to Computer ]
1. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
4 (*)
Incorrect. Refer to Section 8
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));
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));
CREATE TABLE travel (destination_id number primary key,
departure_date date, return_date date, emp_id number(10) REFERENCES employees
(emp_id)); (*)
Incorrect. Refer to Section 8
3. 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));
Correct
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
Correct
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.
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
Section 8 Lesson 2
(Answer all questions in this section)
6. 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 (*)
Correct
7. 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
8. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in
the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character
data.
The CHAR data type requires that a minimum size be specified when
defining a column of this type. (*)
Correct
9. A column that will be used to store binary data up to 4 Gigabyes
in size should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
10. 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
Correct
11. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters,
or a combination of both.
All employee identification values are only 6 digits so the column
should be variable in length.
Description values can range from 0 to 30 characters so the column
should be fixed in length.
Today's date should be used if no value is provided for the sale
date. (*)
Correct
12. 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
Correct
Section 8 Lesson 3
(Answer all questions in this section)
13. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Correct
14. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
ALTER TABLE teams REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Incorrect. Refer to Section 8 Lesson 3
15. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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 drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
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
Incorrect. Refer to Section 8 Lesson 3
17. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct
18. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory'
statement.
Correct
19. Examine the structure of the DONATIONS table.
DONATIONS:
PLEDGE_ID NUMBER
DONOR_ID NUMBER
PLEDGE_DT DATE
AMOUNT_PLEDGED NUMBER (7,2)
AMOUNT_PAID NUMBER (7,2)
PAYMENT_DT DATE
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
You CANNOT decrease the width of the AMOUNT_PLEDGED column.
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.
Incorrect. Refer to Section 8 Lesson 3
20. Which statement about a column is NOT true? Mark for Review
(1) Points
You can increase the width of a CHAR column.
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.
You can decrease the width of a VARCHAR2 column.
Incorrect. Refer to Section 8 Lesson 3
21. 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.
Incorrect. Refer to Section 8
22. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
23. 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. (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. 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
25. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
address VARCHAR2(25),
city VARCHAR2(25),
region VARCHAR2(25),
postal_code VARCHAR2(11),
CONSTRAINT customer_id_un UNIQUE(customer_id),
CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct
26. What is the highest number of NOT NULL constraints you can have
on a table? Mark for Review
(1) Points
10
You can have as many NOT NULL constraints as you have columns in
your table. (*)
Correct
27. 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
28. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Correct
29. Which constraint can only be created at the column level? Mark
for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk
REFERENCES donors(donor_id), pledge_date DATE, amount_pledged
NUMBER(7,2), amount_paid NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk
REFERENCES donors(donor_id), pledge_date DATE, amount_pledged
NUMBER(7,2), amount_paid NUMBER(7,2), payment_dt DATE);
(*)
Correct
31. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
Correct
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
Correct
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
ON DELETE SET NULL
Incorrect. Refer to Section 9
34. How many PRIMARY KEY constraints can be created for each table?
Mark for Review
(1) Points
none
one and only one (*)
one or two
unlimited
Correct
35. 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
Correct
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. (*)
Incorrect. Refer to Section 9
37. 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.
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
39. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS
table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Correct
40. 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 (*)
ENABLE
Correct
41. 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
42. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk
constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that
a manager must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting
manager ID to match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that
indicates each employee ID must be unique.
Correct
43. 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;
Correct
44. 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
to activate a new constraint while preventing the creation of a
PRIMARY KEY index
to activate the previously disabled constraint on the EMP_ID column
while creating a PRIMARY KEY index (*)
Incorrect. Refer to Section 9
45. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the
PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Incorrect. Refer to Section 9
46. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Incorrect. Refer to Section 9
47. 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
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
WITH READ ONLY
Correct
49. 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
50. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Correct
51. 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
52. The FACULTY table contains these columns:
FACULTYID VARCHAR2(5) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(20)
LAST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
STATUS VARCHAR2(2) NOT NULL
The COURSE table contains these columns:
COURSEID VARCHAR2(5) NOT NULL PRIMARY KEY
SUBJECT VARCHAR2(5)
TERM VARCHAR2(6
FACULTYID VARCHAR2(5) NOT NULL FOREIGN KEY
You have been asked to compile a report that identifies all adjunct
professors who will be teaching classes in the upcoming term. You want to
create a view that will simplify the creation of this report. Which
CREATE VIEW statements will accomplish this task?
Mark for Review
(1) Points
CREATE VIEW
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty, course
WHERE facultyid = facultyid);
CREATE VIEW pt_view ON
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f and course c
WHERE f.facultyid = c.facultyid);
CREATE VIEW pt_view IN
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty course);
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
(*)
Incorrect. Refer to Section 10
53. 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
54. Which statement about the CREATE VIEW statement is false? Mark
for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Incorrect. Refer to Section 10
55. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Incorrect. Refer to Section 10
Section 10 Lesson 2
(Answer all questions in this section)
56. 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
Correct
57. You create a view on the EMPLOYEES and DEPARTMENTS tables to
display salary information per department. What will happen if you issue
the following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points
A complex view is created that returns the sum of salaries per
department, sorted by department name. (*)
A simple view is created that returns the sum of salaries per
department, sorted by department name.
A complex view is created that returns the sum of salaries per
department, sorted by department id.
Nothing, as the statement constains an error and will fail.
Correct
58. 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.
Correct
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 (*)
Correct
60. 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. (*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in
subquery
Correct
61. 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. (*)
Incorrect. Refer to Section 10
62. 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
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 execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new
balance values. (*)
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.
Incorrect. Refer to Section 10
64. 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
65. 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; (*)
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW
view. (*)
You can only insert records into the SALES table using the
SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its
maximum value.
The sequence will start with 1. (*)
Correct
69. Which pseudocolumn returns the latest value supplied by a
sequence? Mark for Review
(1) Points
NEXTVAL
CURRVAL (*)
CURRENT
NEXT
Incorrect. Refer to Section 11
70. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Incorrect. Refer to Section 11
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 ; (*)
Incorrect. Refer to Section 11
72. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq CYCLE;
Which statement is true?
Mark for Review
(1) Points
The sequence cannot be used with more than one table.
The sequence preallocates values and retains them in memory.
The sequence cannot generate additional values after reaching its
maximum value.
The sequence will continue to generate values after the maximum
sequence value has been generated. (*)
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. 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
an index (*)
a FOREIGN KEY constraint
Correct
74. 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
75. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
76. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or
concatenated index. (*)
Correct
77. The CUSTOMERS table exists in user Mary's schema. Which
statement should you use to create a synonym for all database users on the
CUSTOMERS table? Mark for Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
78. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically
dropped at the same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
79. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
80. Unique indexes are automatically created on columns that have
which two types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
81. 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
82. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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. (*)
Incorrect. Refer to Section 11
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
(1) Points
CREATE INDEX fl_idx ON employees(first_name || last_name);
CREATE INDEX fl_idx ON employees(first_name), employees(last_name);
CREATE INDEX fl_idx ON employees(first_name,last_name);
(*)
CREATE INDEX fl_idx ON employees(first_name);
CREATE INDEX fl_idx ON employees(last_name);
Correct
84. 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
85. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true?
Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index. (*)
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
87. 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
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
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
Incorrect. Refer to Section 12
89. 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
90. 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;
Correct
91. 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
Incorrect. Refer to Section 12
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.
GRANT SELECT ON employees_view TO public;
GRANT SELECT ON employees_view TO audrey; (*)
GRANT SELECT ON employees AND employees_view TO audrey;
Correct
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to grant privileges to a role?
Mark for Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
Correct
94. Which of the following simplifies the administration of
privileges? Mark for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
95. Granting an object privilege WITH GRANT OPTION allows the
recipient to grant other object privileges on the table to other users. True
or False? Mark for Review
(1) Points
True
False (*)
Correct
96. Which statement would you use to grant a role to users? Mark
for Review
(1) Points
GRANT (*)
ALTER USER
CREATE USER
ASSIGN
Incorrect. Refer to Section 12
97. Which keyword would you use to grant an object privilege to all
database users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Correct
98. 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
Incorrect. Refer to Section 12
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
Incorrect. Refer to Section 14
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 (*)
None of the above
Correct
Plain Text Attachment [ Scan and Save to Computer ]
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. 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
Correct
2. 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 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)
Incorrect. Refer to Section 8
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
4. 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);
Correct
5. Which statement about creating a table is true? Mark for
Review
(1) Points
With a CREATE TABLE statement, a table will always be
created in
the current user's schema.
If no schema is explicitly included in a CREATE TABLE
statement,
the table is created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE
statement,
the CREATE TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE
statement and
the schema does not exist, it will be created.
Correct
Section 8 Lesson 2
(Answer all questions in this section)
6. 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
7. 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 (*)
Correct
8. 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
Correct
9. 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
10. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish? Mark for
Review
(1) Points
Sales identification values could be either numbers
or characters,
or a combination of both.
All employee identification values are only 6 digits
so the column
should be variable in length.
Description values can range from 0 to 30 characters
so the column
should be fixed in length.
Today's date should be used if no value is provided
for the sale
date. (*)
Correct
Page 1 of 10
DeleteReplyForwardSpamMove...
Previous | Next | Back to Messages Save Message Text | Full Headers
Check MailCompose Search Mail: Search MailSearch the Web
Move Options Forward Options
As Inline Text
As Attachment
Reply Options
Reply To Sender
Reply To Everyone
Address Book Shortcuts
Add Contact
Add Category
View Contacts
View Lists
QuickBuilder
Import Contacts
Synchronize
Addresses Options
Addresses Help
Calendar Shortcuts
Add Event
Add Task
Add Birthday
Day
Week
Month
Year
Event List
Reminders
Tasks
Sharing
Synchronize
Calendar Options
Calendar Help
Notepad Shortcuts
Add Note
Add Folder
View Notes
Notepad Options
Notepad Help
Advanced Search
Advanced Search
Copyright 1994-2007 Yahoo! Inc. All rights reserved. Terms of Service -
Copyright/IP Policy - Guidelines - Ad Feedback
NOTICE: We collect personal information on this site.
To learn more about how we use your information, see our Privacy Policy
Skip navigation elements to page contents
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
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);
Correct Correct
2. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct Correct
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct Correct
4. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Incorrect Incorrect. Refer to Section 8
5. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
4 (*)
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 2
(Answer all questions in this section)
6. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct Correct
7. The TIMESTAMP data type allows what? Mark for Review
(1) Points
Time to be stored as an interval of years and months.
Time to be stored as a date with fractional seconds. (*)
Time to be stored as an interval of days to hours, minutes and seconds.
None of the above.
Incorrect Incorrect. Refer to Section 8
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
Correct Correct
9. 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 Correct
10. 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 Correct
Page 1 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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
12. 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
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect Incorrect. Refer to Section 8 Lesson 3
14. 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. (*)
Correct Correct
15. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct Correct
16. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct Correct
17. 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
Correct Correct
18. To do a logical delete of a column without the performance
penalty of rewriting all the table datablocks you can issue the following command:
Mark for Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Incorrect Incorrect. Refer to Section 8 Lesson 3
19. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct Correct
20. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is
not empty. (*)
Incorrect Incorrect. Refer to Section 8 Lesson 3
Previous Page 2 of 10 Next Summary
Skip navigation elements to page contents
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. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Incorrect Incorrect. Refer to Section 8 Lesson 3
22. 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 (*)
Correct 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
 address VARCHAR2(25),
 city VARCHAR2(25),
 region VARCHAR2(25),
 postal_code VARCHAR2(11),
 CONSTRAINT customer_id_un UNIQUE(customer_id),
 CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct Correct
25. 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 Correct
26. 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
Correct Correct
27. Which constraint can only be created at the column level? Mark
for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct Correct
28. A table can only have one unique key constraint defined. True or
False? Mark for Review
(1) Points
True
False (*)
Correct Correct
29. 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 Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the
same datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Incorrect Incorrect. Refer to Section 9
Previous Page 3 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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 of the following types of constraints enforces uniqueness?
Mark for Review
(1) Points
CHECK
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct Correct
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.
Incorrect Incorrect. Refer to Section 9
33. 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 Correct
34. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE);
(*)
Incorrect Incorrect. Refer to Section 9
35. 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
Correct Correct
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 (*)
Correct Correct
37. 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. (*)
Incorrect Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
Correct Correct
39. 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
Incorrect Incorrect. Refer to Section 9
40. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct Correct
Previous Page 4 of 10 Next Summary
Skip navigation elements to page contents
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. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct Correct
42. You need to display the names and definitions of constraints only
in your schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct 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. (*)
Incorrect Incorrect. Refer to Section 9
44. 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;
Correct Correct
45. 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 (*)
ENABLE
Incorrect Incorrect. Refer to Section 9
46. What actions can be performed on or with Constraints? Mark
for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct Correct
47. 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);
ALTER TABLE employee
ADD CONSTRAINT dept_id_fk FOREIGN KEY (dept_id) REFERENCES department(id);
(*)
ALTER TABLE employee
ADD FOREIGN KEY CONSTRAINT dept_id_fk ON (dept_id) REFERENCES department(id);
ALTER TABLE employee
ADD FOREIGN KEY department(id) REFERENCES (dept_id);
Correct Correct
Section 10 Lesson 1
(Answer all questions in this section)
48. 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 Correct
49. 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 Correct
50. 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. (*)
Incorrect Incorrect. Refer to Section 10
Previous Page 5 of 10 Next Summary
Skip navigation elements to page contents
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 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct Correct
54. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple (*)
inline
complex
Incorrect Incorrect. Refer to Section 10
55. Which statement about the CREATE VIEW statement is false? Mark
for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Incorrect Incorrect. Refer to Section 10
Section 10 Lesson 2
(Answer all questions in this section)
56. 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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 Correct
59. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct 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
Correct Correct
Previous Page 6 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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.
Correct Correct
62. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct Correct
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
SELECT (*)
Correct 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 Correct
65. Evaluate this SELECT statement:
SELECT ROWNUM "Rank", customer_id, new_balance
FROM
(SELECT customer_id, new_balance
FROM customer_finance
ORDER BY new_balance DESC)
WHERE ROWNUM <= 25;
Which type of query is this SELECT statement?
Mark for Review
(1) Points
A Top-n query (*)
A complex view
A simple view
A hierarchical view
Correct Correct
66. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect Incorrect. Refer to Section 10
67. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
JOB_ID NUMBER
MANAGER_ID NUMBER
SALARY NUMBER(9,2)
COMMISSOIN NUMBER(7,2)
HIRE_DATE DATE
Which SELECT statement could be used to display the 10 lowest paid clerks that
belong to department 70?
Mark for Review
(1) Points
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary
FROM employees
ORDER BY salary)
WHERE ROWNUM <=10 AND job_id LIKE 'CLERK' AND department_id = 70;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Incorrect Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. You issue this statement:
ALTER SEQUENCE po_sequence INCREMENT BY 2;
Which statement is true?
Mark for Review
(1) Points
Sequence numbers will be cached.
Future sequence numbers generated will increase by 2 each time a number is
generated. (*)
If the PO_SEQUENCE sequence does not exist, it will be created.
The statement fails if the current value of the sequence is greater than the
START WITH value.
Correct Correct
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
Correct Correct
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct Correct
Previous Page 7 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq INCREMENT BY -1;
Which statement is true?
Mark for Review
(1) Points
The statement will not execute successfully.
The sequence will generate sequential descending values. (*)
The starting value of the LINE_ITEM_ID_SEQ sequence will by -1.
The minimum value of the LINE_ITEM_ID_SEQ will be the smallest possible
integer value.
Correct Correct
72. Evaluate this statement:
CREATE SEQUENCE sales_item_id_seq
START WITH 101 MAXVALUE 9000090 CYCLE;
Which statement about this CREATE SEQUENCE statement is true?
Mark for Review
(1) Points
The sequence will reuse numbers and will start with 101. (*)
The sequence will generate decrementing sequence numbers starting at 101.
The statement fails because no INCREMENT BY value is specified.
The sequence will generate sequence numbers starting with 101, but will not
reuse numbers.
Correct Correct
Section 11 Lesson 3
(Answer all questions in this section)
73. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Incorrect Incorrect. Refer to Section 11
74. The EMPLOYEES table has an index named LN_IDX on the LAST_NAME
column. You want to change this index so that it is on the FIRST_NAME column
instead. Which SQL statement will do this? Mark for Review
(1) Points
ALTER INDEX ln_idx ON employees(first_name);
ALTER INDEX ln_idx TO employees(first_name);
ALTER INDEX ln_idx TO fn_idx ON employees(first_name);
None of the above; you cannot ALTER an index. (*)
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 (*)
Incorrect Incorrect. Refer to Section 11
76. 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; (*)
Incorrect Incorrect. Refer to Section 11
77.
As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you
own.
You created a public synonym on the EMPLOYEES table owned by user
Sam.
You created a private synonym on the EMPLOYEES table owned by
user Sam. (*)
Incorrect Incorrect. Refer to Section 11
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.
(*)
An index must be created by a database administrator when a PRIMARY KEY
constraint is created.
An index is never created for a unique constraint.
An index cannot be created before a PRIMARY KEY constraint is created.
Correct 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct Correct
80. 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.
An index can prevent users from viewing certain data in a table.
Correct Correct
Previous Page 8 of 10 Next Summary
Skip navigation elements to page contents
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. 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 Correct
82. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct Correct
83. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DEPARTMENT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCT table
HIRE_DATE DATE DEFAULT SYSDATE
SALARY NUMBER (8,2) NOT NULL
On which column is an index automatically created for the EMPLOYEES table?
Mark for Review
(1) Points
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct Correct
84. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of
the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Incorrect Incorrect. Refer to Section 11
85. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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 Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. You want to grant privileges to user CHAN that will allow CHAN to
update the data in the EMPLOYEE table. Which type of privileges will you grant to
CHAN? Mark for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct Correct
87. 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
Incorrect Incorrect. Refer to Section 12
88. 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
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.
Incorrect Incorrect. Refer to Section 12
89. 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;
Incorrect Incorrect. Refer to Section 12
90. 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 Correct
Previous Page 9 of 10 Next Summary
Skip navigation elements to page contents
Test: 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 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;
Incorrect Incorrect. Refer to Section 12
92. 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Incorrect Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. 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 Correct
94. 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;
Incorrect Incorrect. Refer to Section 12
95. To join a table in your database to a table on a second (remote)
Oracle database, you need to use: Mark for Review
(1) Points
A remote procedure call
An Oracle gateway product
An ODBC driver
A database link (*)
Correct Correct
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.
Incorrect Incorrect. Refer to Section 12
97. Which of the following simplifies the administration of
privileges? Mark for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct 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;
Incorrect Incorrect. Refer to Section 12
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically
rolled back. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect Incorrect. Refer to Section 14
100. Examine the following statements:
UPDATE employees SET salary = 15000;
SAVEPOINT upd1_done;
UPDATE employees SET salary = 22000;
SAVEPOINT upd2_done;
DELETE FROM employees;
You want to retain all the employees with a salary of 15000; What statement would
you execute next?
Mark for Review
(1) Points
ROLLBACK;
ROLLBACK TO SAVEPOINT upd1_done; (*)
ROLLBACK TO SAVEPOINT upd2_done;
ROLLBACK TO SAVE upd1_done;
There is nothing you can do, either all changes must be rolled back, or none
of them can be rolled back.
Correct Correct
Previous Page 10 of 10 Summary
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 statement about creating a table is true? Mark for Review
(1) Points
With a CREATE TABLE statement, a table will always be created in the current
user's schema.
If no schema is explicitly included in a CREATE TABLE statement, the table is
created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE statement, the CREATE
TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE statement and the schema
does not exist, it will be created.
Correct
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);
Correct
3. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Correct
4. 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));
Incorrect. Refer to Section 8
5. 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
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
Incorrect. Refer to Section 8
7. 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
8. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Incorrect. Refer to Section 8
9. 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
Incorrect. Refer to Section 8
10. 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.
(*)
Incorrect. Refer to Section 8
Page 1 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 2
(Answer all questions in this section)
11. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Incorrect. Refer to Section 8
12. 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
Section 8 Lesson 3
(Answer all questions in this section)
13. You need to change the name of the EMPLOYEE table to the EMP table. Which
statement should you use? Mark for Review
(1) Points
RENAME employee emp;
RENAME employee TO emp; (*)
ALTER TABLE employee TO emp;
ALTER TABLE employee RENAME TO emp;
Correct
14. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Incorrect. Refer to Section 8 Lesson 3
15. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect. Refer to Section 8 Lesson 3
17. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is not
empty. (*)
Incorrect. Refer to Section 8 Lesson 3
18. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Incorrect. Refer to Section 8 Lesson 3
19. 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct
20. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
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. 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. (*)
Correct
22. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
23. 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 (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. A table can only have one unique key constraint defined. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. 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 (*)
Incorrect. Refer to Section 9
28. You need to add a NOT NULL constraint to the COST column in the PART table.
Which statement should you use to complete this task? Mark for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL); (*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Incorrect. Refer to Section 9
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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.
Incorrect. Refer to Section 9
Page 3 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 2
(Answer all questions in this section)
31. 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
32. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Incorrect. Refer to Section 9
33. 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
34. How many PRIMARY KEY constraints can be created for each table? Mark for
Review
(1) Points
none
one and only one (*)
one or two
unlimited
Incorrect. Refer to Section 9
35. 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
Correct
36. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
Correct
37. 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 (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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);
Incorrect. Refer to Section 9
39. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
40. 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
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. 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);
(*)
ALTER TABLE employee
MODIFY emp_id PRIMARY KEY;
ALTER TABLE employee
MODIFY CONSTRAINT PRIMARY KEY (emp_id);
Correct
42. What actions can be performed on or with Constraints? Mark for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct
43. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
44. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Incorrect. Refer to Section 9
45. Which of the following would always cause an integrity constraint error?
Mark for Review
(1) Points
Using a subquery in an INSERT statement.
Using the MERGE statement to conditionally insert or update rows.
Using the DELETE command on a row that contains a primary key with a dependent
foreign key. (*)
Using the UPDATE command on rows based in another table.
Incorrect. Refer to Section 9
46. 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
Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES employees
(employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY BETWEEN salary (employee_id) AND
employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees (employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) = employees
(employee_id);
Incorrect. Refer to Section 9
47. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Incorrect. Refer to Section 9
Section 10 Lesson 1
(Answer all questions in this section)
48. 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
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. (*)
Correct
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.
Incorrect. Refer to Section 10
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. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Incorrect. Refer to Section 10
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 (*)
Incorrect. Refer to Section 10
53. 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
Incorrect. Refer to Section 10
54. Views must be used to select data from a table if one exist. As soon as a
view is created on a table, you can no longer select direct from the table. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
55. 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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct
Section 10 Lesson 2
(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.
(*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in subquery
Incorrect. Refer to Section 10
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.
Correct
58. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct
59. You create a view on the EMPLOYEES and DEPARTMENTS tables to display salary
information per department. What will happen if you issue the following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points
A complex view is created that returns the sum of salaries per department,
sorted by department name. (*)
A simple view is created that returns the sum of salaries per department,
sorted by department name.
A complex view is created that returns the sum of salaries per department,
sorted by department id.
Nothing, as the statement constains an error and will fail.
Incorrect. Refer to Section 10
60. 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
Page 6 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 2
(Answer all questions in this section)
61. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
62. 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
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
64. 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
SELECT (*)
Correct
65. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. A gap can occur in a sequence because a user generated a number from the
sequence and then rolled back the transaction. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 11
70. The ALTER SEQUENCE statement can be used to: Mark for Review
(1) Points
Change the START WITH value of a sequence
Change the maximum value to a lower number than was last used
Change the name of the sequence
Change how much a sequence increments by each time a number is generated (*)
Correct
Page 7 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 2
(Answer all questions in this section)
71. Sequences can be used to: (choose three) Mark for Review
(1) Points
(Choose all correct answers)
Ensure primary key values will be unique and consecutive
Ensure primary key values will be unique even though gaps may exist (*)
Generate a range of numbers and optionally cycle through them again (*)
Set a fixed interval between successively generated numbers. (*)
Guarantee that no primary key values are unused
Incorrect. Refer to Section 11
72. 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.
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of
the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Correct
74. 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.
Incorrect. Refer to Section 11
75. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
76. 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.
An index can prevent users from viewing certain data in a table.
Correct
77. 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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
78. 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
79. 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
80. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Incorrect. Refer to Section 11
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. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true?
Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index. (*)
Incorrect. Refer to Section 11
82. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
83. When creating an index on one or more columns of a table, which of the
following statements are true? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
You should create an index if the table is large and most queries are expected
to retrieve less than 2 to 4 percent of the rows. (*)
You should always create an index on tables that are frequently updated.
You should create an index if one or more columns are frequently used together
in a join condition. (*)
You should create an index if the table is very small.
Incorrect. Refer to Section 11
84. 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.
Incorrect. Refer to Section 11
85. 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
an index (*)
a FOREIGN KEY constraint
Incorrect. Refer to Section 11
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;
Incorrect. Refer to Section 12
87. Which of the following are system privileges? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE PROCEDURE (*)
INDEX
Correct
88. 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
89. You want to grant privileges to user CHAN that will allow CHAN to update the
data in the EMPLOYEE table. Which type of privileges will you grant to CHAN? Mark
for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct
90. 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;
Correct
Page 9 of 10
Test: 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 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Correct
92. 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;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
(*)
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to grant privileges to a role? Mark for
Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
Incorrect. Refer to Section 12
94. 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
Incorrect. Refer to Section 12
95. Which keyword would you use to grant an object privilege to all database
users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Incorrect. Refer to Section 12
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.
Correct
97. Which statement would you use to remove an object privilege granted to a
user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
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
Section 14 Lesson 1
(Answer all questions in this section)
99. 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
Incorrect. Refer to Section 14
100. 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;
What result will JANE see?
Mark for Review
(1) Points
22
20 (*)
JANE will receive an error message because she is not allowed to query the
table while BOB is updating it.
Incorrect. Refer to Section 14
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 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));
Incorrect. Refer to Section 8
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));
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct
3. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct
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.
Correct
5. 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
Correct
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
INTERVAL YEAR TO MONTH
TIMESTAMP (*)
INTERVAL DAY TO SECOND
Correct
7. 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 (*)
Correct
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
Correct
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
Correct
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
column? Mark for Review
(1) Points
CHAR
DATE
NUMBER (*)
VARCHAR2
Correct
Page 1 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 2
(Answer all questions in this section)
11. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
12. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
14. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
15. 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
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect. Refer to Section 8 Lesson 3
17. 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. (*)
Correct
18. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct
19. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
20. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Correct
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. 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
22. To do a logical delete of a column without the performance penalty of
rewriting all the table datablocks you can issue the following command: Mark for
Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Correct
23. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
ALTER TABLE teams REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
10
You can have as many NOT NULL constraints as you have columns in your table.
(*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. You need to add a NOT NULL constraint to the COST column in the PART table.
Which statement should you use to complete this task? Mark for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL); (*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Correct
28. A table can only have one unique key constraint defined. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
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
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct
Page 3 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 2
(Answer all questions in this section)
31. 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 (*)
Correct
32. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the same
datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Correct
33. 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
34. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Incorrect. Refer to Section 9
35. 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
36. 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) (*)
CHECK CONSTRAINT part_cost_ck (cost > 1.00)
CONSTRAINT CHECK part_cost_ck (cost > 1.00)
Correct
37. 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. (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
39. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
40. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
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. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Incorrect. Refer to Section 9
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';
ALTER TABLE employees DISABLE fk_dept_id_01;
ALTER TABLE employees DISABLE CONSTRAINT fk_dept_id_01; (*)
Correct
43. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
44. 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
Correct
45. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct
46. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct
47. 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
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. (*)
Correct
49. 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
50. 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.
Incorrect. Refer to Section 10
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. 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
52. Evaluate this view definition:
CREATE OR REPLACE VIEW part_name_v
AS SELECT DISTINCT part_name
FROM parts
WHERE cost >= 45;
Which of the following statements using the PART_NAME_V view will execute
successfully?
Mark for Review
(1) Points
SELECT *
FROM part_name_v;
(*)
UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;
DELETE FROM part_name_v
WHERE part_id = 56897;
INSERT INTO part_name_v (part_id, part_name, product_id, cost) VALUES (857986,
'cylinder', 8790, 3.45);
Correct
53. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Incorrect. Refer to Section 10
54. Which of the following keywords cannot be used when creating a view? Mark
for Review
(1) Points
HAVING
WHERE
ORDER BY (*)
They are all valid keywords when creating views.
Correct
55. Which statement about the CREATE VIEW statement is false? Mark for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Correct
Section 10 Lesson 2
(Answer all questions in this section)
56. 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
Correct
57. You cannot create a view if the view subquery contains an inline view. True
or False? Mark for Review
(1) Points
True
False (*)
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. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
60. 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
Incorrect. Refer to Section 10
Page 6 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 2
(Answer all questions in this section)
61. 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
62. 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.
(*)
Incorrect. Refer to Section 10
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;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary "Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Correct
64. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
65. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
66. The EMP_HIST_V view is no longer needed. Which statement should you use to
the remove this view? Mark for Review
(1) Points
DROP emp_hist_v;
DELETE emp_hist_v;
REMOVE emp_hist_v;
DROP VIEW emp_hist_v; (*)
Correct
67. 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
SELECT (*)
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Incorrect. Refer to Section 11
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct
Page 7 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 2
(Answer all questions in this section)
71. You need to retrieve the next available value for the SALES_IDX sequence.
Which would you include in your SQL statement? Mark for Review
(1) Points
sales_idx
sales_idx.NEXT
sales_idx.NEXTVAL (*)
sales_idx.CURRVAL
Correct
72. 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 ; (*)
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. 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 (*)
Incorrect. Refer to Section 11
74. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
75. Unique indexes are automatically created on columns that have which two
types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
76. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
77. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
78. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
79. 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
80. 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.
An index can prevent users from viewing certain data in a table.
Correct
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. You want to speed up the following query by creating an index:
SELECT * FROM employees WHERE (salary * 12) > 100000;
Which of the following will achieve this?
Mark for Review
(1) Points
Create a composite index on (salary,12).
Create a function-based index on (salary * 12). (*)
Create an index on (salary).
Create a function_based index on ((salary * 12) > 100000).
Correct
82. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
83. 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; (*)
Correct
84. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you own.
You created a public synonym on the EMPLOYEES table owned by user Sam.
You created a private synonym on the EMPLOYEES table owned by user Sam. (*)
Correct
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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
87. 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;
Correct
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
Incorrect. Refer to Section 12
89. 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
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.
A role is a name for a group of privileges. (*)
A role is an object privilege which allows a user to update a table.
Correct
Page 9 of 10
Test: 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 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;
Correct
92. 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
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
Section 12 Lesson 3
(Answer all questions in this section)
93. 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
Correct
94. Which statement would you use to remove an object privilege granted to a
user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
Correct
95. Which of the following simplifies the administration of privileges? Mark
for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
96. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other object privileges on the table to other users. True or False? Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 12
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;
Incorrect. Refer to Section 12
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.
Correct
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically rolled
back. True or False? Mark for Review
(1) Points
True (*)
False
Correct
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
Correct
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 statement about creating a table is true? Mark for Review
(1) Points
With a CREATE TABLE statement, a table will always be created in the current
user's schema.
If no schema is explicitly included in a CREATE TABLE statement, the table is
created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE statement, the CREATE
TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE statement and the schema
does not exist, it will be created.
Correct
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);
Correct
3. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Correct
4. 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));
Incorrect. Refer to Section 8
5. 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
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
Incorrect. Refer to Section 8
7. 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
8. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Incorrect. Refer to Section 8
9. 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
Incorrect. Refer to Section 8
10. 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.
(*)
Incorrect. Refer to Section 8
Page 1 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 2
(Answer all questions in this section)
11. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Incorrect. Refer to Section 8
12. 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
Section 8 Lesson 3
(Answer all questions in this section)
13. You need to change the name of the EMPLOYEE table to the EMP table. Which
statement should you use? Mark for Review
(1) Points
RENAME employee emp;
RENAME employee TO emp; (*)
ALTER TABLE employee TO emp;
ALTER TABLE employee RENAME TO emp;
Correct
14. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Incorrect. Refer to Section 8 Lesson 3
15. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect. Refer to Section 8 Lesson 3
17. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is not
empty. (*)
Incorrect. Refer to Section 8 Lesson 3
18. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Incorrect. Refer to Section 8 Lesson 3
19. 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct
20. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
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. 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. (*)
Correct
22. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
23. 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 (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. A table can only have one unique key constraint defined. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. 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 (*)
Incorrect. Refer to Section 9
28. You need to add a NOT NULL constraint to the COST column in the PART table.
Which statement should you use to complete this task? Mark for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL); (*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Incorrect. Refer to Section 9
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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.
Incorrect. Refer to Section 9
Page 3 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 2
(Answer all questions in this section)
31. 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
32. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Incorrect. Refer to Section 9
33. 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
34. How many PRIMARY KEY constraints can be created for each table? Mark for
Review
(1) Points
none
one and only one (*)
one or two
unlimited
Incorrect. Refer to Section 9
35. 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
Correct
36. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
Correct
37. 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 (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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);
Incorrect. Refer to Section 9
39. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
40. 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
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. 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);
(*)
ALTER TABLE employee
MODIFY emp_id PRIMARY KEY;
ALTER TABLE employee
MODIFY CONSTRAINT PRIMARY KEY (emp_id);
Correct
42. What actions can be performed on or with Constraints? Mark for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct
43. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
44. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Incorrect. Refer to Section 9
45. Which of the following would always cause an integrity constraint error?
Mark for Review
(1) Points
Using a subquery in an INSERT statement.
Using the MERGE statement to conditionally insert or update rows.
Using the DELETE command on a row that contains a primary key with a dependent
foreign key. (*)
Using the UPDATE command on rows based in another table.
Incorrect. Refer to Section 9
46. 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
Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES employees
(employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY BETWEEN salary (employee_id) AND
employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees (employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) = employees
(employee_id);
Incorrect. Refer to Section 9
47. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Incorrect. Refer to Section 9
Section 10 Lesson 1
(Answer all questions in this section)
48. 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
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. (*)
Correct
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.
Incorrect. Refer to Section 10
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. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Incorrect. Refer to Section 10
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 (*)
Incorrect. Refer to Section 10
53. 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
Incorrect. Refer to Section 10
54. Views must be used to select data from a table if one exist. As soon as a
view is created on a table, you can no longer select direct from the table. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
55. 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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct
Section 10 Lesson 2
(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.
(*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in subquery
Incorrect. Refer to Section 10
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.
Correct
58. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct
59. You create a view on the EMPLOYEES and DEPARTMENTS tables to display salary
information per department. What will happen if you issue the following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points
A complex view is created that returns the sum of salaries per department,
sorted by department name. (*)
A simple view is created that returns the sum of salaries per department,
sorted by department name.
A complex view is created that returns the sum of salaries per department,
sorted by department id.
Nothing, as the statement constains an error and will fail.
Incorrect. Refer to Section 10
60. 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
Page 6 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 2
(Answer all questions in this section)
61. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
62. 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
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
64. 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
SELECT (*)
Correct
65. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. A gap can occur in a sequence because a user generated a number from the
sequence and then rolled back the transaction. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 11
70. The ALTER SEQUENCE statement can be used to: Mark for Review
(1) Points
Change the START WITH value of a sequence
Change the maximum value to a lower number than was last used
Change the name of the sequence
Change how much a sequence increments by each time a number is generated (*)
Correct
Page 7 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 2
(Answer all questions in this section)
71. Sequences can be used to: (choose three) Mark for Review
(1) Points
(Choose all correct answers)
Ensure primary key values will be unique and consecutive
Ensure primary key values will be unique even though gaps may exist (*)
Generate a range of numbers and optionally cycle through them again (*)
Set a fixed interval between successively generated numbers. (*)
Guarantee that no primary key values are unused
Incorrect. Refer to Section 11
72. 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.
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of
the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Correct
74. 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.
Incorrect. Refer to Section 11
75. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
76. 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.
An index can prevent users from viewing certain data in a table.
Correct
77. 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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
78. 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
79. 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
80. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Incorrect. Refer to Section 11
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. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true?
Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index. (*)
Incorrect. Refer to Section 11
82. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
83. When creating an index on one or more columns of a table, which of the
following statements are true? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
You should create an index if the table is large and most queries are expected
to retrieve less than 2 to 4 percent of the rows. (*)
You should always create an index on tables that are frequently updated.
You should create an index if one or more columns are frequently used together
in a join condition. (*)
You should create an index if the table is very small.
Incorrect. Refer to Section 11
84. 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.
Incorrect. Refer to Section 11
85. 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
an index (*)
a FOREIGN KEY constraint
Incorrect. Refer to Section 11
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;
Incorrect. Refer to Section 12
87. Which of the following are system privileges? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE PROCEDURE (*)
INDEX
Correct
88. 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
89. You want to grant privileges to user CHAN that will allow CHAN to update the
data in the EMPLOYEE table. Which type of privileges will you grant to CHAN? Mark
for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct
90. 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;
Correct
Page 9 of 10
Test: 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 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Correct
92. 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;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
(*)
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to grant privileges to a role? Mark for
Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
Incorrect. Refer to Section 12
94. 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
Incorrect. Refer to Section 12
95. Which keyword would you use to grant an object privilege to all database
users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Incorrect. Refer to Section 12
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.
Correct
97. Which statement would you use to remove an object privilege granted to a
user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
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
Section 14 Lesson 1
(Answer all questions in this section)
99. 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
Incorrect. Refer to Section 14
100. 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;
What result will JANE see?
Mark for Review
(1) Points
22
20 (*)
JANE will receive an error message because she is not allowed to query the
table while BOB is updating it.
Incorrect. Refer to Section 14
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 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));
Incorrect. Refer to Section 8
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));
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct
3. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct
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.
Correct
5. 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
Correct
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
INTERVAL YEAR TO MONTH
TIMESTAMP (*)
INTERVAL DAY TO SECOND
Correct
7. 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 (*)
Correct
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
Correct
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
Correct
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
column? Mark for Review
(1) Points
CHAR
DATE
NUMBER (*)
VARCHAR2
Correct
Page 1 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 2
(Answer all questions in this section)
11. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
12. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
14. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
15. 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
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect. Refer to Section 8 Lesson 3
17. 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. (*)
Correct
18. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct
19. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
20. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Correct
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. 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
22. To do a logical delete of a column without the performance penalty of
rewriting all the table datablocks you can issue the following command: Mark for
Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Correct
23. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
ALTER TABLE teams REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
10
You can have as many NOT NULL constraints as you have columns in your table.
(*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. You need to add a NOT NULL constraint to the COST column in the PART table.
Which statement should you use to complete this task? Mark for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL); (*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Correct
28. A table can only have one unique key constraint defined. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
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
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct
Page 3 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 2
(Answer all questions in this section)
31. 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 (*)
Correct
32. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the same
datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Correct
33. 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
34. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Incorrect. Refer to Section 9
35. 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
36. 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) (*)
CHECK CONSTRAINT part_cost_ck (cost > 1.00)
CONSTRAINT CHECK part_cost_ck (cost > 1.00)
Correct
37. 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. (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
39. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
40. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
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. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Incorrect. Refer to Section 9
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';
ALTER TABLE employees DISABLE fk_dept_id_01;
ALTER TABLE employees DISABLE CONSTRAINT fk_dept_id_01; (*)
Correct
43. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
44. 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
Correct
45. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct
46. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct
47. 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
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. (*)
Correct
49. 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
50. 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.
Incorrect. Refer to Section 10
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. 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
52. Evaluate this view definition:
CREATE OR REPLACE VIEW part_name_v
AS SELECT DISTINCT part_name
FROM parts
WHERE cost >= 45;
Which of the following statements using the PART_NAME_V view will execute
successfully?
Mark for Review
(1) Points
SELECT *
FROM part_name_v;
(*)
UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;
DELETE FROM part_name_v
WHERE part_id = 56897;
INSERT INTO part_name_v (part_id, part_name, product_id, cost) VALUES (857986,
'cylinder', 8790, 3.45);
Correct
53. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Incorrect. Refer to Section 10
54. Which of the following keywords cannot be used when creating a view? Mark
for Review
(1) Points
HAVING
WHERE
ORDER BY (*)
They are all valid keywords when creating views.
Correct
55. Which statement about the CREATE VIEW statement is false? Mark for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Correct
Section 10 Lesson 2
(Answer all questions in this section)
56. 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
Correct
57. You cannot create a view if the view subquery contains an inline view. True
or False? Mark for Review
(1) Points
True
False (*)
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. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
60. 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
Incorrect. Refer to Section 10
Page 6 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 2
(Answer all questions in this section)
61. 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
62. 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.
(*)
Incorrect. Refer to Section 10
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;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary "Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Correct
64. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
65. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
66. The EMP_HIST_V view is no longer needed. Which statement should you use to
the remove this view? Mark for Review
(1) Points
DROP emp_hist_v;
DELETE emp_hist_v;
REMOVE emp_hist_v;
DROP VIEW emp_hist_v; (*)
Correct
67. 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
SELECT (*)
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Incorrect. Refer to Section 11
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct
Page 7 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 2
(Answer all questions in this section)
71. You need to retrieve the next available value for the SALES_IDX sequence.
Which would you include in your SQL statement? Mark for Review
(1) Points
sales_idx
sales_idx.NEXT
sales_idx.NEXTVAL (*)
sales_idx.CURRVAL
Correct
72. 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 ; (*)
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. 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 (*)
Incorrect. Refer to Section 11
74. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
75. Unique indexes are automatically created on columns that have which two
types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
76. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
77. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
78. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
79. 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
80. 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.
An index can prevent users from viewing certain data in a table.
Correct
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. You want to speed up the following query by creating an index:
SELECT * FROM employees WHERE (salary * 12) > 100000;
Which of the following will achieve this?
Mark for Review
(1) Points
Create a composite index on (salary,12).
Create a function-based index on (salary * 12). (*)
Create an index on (salary).
Create a function_based index on ((salary * 12) > 100000).
Correct
82. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
83. 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; (*)
Correct
84. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you own.
You created a public synonym on the EMPLOYEES table owned by user Sam.
You created a private synonym on the EMPLOYEES table owned by user Sam. (*)
Correct
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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
87. 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;
Correct
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
Incorrect. Refer to Section 12
89. 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
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.
A role is a name for a group of privileges. (*)
A role is an object privilege which allows a user to update a table.
Correct
Page 9 of 10
Test: 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 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;
Correct
92. 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
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
Section 12 Lesson 3
(Answer all questions in this section)
93. 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
Correct
94. Which statement would you use to remove an object privilege granted to a
user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
Correct
95. Which of the following simplifies the administration of privileges? Mark
for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
96. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other object privileges on the table to other users. True or False? Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 12
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;
Incorrect. Refer to Section 12
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.
Correct
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically rolled
back. True or False? Mark for Review
(1) Points
True (*)
False
Correct
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
Correct
Page 10 of 10
Skip navigation elements to page contents
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
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);
Correct Correct
2. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct Correct
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct Correct
4. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Incorrect Incorrect. Refer to Section 8
5. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
1
4 (*)
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 2
(Answer all questions in this section)
6. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct Correct
7. The TIMESTAMP data type allows what? Mark for Review
(1) Points
Time to be stored as an interval of years and months.
Time to be stored as a date with fractional seconds. (*)
Time to be stored as an interval of days to hours, minutes and seconds.
None of the above.
Incorrect Incorrect. Refer to Section 8
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
Correct Correct
9. 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 Correct
10. 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 Correct
Page 1 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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
12. 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
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect Incorrect. Refer to Section 8 Lesson 3
14. 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. (*)
Correct Correct
15. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct Correct
16. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct Correct
17. 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
Correct Correct
18. To do a logical delete of a column without the performance
penalty of rewriting all the table datablocks you can issue the following command:
Mark for Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Incorrect Incorrect. Refer to Section 8 Lesson 3
19. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct Correct
20. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is
not empty. (*)
Incorrect Incorrect. Refer to Section 8 Lesson 3
Previous Page 2 of 10 Next Summary
Skip navigation elements to page contents
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. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Incorrect Incorrect. Refer to Section 8 Lesson 3
22. 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 (*)
Correct 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
 address VARCHAR2(25),
 city VARCHAR2(25),
 region VARCHAR2(25),
 postal_code VARCHAR2(11),
 CONSTRAINT customer_id_un UNIQUE(customer_id),
 CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct Correct
25. 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 Correct
26. 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
Correct Correct
27. Which constraint can only be created at the column level? Mark
for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct Correct
28. A table can only have one unique key constraint defined. True or
False? Mark for Review
(1) Points
True
False (*)
Correct Correct
29. 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 Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the
same datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Incorrect Incorrect. Refer to Section 9
Previous Page 3 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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 of the following types of constraints enforces uniqueness?
Mark for Review
(1) Points
CHECK
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct Correct
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.
Incorrect Incorrect. Refer to Section 9
33. 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 Correct
34. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE);
(*)
Incorrect Incorrect. Refer to Section 9
35. 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
Correct Correct
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 (*)
Correct Correct
37. 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. (*)
Incorrect Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
Correct Correct
39. 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
Incorrect Incorrect. Refer to Section 9
40. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct Correct
Previous Page 4 of 10 Next Summary
Skip navigation elements to page contents
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. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct Correct
42. You need to display the names and definitions of constraints only
in your schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct 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. (*)
Incorrect Incorrect. Refer to Section 9
44. 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;
Correct Correct
45. 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 (*)
ENABLE
Incorrect Incorrect. Refer to Section 9
46. What actions can be performed on or with Constraints? Mark
for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct Correct
47. 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);
ALTER TABLE employee
ADD CONSTRAINT dept_id_fk FOREIGN KEY (dept_id) REFERENCES department(id);
(*)
ALTER TABLE employee
ADD FOREIGN KEY CONSTRAINT dept_id_fk ON (dept_id) REFERENCES department(id);
ALTER TABLE employee
ADD FOREIGN KEY department(id) REFERENCES (dept_id);
Correct Correct
Section 10 Lesson 1
(Answer all questions in this section)
48. 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 Correct
49. 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 Correct
50. 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. (*)
Incorrect Incorrect. Refer to Section 10
Previous Page 5 of 10 Next Summary
Skip navigation elements to page contents
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 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct Correct
54. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple (*)
inline
complex
Incorrect Incorrect. Refer to Section 10
55. Which statement about the CREATE VIEW statement is false? Mark
for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Incorrect Incorrect. Refer to Section 10
Section 10 Lesson 2
(Answer all questions in this section)
56. 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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 Correct
59. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct 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
Correct Correct
Previous Page 6 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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.
Correct Correct
62. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct Correct
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
SELECT (*)
Correct 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 Correct
65. Evaluate this SELECT statement:
SELECT ROWNUM "Rank", customer_id, new_balance
FROM
(SELECT customer_id, new_balance
FROM customer_finance
ORDER BY new_balance DESC)
WHERE ROWNUM <= 25;
Which type of query is this SELECT statement?
Mark for Review
(1) Points
A Top-n query (*)
A complex view
A simple view
A hierarchical view
Correct Correct
66. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect Incorrect. Refer to Section 10
67. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
JOB_ID NUMBER
MANAGER_ID NUMBER
SALARY NUMBER(9,2)
COMMISSOIN NUMBER(7,2)
HIRE_DATE DATE
Which SELECT statement could be used to display the 10 lowest paid clerks that
belong to department 70?
Mark for Review
(1) Points
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary
FROM employees
ORDER BY salary)
WHERE ROWNUM <=10 AND job_id LIKE 'CLERK' AND department_id = 70;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Incorrect Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. You issue this statement:
ALTER SEQUENCE po_sequence INCREMENT BY 2;
Which statement is true?
Mark for Review
(1) Points
Sequence numbers will be cached.
Future sequence numbers generated will increase by 2 each time a number is
generated. (*)
If the PO_SEQUENCE sequence does not exist, it will be created.
The statement fails if the current value of the sequence is greater than the
START WITH value.
Correct Correct
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
Correct Correct
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct Correct
Previous Page 7 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq INCREMENT BY -1;
Which statement is true?
Mark for Review
(1) Points
The statement will not execute successfully.
The sequence will generate sequential descending values. (*)
The starting value of the LINE_ITEM_ID_SEQ sequence will by -1.
The minimum value of the LINE_ITEM_ID_SEQ will be the smallest possible
integer value.
Correct Correct
72. Evaluate this statement:
CREATE SEQUENCE sales_item_id_seq
START WITH 101 MAXVALUE 9000090 CYCLE;
Which statement about this CREATE SEQUENCE statement is true?
Mark for Review
(1) Points
The sequence will reuse numbers and will start with 101. (*)
The sequence will generate decrementing sequence numbers starting at 101.
The statement fails because no INCREMENT BY value is specified.
The sequence will generate sequence numbers starting with 101, but will not
reuse numbers.
Correct Correct
Section 11 Lesson 3
(Answer all questions in this section)
73. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Incorrect Incorrect. Refer to Section 11
74. The EMPLOYEES table has an index named LN_IDX on the LAST_NAME
column. You want to change this index so that it is on the FIRST_NAME column
instead. Which SQL statement will do this? Mark for Review
(1) Points
ALTER INDEX ln_idx ON employees(first_name);
ALTER INDEX ln_idx TO employees(first_name);
ALTER INDEX ln_idx TO fn_idx ON employees(first_name);
None of the above; you cannot ALTER an index. (*)
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 (*)
Incorrect Incorrect. Refer to Section 11
76. 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; (*)
Incorrect Incorrect. Refer to Section 11
77.
As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you
own.
You created a public synonym on the EMPLOYEES table owned by user
Sam.
You created a private synonym on the EMPLOYEES table owned by
user Sam. (*)
Incorrect Incorrect. Refer to Section 11
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.
(*)
An index must be created by a database administrator when a PRIMARY KEY
constraint is created.
An index is never created for a unique constraint.
An index cannot be created before a PRIMARY KEY constraint is created.
Correct 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct Correct
80. 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.
An index can prevent users from viewing certain data in a table.
Correct Correct
Previous Page 8 of 10 Next Summary
Skip navigation elements to page contents
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. 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 Correct
82. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct Correct
83. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DEPARTMENT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCT table
HIRE_DATE DATE DEFAULT SYSDATE
SALARY NUMBER (8,2) NOT NULL
On which column is an index automatically created for the EMPLOYEES table?
Mark for Review
(1) Points
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct Correct
84. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of
the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Incorrect Incorrect. Refer to Section 11
85. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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 Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. You want to grant privileges to user CHAN that will allow CHAN to
update the data in the EMPLOYEE table. Which type of privileges will you grant to
CHAN? Mark for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct Correct
87. 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
Incorrect Incorrect. Refer to Section 12
88. 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
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.
Incorrect Incorrect. Refer to Section 12
89. 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;
Incorrect Incorrect. Refer to Section 12
90. 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 Correct
Previous Page 9 of 10 Next Summary
Skip navigation elements to page contents
Test: 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 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;
Incorrect Incorrect. Refer to Section 12
92. 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Incorrect Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. 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 Correct
94. 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;
Incorrect Incorrect. Refer to Section 12
95. To join a table in your database to a table on a second (remote)
Oracle database, you need to use: Mark for Review
(1) Points
A remote procedure call
An Oracle gateway product
An ODBC driver
A database link (*)
Correct Correct
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.
Incorrect Incorrect. Refer to Section 12
97. Which of the following simplifies the administration of
privileges? Mark for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct 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;
Incorrect Incorrect. Refer to Section 12
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically
rolled back. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect Incorrect. Refer to Section 14
100. Examine the following statements:
UPDATE employees SET salary = 15000;
SAVEPOINT upd1_done;
UPDATE employees SET salary = 22000;
SAVEPOINT upd2_done;
DELETE FROM employees;
You want to retain all the employees with a salary of 15000; What statement would
you execute next?
Mark for Review
(1) Points
ROLLBACK;
ROLLBACK TO SAVEPOINT upd1_done; (*)
ROLLBACK TO SAVEPOINT upd2_done;
ROLLBACK TO SAVE upd1_done;
There is nothing you can do, either all changes must be rolled back, or none
of them can be rolled back.
Correct Correct
Previous Page 10 of 10 Summary
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 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));
Correct
2. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct
3. 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
Correct
4. Which column name is valid? Mark for Review
(1) Points
1NUMBER
NUMBER
NUMBER_1$ (*)
1_NUMBER#
Incorrect. Refer to Section 8
5. Which statement about creating a table is true? Mark for Review
(1) Points
With a CREATE TABLE statement, a table will always be created in the current
user's schema.
If no schema is explicitly included in a CREATE TABLE statement, the table is
created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE statement, the CREATE
TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE statement and the schema
does not exist, it will be created.
Correct
Section 8 Lesson 2
(Answer all questions in this section)
6. The TIMESTAMP data type allows what? Mark for Review
(1) Points
Time to be stored as an interval of years and months.
Time to be stored as a date with fractional seconds. (*)
Time to be stored as an interval of days to hours, minutes and seconds.
None of the above.
Correct
7. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
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 (*)
Correct
9. 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
Correct
10. 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
Page 1 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 2
(Answer all questions in this section)
11. 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
12. Which data types stores variable-length character data? Select two. Mark
for Review
(1) Points
(Choose all correct answers)
CHAR
NCHAR
VARCHAR (*)
VARCHAR2 (*)
Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Correct
14. 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
Correct
15. You need to change the name of the EMPLOYEE table to the EMP table. Which
statement should you use? Mark for Review
(1) Points
RENAME employee emp;
RENAME employee TO emp; (*)
ALTER TABLE employee TO emp;
ALTER TABLE employee RENAME TO emp;
Correct
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Correct
17. 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
18. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is not
empty. (*)
Correct
19. To do a logical delete of a column without the performance penalty of
rewriting all the table datablocks you can issue the following command: Mark for
Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Correct
20. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
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. Which statement about a column is NOT true? Mark for Review
(1) Points
You can increase the width of a CHAR column.
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.
You can decrease the width of a VARCHAR2 column.
Correct
22. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Correct
23. 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
Section 9 Lesson 1
(Answer all questions in this section)
24. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
10
You can have as many NOT NULL constraints as you have columns in your table.
(*)
Correct
25. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
address VARCHAR2(25),
city VARCHAR2(25),
region VARCHAR2(25),
postal_code VARCHAR2(11),
CONSTRAINT customer_id_un UNIQUE(customer_id),
CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct
26. 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
27. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Correct
28. 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
Correct
29. 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
Section 9 Lesson 2
(Answer all questions in this section)
30. 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) (*)
CHECK CONSTRAINT part_cost_ck (cost > 1.00)
CONSTRAINT CHECK part_cost_ck (cost > 1.00)
Correct
Page 3 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 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
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. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the same
datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Correct
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
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
35. 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
36. Which of the following types of constraints enforces uniqueness? Mark for
Review
(1) Points
CHECK
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct
37. 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.
Correct
Section 9 Lesson 3
(Answer all questions in this section)
38. 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
Correct
39. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct
40. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
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. Examine the structures of the PRODUCT and SUPPLIER tables.
PRODUCT
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIER table
LIST_PRICE NUMBER (7,2)
COST NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
REORDER_QTY NUMBER
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;
For which task would you issue this statement?
Mark for Review
(1) Points
To remove all constraint references to SUPPLIERS table
To drop the FOREIGN KEY constraint on the PRODUCTS table
To remove all constraint references to the PRODUCTS table
To disable any dependent integrity constraints on the SUPPLIER_ID column in the
PRODUCTS table
To disable any dependent integrity constraints on the SUPPLIER_ID column in the
SUPPLIERS table (*)
Incorrect. Refer to Section 9
42. 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 (*)
ENABLE
Correct
43. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
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
45. 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
Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES employees
(employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY BETWEEN salary (employee_id) AND
employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees (employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) = employees
(employee_id);
Correct
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 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
47. 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);
ALTER TABLE employee
ADD CONSTRAINT dept_id_fk FOREIGN KEY (dept_id) REFERENCES department(id);
(*)
ALTER TABLE employee
ADD FOREIGN KEY CONSTRAINT dept_id_fk ON (dept_id) REFERENCES department(id);
ALTER TABLE employee
ADD FOREIGN KEY department(id) REFERENCES (dept_id);
Correct
Section 10 Lesson 1
(Answer all questions in this section)
48. Which of the following keywords cannot be used when creating a view? Mark
for Review
(1) Points
HAVING
WHERE
ORDER BY (*)
They are all valid keywords when creating views.
Correct
49. Which statement about the CREATE VIEW statement is false? Mark for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
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.
Create a view. (*)
Create a subquery.
Create a trigger.
Correct
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. 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
52. 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
53. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Correct
54. 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
55. 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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct
Section 10 Lesson 2
(Answer all questions in this section)
56. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct
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 (*)
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. You cannot create a view if the view subquery contains an inline view. True
or False? Mark for Review
(1) Points
True
False (*)
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
Correct
Page 6 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 2
(Answer all questions in this section)
61. You cannot modify data in a view if the view contains ______. Mark for
Review
(1) Points
the DISTINCT keyword (*)
a WHERE clause
a subquery in the FROM clause
the WITH CHECK OPTION clause
Correct
62. 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
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
64. 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. (*)
Incorrect. Refer to Section 10
65. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
66. 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
67. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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
Section 11 Lesson 2
(Answer all questions in this section)
68. 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
Correct
69. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Correct
70. Which of the following best describes the function of the CURRVAL virtual
column? Mark for Review
(1) Points
The CURRVAL virtual column will display the integer that was most recently
supplied by a sequence. (*)
The CURRVAL virtual column will increment a sequence by a specified value.
The CURRVAL virtual column will display either the physical locations or the
logical locations of the rows in the table.
The CURRVAL virtual column will return a value of 1 for a parent record in a
hierarchical result set.
Incorrect. Refer to Section 11
Page 7 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 2
(Answer all questions in this section)
71. Creating a sequence with NOCACHE ensures that all numbers in the sequence's
range will be used successfully. True or False? Mark for Review
(1) Points
True
False (*)
Correct
72. 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 ; (*)
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
On which column is an index automatically created for the EMPLOYEES table?
Mark for Review
(1) Points
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct
74. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you own.
You created a public synonym on the EMPLOYEES table owned by user Sam.
You created a private synonym on the EMPLOYEES table owned by user Sam. (*)
Correct
75. 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.
An index can prevent users from viewing certain data in a table.
Correct
76. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
77. 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;
Incorrect. Refer to Section 11
78. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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
79. When creating an index on one or more columns of a table, which of the
following statements are true? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
You should create an index if the table is large and most queries are expected
to retrieve less than 2 to 4 percent of the rows. (*)
You should always create an index on tables that are frequently updated.
You should create an index if one or more columns are frequently used together
in a join condition. (*)
You should create an index if the table is very small.
Correct
80. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
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. 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
82. 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
83. 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. (*)
An index must be created by a database administrator when a PRIMARY KEY
constraint is created.
An index is never created for a unique constraint.
An index cannot be created before a PRIMARY KEY constraint is created.
Correct
84. 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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
85. 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 (*)
Incorrect. Refer to Section 11
Section 12 Lesson 2
(Answer all questions in this section)
86. 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
87. 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 (*)
Incorrect. Refer to Section 12
88. 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;
Correct
89. 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
90. Which of the following are system privileges? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE PROCEDURE (*)
INDEX
Correct
Page 9 of 10
Test: 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. 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;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
(*)
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
Correct
92. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
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
Correct
94. Which keyword would you use to grant an object privilege to all database
users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Correct
95. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other object privileges on the table to other users. True or False? Mark for
Review
(1) Points
True
False (*)
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. 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
Section 14 Lesson 1
(Answer all questions in this section)
99. 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
Correct
100. If a database crashes, all uncommitted changes are automatically rolled
back. True or False? Mark for Review
(1) Points
True (*)
False
Correct
Page 10 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. Which SQL function can be used to remove heading or trailing characters (or
both) from a character string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
Correct
2. Which SQL function is used to return the position where a specific character
string begins within a larger character string? Mark for Review
(1) Points
CONCAT
INSTR (*)
LENGTH
SUBSTR
Correct
3. You query the database with this SQL statement:
SELECT LOWER(SUBSTR(CONCAT(last_name, first_name)), 1, 5) "ID"
FROM employee;
In which order are the functions evaluated?
Mark for Review
(1) Points
LOWER, SUBSTR, CONCAT
LOWER, CONCAT, SUBSTR
SUBSTR, CONCAT, LOWER
CONCAT, SUBSTR, LOWER (*)
Correct
4. What will the following SQL statemtent display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value,
size of 15 and the column labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of
the decimal and the column labeled SALARY.
The last name and salary for all employees with the format of the salary 15
characters long, left-padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where
expected."
Correct
5. You need to display the number of characters in each customer's last name.
Which function should you use? Mark for Review
(1) Points
LENGTH (*)
LPAD
COUNT
SUBSTR
Correct
6. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 12.00
You query the database and return the value 79. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
(*)
Correct
7. You issue this SQL statement:
SELECT INSTR ('organizational sales', 'al')
FROM dual;
Which value is returned by this command?
Mark for Review
(1) Points
13 (*)
17
Correct
Section 1 Lesson 2
(Answer all questions in this section)
8. Which script displays '01-MAY-04' when the HIRE_DATE value is '20-MAY-04'?
Mark for Review
(1) Points
SELECT TRUNC(hire_date, 'MONTH')
FROM employee;
(*)
SELECT ROUND(hire_date, 'MONTH')
FROM employee;
SELECT ROUND(hire_date, 'MON')
FROM employee;
SELECT TRUNC(hire_date, 'MI')
FROM employee;
Correct
9. You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
Mark for Review
(1) Points
1200
1282
1282.25
1300 (*)
Correct
10. You issue this SQL statement:
SELECT TRUNC(751.367,-1)
FROM dual;
Which value does this statement display?
Mark for Review
(1) Points
700
750 (*)
751
751.3
Correct
Page 1 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1 Lesson 3
(Answer all questions in this section)
11. Evaluate this SELECT statement:
SELECT SYSDATE + 30
FROM dual;
Which value is returned by the query?
Mark for Review
(1) Points
the current date plus 30 hours
the current date plus 30 days (*)
the current date plus 30 months
No value is returned because the SELECT statement generates an error.
Correct
12. The EMPLOYEE table contains these columns:
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
HIRE_DATE DATE
EVAL_MONTHS NUMBER(3)
Evaluate this SELECT statement:
SELECT hire_date + eval_months
FROM employee;
The values returned by this SELECT statement will be of which data type?
Mark for Review
(1) Points
DATE (*)
NUMBER
DATETIME
INTEGER
Correct
13. Which of the following Date Functions will add calendar months to a date?
Mark for Review
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Correct
14. You want to create a report that displays all orders and their amounts that
were placed during the month of January. You want the orders with the highest
amounts to appear first. Which query should you issue? Mark for Review
(1) Points
SELECT orderid, total
FROM orders
WHERE order_date LIKE '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
SELECT orderid, total
FROM orders
WHERE order_date IN ( 01-jan-02 , 31-jan-02 )
ORDER BY total;
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
(*)
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '31-jan-02' AND '01-jan-02'
ORDER BY total DESC;
Correct
15. You need to display the current year as a character value (for example: Two
Thousand and One). Which element would you use? Mark for Review
(1) Points
RR
YY
YYYY
YEAR (*)
Correct
Section 2 Lesson 1
(Answer all questions in this section)
16. Which three statements concerning explicit data type conversions are true?
(Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
Use the TO_NUMBER function to convert a number to a character string.
Use the TO_DATE function to convert a character string to a date value. (*)
Use the TO_NUMBER function to convert a character string of digits to a number.
(*)
Use the TO_DATE function to convert a date value to character string or number.
Use the TO_CHAR function to convert a number or date value to character string.
(*)
Correct
17. Which arithmetic operation will return a numeric value? Mark for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
SYSDATE + 30 / 24
Correct
18. Which statement concerning single row functions is true? Mark for Review
(1) Points
Single row functions can accept only one argument, but can return multiple
values.
Single row functions cannot modify a data type.
Single row functions can be nested. (*)
Single row functions return one or more results per row.
Incorrect. Refer to Section 2
19. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2 (25)
FIRST_NAME VARCHAR2 (25)
SALARY NUMBER(6)
You need to create a report to display the salaries of all employees. Which script
should you use to display the salaries in format: "$45,000.00"?
Mark for Review
(1) Points
SELECT TO_CHAR(salary, '$999,999')
FROM employees;
SELECT TO_NUM(salary, '$999,990.99')
FROM employees;
SELECT TO_NUM(salary, '$999,999.00')
FROM employees;
SELECT TO_CHAR(salary, '$999,999.00')
FROM employees;
(*)
Incorrect. Refer to Section 2
20. Which functions allow you to perform explicit data type conversions? Mark
for Review
(1) Points
ROUND, TRUNC, ADD_MONTHS
LENGTH, SUBSTR, LPAD, TRIM
TO_CHAR, TO_DATE, TO_NUMBER (*)
NVL, NVL2, NULLIF
Correct
Page 2 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 2 Lesson 1
(Answer all questions in this section)
21. If you use the RR format when writing a query using the date 27-OCT-17 and
the year is 2001, what year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Correct
Section 2 Lesson 2
(Answer all questions in this section)
22. Which of the following General Functions will return the first non-null
expression in the expression list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
COALESCE (*)
Incorrect. Refer to Section 2
23. You need to replace null values in the DEPT_ID column with the text "N/A".
Which functions should you use? Mark for Review
(1) Points
TO_CHAR and NVL (*)
TO_CHAR and NULL
TO_CHAR and NULLIF
TO_NUMBER and NULLIF
Correct
24. When executed, which statement displays a zero if the TUITION_BALANCE value
is zero and the HOUSING_BALANCE value is null? Mark for Review
(1) Points
SELECT NVL (tuition_balance + housing_balance, 0) "Balance Due"
FROM student_accounts;
(*)
SELECT NVL(tuition_balance, 0), NVL (housing_balance), tuition_balance +
housing_balance "Balance Due"
FROM student_accounts;
SELECT tuition_balance + housing_balance
FROM student_accounts;
SELECT TO_NUMBER(tuition_balance, 0), TO_NUMBER (housing_balance, 0),
tutition_balance + housing_balance "Balance Due"
FROM student_accounts;
Correct
Section 3 Lesson 2
(Answer all questions in this section)
25. Your company stores its business information in an Oracle9i database. The
EMPLOYEES table includes the following columns:
EMP_ID NUMBER(5) NOT NULL PRIMARY KEY
FNAME VARCHAR2(25)
LNAME VARCHAR2(25)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(25)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
DEPT_ID NUMBER(5) NOT NULL FOREIGN KEY
The BONUS table includes the following columns:
BONUS_ID NUMBER(5) NOT NULL PRIMARY KEY
ANNUAL_SALARY NUMBER(10)
BONUS_PCT NUMBER(3, 2)
EMP_ID VARCHAR2(5) NOT NULL FOREIGN KEY
You want to determine the amount of each employee's bonus. Which of the following
queries should you issue?
Mark for Review
(1) Points
SELECT e.fname, e.lname, b.annual_salary * b. bonus_pct
FROM employees e, bonus b
WHERE e.emp_id = b.emp_id;
(*)
SELECT e.fname, e.lname, b.annual_salary, b. bonus_pct
FROM employees e, bonus b
WHERE e.emp_id = b.emp_id;
SELECT e.fname, e.lname, b.annual_salary, b. bonus_pct
FROM employees, bonus
WHERE e.emp_id = b.emp_id;
SELECT fname, lname, annual_salary * bonus_pct
FROM employees, bonus NATURAL JOIN;
Correct
26. What is the minimum number of join conditions required to join 5 tables
together? Mark for Review
(1) Points
4 (*)
One more than the number of tables
Correct
27. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
Correct
28. The CUSTOMERS and SALES tables contain these columns:
CUSTOMERS
CUST_ID NUMBER(10) PRIMARY KEY
COMPANY VARCHAR2(30)
LOCATION VARCHAR2(20)
SALES
SALES_ID NUMBER(5) PRIMARY KEY
CUST_ID NUMBER(10) FOREIGN KEY
TOTAL_SALES NUMBER(30)
Which SELECT statement will return the customer ID, the company and the total
sales?
Mark for Review
(1) Points
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id (+);
SELECT cust_id, company, total_sales
FROM customers, sales
WHERE cust_id = cust_id;
SELECT c.cust_id, c.company, s.total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
(*)
SELECT cust_id, company, total_sales
FROM customers c, sales s
WHERE c.cust_id = s.cust_id;
Correct
29. What is produced when a join condition is not specified in a multiple-table
query? Mark for Review
(1) Points
a self-join
an outer join
an equijoin
a Cartesian product (*)
Correct
30. You need to provide a list of the first and last names of all employees who
work in the Sales department who earned a bonus and had sales over $50,000. The
company president would like the sales listed starting with the highest amount
first. The EMPLOYEES table and the SALES_DEPT table contain the following columns:
EMPLOYEES
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
SALES_DEPT
SALES_ID NUMBER(10) PRIMARY KEY
SALES NUMBER(20)
QUOTA NUMBER(20)
MGR VARCHAR2(30)
BONUS NUMBER(10)
EMP_ID NUMBER(10) FOREIGN KEY
Which SELECT statement will accomplish this task?
Mark for Review
(1) Points
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s.sales
FROM employees e, sales_dept s
ORDER BY sales DESC
WHERE e.emp_id = s.emp_id AND sales > 50000 AND s.bonus IS NOT NULL;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
ORDER BY sales DESC
FROM employees e, sales_dept s
WHERE e.emp_id = s.emp_id AND s.bonus IS NOT NULL AND sales > 50000;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
WHERE e.emp_id = s.emp_id
FROM employees e, sales_dept s AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
SELECT e.emp_id, e.lname, e.fname, s.emp_id, s.bonus, s. sales
FROM employees e, sales_dept s
WHERE e.emp_id = s.emp_id AND s.bonus IS NOT NULL AND sales > 50000
ORDER BY sales DESC;
(*)
Correct
Page 3 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 3 Lesson 4
(Answer all questions in this section)
31. Evaluate this SELECT statement:
SELECT p.player_id, m.last_name, m.first_name, t.team_name
FROM player p
LEFT OUTER JOIN player m ON (p.manager_id = m.player_id)
LEFT OUTER JOIN team t ON (p.team_id = t.team_id);
Which join is evaluated first?
Mark for Review
(1) Points
the self-join of the player table (*)
the join between the player table and the team table on TEAM_ID
the join between the player table and the team table on MANAGER_ID
the join between the player table and the team table on PLAYER_ID
Correct
32. Which of the following best describes the function of an outer join? Mark
for Review
(1) Points
An outer join will return only those rows that do not meet the join criteria.
An outer join will return only data from the far left column in one table and
the far right column in the other table.
An outer join will return data only if both tables contain an identical pair of
columns.
An outer join will return all rows that meet the join criteria and will return
NULL values from one table if no rows from the other table satisfy the join
criteria. (*)
Correct
33. Which statement about outer joins is true? Mark for Review
(1) Points
The tables must be aliased.
The FULL, RIGHT, or LEFT keyword must be included.
The OR operator cannot be used to link outer join conditions. (*)
Outer joins are always evaluated before other types of joins in the query.
Incorrect. Refer to Section 3
Section 4 Lesson 2
(Answer all questions in this section)
34. Which of the following best describes a natural join? Mark for Review
(1) Points
A join between two tables that includes columns that share the same name,
datatypes and lengths (*)
A join that produces a Cartesian product
A join between tables where matching fields do not exist
A join that uses only one table
Correct
35. Which of the following conditions will cause an error on a NATURAL JOIN?
Mark for Review
(1) Points
When you attempt to write it as an equijoin.
When the NATURAL JOIN clause is based on all columns in the two tables that
have the same name.
If it selects rows from the two tables that have equal values in all matched
columns.
If the columns having the same names have different data types, then an error
is returned. (*)
Correct
36. You need to join all the rows in the EMPLOYEE table to all the rows in the
EMP_REFERENCE table. Which type of join should you create? Mark for Review
(1) Points
An equijoin
A cross join (*)
An inner join
A full outer join
Correct
Section 4 Lesson 3
(Answer all questions in this section)
37. Which of the following statements is the simplest description of a
nonequijoin? Mark for Review
(1) Points
A join condition containing something other than an equality operator (*)
A join condition that is not equal to other joins.
A join condition that includes the (+) on the left hand side.
A join that joins a table to itself
Correct
38. You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE
statements in sequence:
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information about
orders placed by customers who reside in Nashville . Which query should you issue
to achieve the desired results?
Mark for Review
(1) Points
SELECT custid, companyname
FROM customers
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
(*)
SELECT orderid, orderdate, total
FROM orders
WHERE city = 'Nashville';
Incorrect. Refer to Section 4
39. The primary advantage of using JOIN ON is: Mark for Review
(1) Points
The join happens automatically based on matching column names and data types
It will display rows that do not meet the join condition
It permits columns with different names to be joined (*)
It permits columns that don't have matching data types to be joined
Incorrect. Refer to Section 4
40. Evaluate this SELECT statement:
SELECT a.lname || ', ' || a.fname as "Patient", b.lname || ', ' || b.fname as
"Physician", c.admission
FROM patient a
JOIN physician b
ON (b.physician_id = c.physician_id);
JOIN admission c
ON (a.patient_id = c.patient_id);
Which clause generates an error?
Mark for Review
(1) Points
JOIN physician b
ON (b.physician_id = c.physician_id); (*)
JOIN admission c
ON (a.patient_id = c.patient_id)
Correct
Page 4 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. What should be included in a SELECT statement to return NULL values from all
tables? Mark for Review
(1) Points
natural joins
left outer joins
full outer joins (*)
right outer joins
Correct
42. You need to join the EMPLOYEE_HIST and EMPLOYEE tables. The EMPLOYEE_HIST
table will be the first table in the FROM clause. All the matched and unmatched
rows in the EMPLOYEE table need to be displayed. Which type of join will you use?
Mark for Review
(1) Points
a cross join
an inner join
a left outer join
a right outer join (*)
Correct
43. Which two sets of join keywords create a join that will include unmatched
rows from the first table specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
Incorrect. Refer to Section 4
Section 5 Lesson 1
(Answer all questions in this section)
44. What is the best explanation as to why this SQL statement will NOT execute?
SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
Mark for Review
(1) Points
Salaries cannot be averaged as not all the numbers will divide evenly.
You cannot use a column alias in the GROUP BY clause. (*)
The GROUP BY clause must have something to GROUP.
The department id is not listed in the departments table.
Correct
45. Evaluate this SELECT statement:
SELECT MAX(salary), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The highest salary for all employees.
The highest salary in each department. (*)
The employees with the highest salaries.
The employee with the highest salary for each department.
Correct
46. Which statement about group functions is true? Mark for Review
(1) Points
Group functions ignore null values. (*)
Group functions can only be used in a SELECT list.
Group functions can be used in a WHERE clause.
A query that includes a group function in the SELECT list must include a GROUP
BY clause.
Correct
47. Evaluate this SELECT statement:
SELECT MIN(hire_date), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEE table.
The latest hire date in the EMPLOYEE table.
The hire dates in the EMPLOYEE table that contain NULL values.
Correct
Section 5 Lesson 2
(Answer all questions in this section)
48. The CUSTOMER table contains these columns:
CUSTOMER_ID NUMBER(9)
FNAME VARCHAR2(25)
LNAME VARCHAR2(30)
CREDIT_LIMIT NUMBER (7,2)
CATEGORY VARCHAR2(20)
You need to calculate the average credit limit for all the customers in each
category. The average should be calculated based on all the rows in the table
excluding any customers who have not yet been assigned a credit limit value. Which
group function should you use to calculate this value?
Mark for Review
(1) Points
AVG (*)
SUM
COUNT
STDDEV
Correct
49. Group functions return a value for ________________ and ________________
null values in their computations. Mark for Review
(1) Points
a row set, ignore (*)
each row, ignore
a row set, include
each row, include
Incorrect. Refer to Section 5
50. You need to calculate the average salary of employees in each department.
Which group function will you use? Mark for Review
(1) Points
AVG (*)
MEAN
MEDIAN
AVERAGE
Correct
Page 5 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 5 Lesson 2
(Answer all questions in this section)
51. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(30)
PROD_CAT VARCHAR2(30)
PROD_PRICE NUMBER(3)
PROD_QTY NUMBER(4)
The following statement is issued:
SELECT AVG(prod_price, prod_qty)
FROM products;
What happens when this statement is issued?
Mark for Review
(1) Points
Both the average price and the average quantity of the products are returned.
Only the average quantity of the products is returned.
The values in the PROD_PRICE column and the PROD_QTY column are averaged
together.
An error occurs. (*)
Correct
52. The TRUCKS table contains these columns:
TRUCKS
TYPE VARCHAR2(30)
YEAR DATE
MODEL VARCHAR2(20)
PRICE NUMBER(10)
Which SELECT statement will return the average price for the 4x4 model?
Mark for Review
(1) Points
SELECT AVG (price) FROM trucks WHERE model = '4x4'; (*)
SELECT AVG (price) FROM trucks WHERE model IS '4x4';
SELECT AVG(price) FROM trucks WHERE model IS 4x4;
SELECT AVG(price), model FROM trucks WHERE model IS '4x4';
Correct
53. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January,
February and March of 2003. Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct
54. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(9,2)
HIRE_DATE DATE
BONUS NUMBER(7,2)
COMM_PCT NUMBER(4,2)
Which three functions could be used with the HIRE_DATE, LAST_NAME, or SALARY
columns? (Choose three.)
Mark for Review
(1) Points
(Choose all correct answers)
MAX (*)
SUM
AVG
MIN (*)
COUNT (*)
Correct
55. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
NAME VARCHAR2(30)
LOCATION_ID NUMBER
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
(Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT location_id, MIN(AVG(order_amount)) (*)
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
SALARY NUMBER(7,2)
DEPARTMENT_ID NUMBER(9)
You need to display the number of employees whose salary is greater than $50,000?
Which SELECT would you use?
Mark for Review
(1) Points
SELECT * FROM employees
WHERE salary > 50000;
SELECT * FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary < 50000;
SELECT COUNT(*) FROM employees
WHERE salary > 50000;
(*)
SELECT COUNT(*) FROM employees
WHERE salary > 50000
GROUP BY employee_id, last_name, first_name, salary, department_id;
Correct
57. Which statement about the COUNT function is true? Mark for Review
(1) Points
The COUNT function ignores duplicates by default.
The COUNT function always ignores null values by default. (*)
The COUNT function can be used to find the maximum value in each column.
The COUNT function can be used to determine the number of unique, non-null
values in a column.
Incorrect. Refer to Section 5
58. Evaluate this SQL statement:
SELECT COUNT (amount)
FROM inventory;
What will occur when the statement is issued?
Mark for Review
(1) Points
The statement will return the greatest value in the INVENTORY table.
The statement will return the total number of rows in the AMOUNT column.
The statement will replace all NULL values that exist in the AMOUNT column.
The statement will count the number of rows in the INVENTORY table where the
AMOUNT column is not null. (*)
Correct
59. Which SELECT statement will calculate the number of rows in the PRODUCTS
table? Mark for Review
(1) Points
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
Correct
Section 6 Lesson 1
(Answer all questions in this section)
60. The PLAYERS table contains these columns:
PLAYER_ID NUMBER PK
PLAYER_NAME VARCHAR2 (30)
TEAM_ID NUMBER
HIRE_DATE DATE
SALARY NUMBER (8,2)
Which two clauses represent valid uses of aggregate functions? (Choose three.)
Mark for Review
(1) Points
(Choose all correct answers)
ORDER BY AVG(salary)
GROUP BY MAX(salary) (*)
SELECT AVG(NVL(salary, 0)) (*)
HAVING MAX(salary) > 10000 (*)
WHERE hire_date > AVG(hire_date)
Incorrect. Refer to Section 6
Page 6 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. Evaluate this SELECT statement:
SELECT COUNT(emp_id), dept_id
FROM employee
GROUP BY dept_id;
You only want to include employees who earn more than 15000.
Which clause should you include in the SELECT statement?
Mark for Review
(1) Points
WHERE salary > 15000 (*)
HAVING salary > 15000
WHERE SUM(salary) > 15000
HAVING SUM(salary) > 15000
Incorrect. Refer to Section 6
62. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id
FROM employee
GROUP BY dept_id;
How are the results of this statement sorted?
Mark for Review
(1) Points
Ascending order by dept_id (*)
Descending order by dept_id
Ascending order by cumulative salary
Descending order by cumulative salary
Correct
63. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR(20)
PROD_CAT VARCHAR2(15)
PROD_PRICE NUMBER(5)
PROD_QTY NUMBER(4)
You need to identify the minimum product price in each product category.
Which statement could you use to accomplish this task?
Mark for Review
(1) Points
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_price;
SELECT prod_cat, MIN (prod_price)
FROM products
GROUP BY prod_cat;
(*)
SELECT MIN (prod_price), prod_cat
FROM products
GROUP BY MIN (prod_price), prod_cat;
SELECT prod_price, MIN (prod_cat)
FROM products
GROUP BY prod_cat;
Correct
64. Evaluate this statement:
SELECT department_id, AVG(salary)
FROM employees
WHERE job_id <> 69879
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000
ORDER BY department_id;
Which clauses restricts the result? Choose two.
Mark for Review
(1) Points
(Choose all correct answers)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Correct
65. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, mgr_id
FROM employee
GROUP BY dept_id, mgr_id;
Which SELECT statement clause allows you to restrict the rows returned, based on a
group function?
Mark for Review
(1) Points
HAVING SUM(salary) > 100000 (*)
WHERE SUM(salary) > 100000
WHERE salary > 100000
HAVING salary > 100000
Correct
66. The PLAYERS and TEAMS tables contain these columns:
PLAYERS
PLAYER_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
TEAM_ID NUMBER
POSITION VARCHAR2 (25)
TEAMS
TEAM_ID NUMBER NOT NULL, Primary Key
TEAM_NAME VARCHAR2 (25)
You need to create a report that lists the names of each team with more than five
pitchers.
Which SELECT statement will produce the desired result?
Mark for Review
(1) Points
SELECT t.team_name, COUNT(p.player_id)
FROM players p, teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name;
SELECT t.team_name, COUNT(p.player_id)
FROM players JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER' HAVING COUNT(p.player_id) > 5;
SELECT t.team_name, COUNT(p.player_id)
FROM players p, teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 5;
SELECT t.team_name, COUNT(p.player_id)
FROM players p JOIN teams t ON (p.team_id = t.team_id)
WHERE UPPER(p.position) = 'PITCHER'
GROUP BY t.team_name HAVING COUNT(p.player_id) > 5;
(*)
Correct
67. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER(9) PK
CATEGORY_ID VARCHAR2(10)
LOCATION_ID NUMBER(9)
DESCRIPTION VARCHAR2(30)
COST NUMBER(7,2)
PRICE NUMBER(7,2)
QUANTITY NUMBER
You display the total of the extended costs for each product category by location.
You need to include only the products that have a price less than $25.00. The
extended cost of each item equals the quantity value multiplied by the cost value.
Which SQL statement will display the desired result?
Mark for Review
(1) Points
SELECT category_id, SUM(cost * quantity) TOTAL,location_id
FROM products
WHERE price > 25.00
GROUP BY category_id, location_id;
SELECT SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY location_id;
SELECT category_id, SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY category_id, location_id;
(*)
SELECT SUM(cost * quantity) TOTAL
FROM products
WHERE price < 25.00;
Incorrect. Refer to Section 6
Section 6 Lesson 2
(Answer all questions in this section)
68. If you use the equality operator (=) with a subquery, how many values can
the subquery return? Mark for Review
(1) Points
only 1 (*)
up to 2
up to 5
unlimited
Correct
69. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use
subqueries? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id =
45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity >
0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity
> 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY
teacher_id);
Incorrect. Refer to Section 6
70. You need to display all the players whose salaries are greater than or equal
to John Brown's salary. Which comparison operator should you use? Mark for Review
(1) Points
>
<=
>= (*)
Correct
Page 7 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 2
(Answer all questions in this section)
71. You need to create a report to display the names of products with a cost
value greater than the average cost of all products. Which SELECT statement should
you use? Mark for Review
(1) Points
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost) FROM product);
(*)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
SELECT AVG(cost), product_name
FROM products
WHERE cost > AVG(cost)
GROUP by product_name;
SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
Correct
72. Which operator can be used with a multiple-row subquery? Mark for Review
(1) Points
IN (*)
<>
LIKE
Correct
Section 6 Lesson 3
(Answer all questions in this section)
73. If a single-row subquery returns a null value and uses the equality
comparison operator, what will the outer query return? Mark for Review
(1) Points
no rows (*)
all the rows in the table
a null value
an error
Correct
74. Examine the structure of the EMPLOYEE, DEPARTMENT, and ORDERS tables.
EMPLOYEE
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
DEPARTMENT
DEPARTMENT_ID NUMBER(9)
DEPARTMENT_NAME VARCHAR2(25)
CREATION_DATE DATE
ORDERS
ORDER_ID NUMBER(9)
EMPLOYEE_ID NUMBER(9)
DATE DATE
CUSTOMER_ID NUMBER(9)
You want to display all employees who had an order after the Sales department was
established. Which of the following constructs would you use?
Mark for Review
(1) Points
a group function
a single-row subquery (*)
the HAVING clause
a MERGE statement
Correct
75. Which comparison operator can only be used with a single-row subquery? Mark
for Review
(1) Points
ANY
ALL
<> (*)
IN
Correct
Section 6 Lesson 4
(Answer all questions in this section)
76. You need to display all the products that cost more than the maximum cost of
every product produced in Japan. Which multiple-row comparison operator could you
use? Mark for Review
(1) Points
>ANY (*)
NOT=ALL
IN
>IN
Incorrect. Refer to Section 6
77. Which statement about the ANY operator when used with a multiple-row
subquery is true? Mark for Review
(1) Points
The ANY operator compares every value returned by the subquery. (*)
The ANY operator can be used with the DISTINCT keyword.
The ANY operator is a synonym for the ALL operator.
The ANY operator can be used with the LIKE and IN operators.
Correct
78. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than
$30,000 and more than $50,000.
All employees who work in a department with employees who earn more than
$30,000, but less than $50,000. (*)
Correct
79. Evaluate the structure of the EMPLOYEE and DEPART_HIST tables:
EMPLOYEE:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
DEPART_HIST:
EMPLOYEE_ID NUMBER(9)
OLD_DEPT_ID NUMBER(9)
NEW_DEPT_ID NUMBER(9)
CHANGE_DATE DATE
You want to generate a list of employees who are in department 10, but used to be
in department 15.
Which query should you use?
Mark for Review
(1) Points
SELECT employee_id, emp_lname, emp_fname, dept_id
FROM employee
WHERE (employee_id, dept_id) IN
(SELECT employee_id, dept_id
FROM department_hist
WHERE dept_id = 15) AND dept_id = 10;
(*)
SELECT employee_id, emp_lname, emp_fname, dept_id
FROM employee
WHERE (employee_id) IN
(SELECT employee_id
FROM employee_hist
WHERE dept_id = 15);
SELECT employee_id, emp_lname, emp_fname, dept_id
FROM employee
WHERE (employee_id, dept_id) =
(SELECT employee_id, dept_id
FROM employee_hist
WHERE dept_id = 15);
SELECT employee_id, emp_lname, emp_fname, dept_id
FROM employee
WHERE (employee_id, dept_id) IN
(SELECT employee_id, dept_id
FROM employee
WHERE dept_id = 15);
Incorrect. Refer to Section 6
80. Evaluate this SELECT statement that includes a subquery:
SELECT last_name, first_name
FROM customer
WHERE area_code IN
(SELECT area_code FROM sales WHERE salesperson_id = 20);
Which statement is true about the given subquery?
Mark for Review
(1) Points
The outer query executes before the nested subquery.
The results of the inner query are returned to the outer query. (*)
An error occurs if the either the inner or outer queries do not return a value.
Both the inner and outer queries must return a value, or an error occurs.
Correct
Page 8 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. Evaluate this SELECT statement:
SELECT student_id, last_name, first_name
FROM student
WHERE major_id NOT IN
(SELECT major_id
FROM majors
WHERE department_head_id = 30 AND title = 'ADJUNCT');
What would happen if the inner query returned a NULL value row?
Mark for Review
(1) Points
A syntax error would be returned.
No rows would be returned from the STUDENT table. (*)
All the rows in the STUDENT table would be displayed.
Only the rows with STUDENT_ID values equal to NULL would be displayed.
Correct
82. Which comparison operator would you use to compare a value to every value
returned by a subquery? Mark for Review
(1) Points
SOME
ANY
ALL (*)
IN
Correct
83. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used.
(*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Correct
84. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT payment_date, customer_id, payment_amount
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_date >= '05-JAN-2002' OR payment_amount > 500.00);
Which change could correct the problem?
Mark for Review
(1) Points
Remove the subquery WHERE clause.
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Include the PAYMENT_ID column in the select list of the outer query.
Remove the single quotes around the date value in the inner query WHERE clause.
Correct
85. Examine the structures of the PARTS and MANUFACTURERS tables:
PARTS:
PARTS_ID VARCHAR2(25)
PK PARTS_NAME VARCHAR2(50)
MANUFACTURERS_ID NUMBER
COST NUMBER(5,2)
PRICE NUMBER(5,2)
MANUFACTURERS:
ID NUMBER
PK NAME VARCHAR2(30)
LOCATION VARCHAR2(20)
Which SQL statement correctly uses a subquery?
Mark for Review
(1) Points
UPDATE parts SET price = price * 1.15
WHERE manufacturers_id =
(SELECT id
FROM manufacturers
WHERE UPPER(location) IN('ATLANTA ', 'BOSTON ', 'DALLAS '));
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id !=
(SELECT id
FROM manufacturers
WHERE LOWER(name) = 'cost plus');
SELECT parts_name, price, cost
FROM parts
WHERE manufacturers_id IN
(SELECT id
FROM manufacturers m
JOIN part p ON (m.id = p.manufacturers_id));
(*)
SELECT parts_name
FROM
(SELECT AVG(cost)
FROM manufacturers)
WHERE cost > AVG(cost);
Correct
86. Evaluate this SELECT statement:
SELECT player_id, name
FROM players
WHERE team_id IN
(SELECT team_id
FROM teams
WHERE team_id > 300 AND salary_cap > 400000);
What would happen if the inner query returned a NULL value?
Mark for Review
(1) Points
No rows would be returned by the outer query. (*)
A syntax error in the outer query would be returned.
A syntax error in the inner query would be returned.
All the rows in the PLAYER table would be returned by the outer query.
Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. Which statement about the VALUES clause of an INSERT statement is true?
Mark for Review
(1) Points
If no column list is specified, then the values must be in the order the
columns are specified in the table. (*)
The VALUES clause in an INSERT statement is optional.
Character, date, and numeric data must be enclosed within single quotes in the
VALUES clause.
To specify a null value in the VALUES clause, use an empty string (' ').
Correct
88. The PRODUCTS table contains these columns:
PROD_ID NUMBER(4)
PROD_NAME VARCHAR2(25)
PROD_PRICE NUMBER(3)
You want to add the following row data to the PRODUCTS table:
(1) a NULL value in the PROD_ID column
(2) "6-foot nylon leash" in the PROD_NAME column
(3) "10" in the PROD_PRICE column
You issue this statement:
INSERT INTO products
VALUES (null,'6-foot nylon leash', 10);
What row data did you add to the table?
Mark for Review
(1) Points
The row was created with the correct data in all three columns. (*)
The row was created with the correct data in two of three columns.
The row was created with the correct data in one of the three columns.
The row was created completely wrong. No data ended up in the correct columns.
Correct
89. Using the INSERT statement, and assuming that a column can accept null
values, how can you implicitly insert a null value in a column? Mark for Review
(1) Points
Use the NULL keyword.
Use the ON clause
Omit the column in the column list. (*)
It is not possible to implicitly insert a null value in a column.
Correct
90. You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table.
What could you use in the INSERT statement to accomplish this task? Mark for
Review
(1) Points
an ON clause
a SET clause
a subquery (*)
a function
Incorrect. Refer to Section 7
Page 9 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 7 Lesson 2
(Answer all questions in this section)
91. What would happen if you issued a DELETE statement without a WHERE clause?
Mark for Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
Correct
92. When the WHERE clause is missing in a DELETE statement, what is the result?
Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Correct
93. Which two commands can be used to modify existing data in a database row?
Mark for Review
(1) Points
(Choose all correct answers)
DELETE
INSERT (*)
SELECT
UPDATE (*)
Correct
94. You need to remove a row from the EMPLOYEE table. Which statement would you
use? Mark for Review
(1) Points
UPDATE with a WHERE clause
INSERT with a WHERE clause
DELETE with a WHERE clause (*)
MERGE with a WHERE clause
Correct
95. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the
EMPLOYEE table using one UPDATE statement. Which clause should you include in the
UPDATE statement to update multiple columns? Mark for Review
(1) Points
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
Correct
96. You need to update the expiration date of products manufactured before June
30th . In which clause of the UPDATE statement will you specify this condition?
Mark for Review
(1) Points
the ON clause
the WHERE clause (*)
the SET clause
the USING clause
Incorrect. Refer to Section 7
97. The PLAYERS table contains these columns:
PLAYER_ID NUMBER NOT NULL
PLAYER_LNAME VARCHAR2(20) NOT NULL
PLAYER_FNAME VARCHAR2(10) NOT NULL
TEAM_ID NUMBER
SALARY NUMBER(9,2)
You need to increase the salary of each player for all players on the Tiger team by
12.5 percent. The TEAM_ID value for the Tiger team is 5960. Which statement should
you use?
Mark for Review
(1) Points
UPDATE players (salary) SET salary = salary * 1.125;
UPDATE players SET salary = salary * .125 WHERE team_id = 5960;
UPDATE players SET salary = salary * 1.125 WHERE team_id = 5960; (*)
UPDATE players (salary) VALUES(salary * 1.125) WHERE team_id = 5960;
Correct
98. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta.
Which script should you use?
Mark for Review
(1) Points
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
(*)
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
DELETE FROM products
WHERE supplier_id =
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ALANTA');
Correct
99. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5)
NAME VARCHAR2(25)
SUBJECT_ID NUMBER(5)
HIRE_DATE DATE
SALARY NUMBER(9,2)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER(5)
TEACHER_ID NUMBER(5)
START_DATE DATE
MAX_CAPACITY NUMBER(3)
Which scenario would require a subquery to return the desired results?
Mark for Review
(1) Points
You need to display the start date for each class taught by a given teacher.
You need to create a report to display the teachers who were hired more than
five years ago.
You need to display the names of the teachers who teach classes that start
within the next week.
You need to create a report to display the teachers who teach more classes than
the average number of classes taught by each teacher. (*)
Incorrect. Refer to Section 7
100. One of the sales representatives, Janet Roper, has informed you that she
was recently married, and she has requested that you update her name in the
employee database. Her new last name is Cooper. Janet is the only person with the
last name of Roper that is employed by the company. The EMPLOYEES table contains
these columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
Correct
Page 10 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. The PRICE table contains this data:
PRODUCT_ID MANUFACTURER_ID
86950 59604
You query the database and return the value 95. Which script did you use?
Mark for Review
(1) Points
SELECT SUBSTR(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
(*)
SELECT LENGTH(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
SELECT SUBSTR(product_id, -1, 3)
FROM price
WHERE manufacturer_id = 59604;
SELECT TRIM(product_id, -3, 2)
FROM price
WHERE manufacturer_id = 59604;
Correct
2. Which SQL function can be used to remove heading or trailing characters (or
both) from a character string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
Incorrect. Refer to Section 1
3. Which SQL function is used to return the position where a specific character
string begins within a larger character string? Mark for Review
(1) Points
CONCAT
INSTR (*)
LENGTH
SUBSTR
Incorrect. Refer to Section 1
4. You query the database with this SQL statement:
SELECT CONCAT(last_name, (SUBSTR(LOWER(first_name), 4))) "Default Password"
FROM employees;
Which function will be evaluated first?
Mark for Review
(1) Points
CONCAT
SUBSTR
LOWER (*)
All three will be evaluated simultaneously.
Incorrect. Refer to Section 1
5. You need to display each employee's name in all uppercase letters. Which
function should you use? Mark for Review
(1) Points
CASE
UCASE
UPPER (*)
TOUPPER
Incorrect. Refer to Section 1
6. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 12.00
You query the database and return the value 79. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
(*)
Incorrect. Refer to Section 1
7. What will the following SQL statemtent display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value,
size of 15 and the column labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of
the decimal and the column labeled SALARY.
The last name and salary for all employees with the format of the salary 15
characters long, left-padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where
expected."
Incorrect. Refer to Section 1
Section 1 Lesson 2
(Answer all questions in this section)
8. Which two functions can be used to manipulate number or date column values,
but NOT character column values? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
Incorrect. Refer to Section 1
9. You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
Mark for Review
(1) Points
1200
1282
1282.25
1300 (*)
Incorrect. Refer to Section 1
10. Evaluate this function: MOD (25, 2) Which value is returned? Mark for
Review
(1) Points
1 (*)
25
Correct
Page 1 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1 Lesson 3
(Answer all questions in this section)
11. Which of the following Date Functions will add calendar months to a date?
Mark for Review
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Incorrect. Refer to Section 1
12. Which function would you use to return the current database server date and
time? Mark for Review
(1) Points
DATE
SYSDATE (*)
DATETIME
CURRENTDATE
Incorrect. Refer to Section 1
13. Which SELECT statement will return a numeric value? Mark for Review
(1) Points
SELECT SYSDATE + 600 / 24
FROM employee;
SELECT ROUND(hire_date, DAY)
FROM employee;
SELECT (SYSDATE - hire_date) / 7
FROM employee;
(*)
SELECT SYSDATE - 7
FROM employee;
Incorrect. Refer to Section 1
14. You need to subtract three months from the current date. Which function
should you use? Mark for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Incorrect. Refer to Section 1
15. Which SELECT statement will NOT return a date value? Mark for Review
(1) Points
SELECT (30 + hire_date) + 1440/24
FROM employees;
SELECT (SYSDATE - hire_date) + 10*8
FROM employees;
(*)
SELECT SYSDATE - TO_DATE('25-JUN-02') + hire_date
FROM employees;
SELECT (hire_date - SYSDATE) + TO_DATE('25-JUN-02')
FROM employees;
Incorrect. Refer to Section 1
Section 2 Lesson 1
(Answer all questions in this section)
16. Which statement concerning single row functions is true? Mark for Review
(1) Points
Single row functions can accept only one argument, but can return multiple
values.
Single row functions cannot modify a data type.
Single row functions can be nested. (*)
Single row functions return one or more results per row.
Incorrect. Refer to Section 2
17. Which two statements concerning SQL functions are true? (Choose two.) Mark
for Review
(1) Points
(Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type.
(*)
Single-row functions manipulate groups of rows to return one result per group
of rows.
Incorrect. Refer to Section 2
18. Which three statements concerning explicit data type conversions are true?
(Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
Use the TO_NUMBER function to convert a number to a character string.
Use the TO_DATE function to convert a character string to a date value. (*)
Use the TO_NUMBER function to convert a character string of digits to a number.
(*)
Use the TO_DATE function to convert a date value to character string or number.
Use the TO_CHAR function to convert a number or date value to character string.
(*)
Incorrect. Refer to Section 2
19. Which arithmetic operation will return a numeric value? Mark for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
SYSDATE + 30 / 24
Correct
20. If you use the RR format when writing a query using the date 27-OCT-17 and
the year is 2001, what year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Incorrect. Refer to Section 2
Page 2 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 2 Lesson 1
(Answer all questions in this section)
21. All Human Resources data is stored in a table named EMPLOYEES. You have been
asked to create a report that displays each employee's name and salary. Each
employee's salary must be displayed in the following format: $000,000.00. Which
function should you include in a SELECT statement to achieve the desired result?
Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Correct
Section 2 Lesson 2
(Answer all questions in this section)
22. The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
SELECT NVL(10 / price, '0')
FROM PRODUCT;
What would happen if the PRICE column contains null values?
Mark for Review
(1) Points
The statement would fail because values cannot be divided by 0.
A value of 0 would be displayed. (*)
A value of 10 would be displayed.
The statement would fail because values cannot be divided by null.
Incorrect. Refer to Section 2
23. Which of the following General Functions will return the first non-null
expression in the expression list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
COALESCE (*)
Incorrect. Refer to Section 2
24. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
Evaluate this SELECT statement:
SELECT style_id, style_name, category, cost
FROM styles
WHERE style_name LIKE 'SANDAL' AND NVL(cost, 0) < 15.00
ORDER BY category, cost;
Which result will the query provide?
Mark for Review
(1) Points
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
869506 SANDAL 89690 15.00
STYLE_ID STYLE_NAME CATEGORY COST
968950 SANDAL 85909 10.00
895840 SANDAL 85940 12.00
758960 SANDAL 86979
(*)
Incorrect. Refer to Section 2
Section 3 Lesson 2
(Answer all questions in this section)
25. The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
Which result will this statement provide?
Mark for Review
(1) Points
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID
values (*)
A report containing each patient's id value and their doctor's id value
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
A syntax error
Correct
26. Your have two tables named EMPLOYEES and SALES. You want to identify the
sales representatives who have generated at least $100,000 in revenue.
Which query should you issue? Mark for Review
(1) Points
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
(*)
SELECT e.fname, e.lname, s.sales
FROM employees, sales
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
SELECT fname, lname, sales
Q FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
Incorrect. Refer to Section 3
27. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
Incorrect. Refer to Section 3
28. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all
possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Correct
29. When joining 3 tables in a SELECT statement, how many join conditions are
needed in the WHERE clause? Mark for Review
(1) Points
2 (*)
Incorrect. Refer to Section 3
30. Your company stores its business information in an Oracle9i database. The
EMPLOYEES table includes the following columns:
EMP_ID NUMBER(5) NOT NULL PRIMARY KEY
FNAME VARCHAR2(25)
LNAME VARCHAR2(25)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(25)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
DEPT_ID NUMBER(5) NOT NULL FOREIGN KEY
The BONUS table includes the following columns:
BONUS_ID NUMBER(5) NOT NULL PRIMARY KEY
ANNUAL_SALARY NUMBER(10)
BONUS_PCT NUMBER(3, 2)
EMP_ID VARCHAR2(5) NOT NULL FOREIGN KEY
You want to determine the amount of each employee's bonus. Which of the following
queries should you issue?
Mark for Review
(1) Points
SELECT e.fname, e.lname, b.annual_salary * b. bonus_pct
FROM employees e, bonus b
WHERE e.emp_id = b.emp_id;
(*)
SELECT e.fname, e.lname, b.annual_salary, b. bonus_pct
FROM employees e, bonus b
WHERE e.emp_id = b.emp_id;
SELECT e.fname, e.lname, b.annual_salary, b. bonus_pct
FROM employees, bonus
WHERE e.emp_id = b.emp_id;
SELECT fname, lname, annual_salary * bonus_pct
FROM employees, bonus NATURAL JOIN;
Correct
Page 3 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 3 Lesson 4
(Answer all questions in this section)
31. Which of the following best describes the function of an outer join? Mark
for Review
(1) Points
An outer join will return only those rows that do not meet the join criteria.
An outer join will return only data from the far left column in one table and
the far right column in the other table.
An outer join will return data only if both tables contain an identical pair of
columns.
An outer join will return all rows that meet the join criteria and will return
NULL values from one table if no rows from the other table satisfy the join
criteria. (*)
Incorrect. Refer to Section 3
32. Evaluate this SELECT statement:
SELECT p.player_id, m.last_name, m.first_name, t.team_name
FROM player p
LEFT OUTER JOIN player m ON (p.manager_id = m.player_id)
LEFT OUTER JOIN team t ON (p.team_id = t.team_id);
Which join is evaluated first?
Mark for Review
(1) Points
the self-join of the player table (*)
the join between the player table and the team table on TEAM_ID
the join between the player table and the team table on MANAGER_ID
the join between the player table and the team table on PLAYER_ID
Correct
33. Which two operators can be used in an outer join condition using the outer
join operator (+)? Mark for Review
(1) Points
AND and = (*)
OR and =
BETWEEN...AND... and IN
IN and =
Correct
Section 4 Lesson 2
(Answer all questions in this section)
34. Which of the following best describes a natural join? Mark for Review
(1) Points
A join between two tables that includes columns that share the same name,
datatypes and lengths (*)
A join that produces a Cartesian product
A join between tables where matching fields do not exist
A join that uses only one table
Correct
35. You need to join all the rows in the EMPLOYEE table to all the rows in the
EMP_REFERENCE table. Which type of join should you create? Mark for Review
(1) Points
An equijoin
A cross join (*)
An inner join
A full outer join
Incorrect. Refer to Section 4
36. Which statement about a natural join is true? Mark for Review
(1) Points
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and datatype. (*)
Columns with the same names must have compatible data types.
Columns with the same names cannot be included in the SELECT list of the query.
Incorrect. Refer to Section 4
Section 4 Lesson 3
(Answer all questions in this section)
37. For which condition would you use an equijoin query with the USING keyword?
Mark for Review
(1) Points
You need to perform a join of the CUSTOMER and ORDER tables but limit the
number of columns in the join condition. (*)
The ORDER table contains a column that has a referential constraint to a column
in the PRODUCT table.
The CUSTOMER and ORDER tables have no columns with identical names.
The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The CUST_ID
column in the ORDER table contains null values that need to be displayed.
Correct
38. Which SELECT clause creates an equijoin by specifying a column name common
to both tables? Mark for Review
(1) Points
A HAVING clause
The FROM clause
The SELECT clause
A USING clause (*)
Incorrect. Refer to Section 4
39. The primary advantage of using JOIN ON is: Mark for Review
(1) Points
The join happens automatically based on matching column names and data types
It will display rows that do not meet the join condition
It permits columns with different names to be joined (*)
It permits columns that don't have matching data types to be joined
Incorrect. Refer to Section 4
40. You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE
statements in sequence:
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information about
orders placed by customers who reside in Nashville . Which query should you issue
to achieve the desired results?
Mark for Review
(1) Points
SELECT custid, companyname
FROM customers
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
(*)
SELECT orderid, orderdate, total
FROM orders
WHERE city = 'Nashville';
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. Which query represents the correct syntax for a left outer join? Mark for
Review
(1) Points
SELECT companyname, orderdate, total
FROM customers c
LEFT JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
OUTER JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER JOIN orders o ON c.cust_id = o.cust_id;
(*)
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER JOIN orders o
ON c.cust_id = o.cust_id;
Incorrect. Refer to Section 4
42. Which two sets of join keywords create a join that will include unmatched
rows from the first table specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
Correct
43. Which type of join returns rows from one table that have NO direct match in
the other table? Mark for Review
(1) Points
equijoin
self join
outer join (*)
natural join
Incorrect. Refer to Section 4
Section 5 Lesson 1
(Answer all questions in this section)
44. Group functions can be nested to a depth of? Mark for Review
(1) Points
three
four
two (*)
Group functions cannot be nested.
Incorrect. Refer to Section 5
45. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
The first column listed in the GROUP BY clause is the most major grouping. (*)
The last column listed in the GROUP BY clause is the most major grouping.
The GROUP BY clause can contain an aggregate function.
A GROUP BY clause cannot be used without an ORDER BY clause.
Correct
46. Evaluate this SELECT statement:
SELECT MIN(hire_date), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEE table.
The latest hire date in the EMPLOYEE table.
The hire dates in the EMPLOYEE table that contain NULL values.
Correct
47. Which statement about group functions is true? Mark for Review
(1) Points
Group functions ignore null values. (*)
Group functions can only be used in a SELECT list.
Group functions can be used in a WHERE clause.
A query that includes a group function in the SELECT list must include a GROUP
BY clause.
Correct
Section 5 Lesson 2
(Answer all questions in this section)
48. You need to calculate the standard deviation for the cost of products
produced in the Birmingham facility. Which group function will you use? Mark for
Review
(1) Points
STDEV
STDDEV (*)
VAR_SAMP
VARIANCE
Incorrect. Refer to Section 5
49. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January,
February and March of 2003. Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct
50. Which aggregate function can be used on a column of the DATE data type?
Mark for Review
(1) Points
AVG
MAX (*)
STDDEV
SUM
Incorrect. Refer to Section 5
Page 5 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 5 Lesson 2
(Answer all questions in this section)
51. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
NAME VARCHAR2(30)
LOCATION_ID NUMBER
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
(Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT location_id, MIN(AVG(order_amount)) (*)
Incorrect. Refer to Section 5
52. Which group function would you use to display the total of all salary values
in the EMPLOYEE table? Mark for Review
(1) Points
SUM (*)
AVG
COUNT
MAX
Correct
53. You need to compute the total salary for all employees in department 10.
Which group function will you use? Mark for Review
(1) Points
MAX
SUM (*)
VARIANCE
COUNT
Incorrect. Refer to Section 5
54. The CUSTOMER table contains these columns:
CUSTOMER_ID NUMBER(9)
FNAME VARCHAR2(25)
LNAME VARCHAR2(30)
CREDIT_LIMIT NUMBER (7,2)
CATEGORY VARCHAR2(20)
You need to calculate the average credit limit for all the customers in each
category. The average should be calculated based on all the rows in the table
excluding any customers who have not yet been assigned a credit limit value. Which
group function should you use to calculate this value?
Mark for Review
(1) Points
AVG (*)
SUM
COUNT
STDDEV
Correct
55. The AVG, SUM, VARIANCE, and STDDEV functions can be used with which of the
following? Mark for Review
(1) Points
Only numeric data types (*)
Integers only
Any data type
All except numeric
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56. Which SELECT statement will calculate the number of rows in the PRODUCTS
table? Mark for Review
(1) Points
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
Incorrect. Refer to Section 5
57. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did
you execute?
Mark for Review
(1) Points
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_item;
Incorrect. Refer to Section 5
58. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
You issue this SELECT statement:
SELECT COUNT(category)
FROM styles;
Which value is displayed?
Mark for Review
(1) Points
7 (*)
The statement will NOT execute successfully.
Incorrect. Refer to Section 5
59. Evaluate this SQL statement:
SELECT COUNT (amount)
FROM inventory;
What will occur when the statement is issued?
Mark for Review
(1) Points
The statement will return the greatest value in the INVENTORY table.
The statement will return the total number of rows in the AMOUNT column.
The statement will replace all NULL values that exist in the AMOUNT column.
The statement will count the number of rows in the INVENTORY table where the
AMOUNT column is not null. (*)
Incorrect. Refer to Section 5
Section 6 Lesson 1
(Answer all questions in this section)
60. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER(9) PK
CATEGORY_ID VARCHAR2(10)
LOCATION_ID NUMBER(9)
DESCRIPTION VARCHAR2(30)
COST NUMBER(7,2)
PRICE NUMBER(7,2)
QUANTITY NUMBER
You display the total of the extended costs for each product category by location.
You need to include only the products that have a price less than $25.00. The
extended cost of each item equals the quantity value multiplied by the cost value.
Which SQL statement will display the desired result?
Mark for Review
(1) Points
SELECT category_id, SUM(cost * quantity) TOTAL,location_id
FROM products
WHERE price > 25.00
GROUP BY category_id, location_id;
SELECT SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY location_id;
SELECT category_id, SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY category_id, location_id;
(*)
SELECT SUM(cost * quantity) TOTAL
FROM products
WHERE price < 25.00;
Incorrect. Refer to Section 6
Page 6 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. You want to write a report that returns the average salary of all employees
in the company, sorted by departments. The EMPLOYEES table contains the following
columns:
EMPLOYEES:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which SELECT statement will return the information that you require?
Mark for Review
(1) Points
SELECT salary (AVG)
FROM employees
GROUP BY dept;
SELECT AVG (salary)
FROM employees
GROUP BY dept;
(*)
SELECT AVG (salary)
FROM employees
BY dept;
SELECT AVG salary
FROM employees
BY dept;
Incorrect. Refer to Section 6
62. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you
use should a WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
Correct
63. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
Mark for Review
(1) Points
SELECT
FROM
WHERE
GROUP BY (*)
Incorrect. Refer to Section 6
64. Evaluate this statement:
SELECT department_id, AVG(salary)
FROM employees
WHERE job_id <> 69879
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000
ORDER BY department_id;
Which clauses restricts the result? Choose two.
Mark for Review
(1) Points
(Choose all correct answers)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Incorrect. Refer to Section 6
65. The EMPLOYEES table contains the following columns:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
You want to create a report that includes each employee's last name, employee
identification number, date of hire and salary. The report should include only
those employees who have been with the company for more than one year and whose
salary exceeds $40,000.
Which of the following SELECT statements will accomplish this task?
Mark for Review
(1) Points
SELECT emp_id, lname, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT emp_id, lname, hire_date, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT emp_id, lname, hire_date, salary
FROM employees
WHERE salary > 40000
AND (sysdate-hire_date) / 365 > 1;
(*)
SELECT emp_id, lname, salary
FROM employees
WHERE salary > 40000
AND hire_date IN (sysdate-hire_date) / 365 > 1);
Incorrect. Refer to Section 6
66. Evaluate this SELECT statement:
SELECT COUNT(emp_id), dept_id
FROM employee
GROUP BY dept_id;
You only want to include employees who earn more than 15000.
Which clause should you include in the SELECT statement?
Mark for Review
(1) Points
WHERE salary > 15000 (*)
HAVING salary > 15000
WHERE SUM(salary) > 15000
HAVING SUM(salary) > 15000
Correct
67. What is the correct order of clauses in a SELECT statement? Mark for Review
(1) Points
SELECT
FROM
WHERE
ORDER BY
HAVING
SELECT
FROM
HAVING
GROUP BY
WHERE
ORDER BY
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
(*)
SELECT
FROM
WHERE
HAVING
ORDER BY
GROUP BY
Incorrect. Refer to Section 6
Section 6 Lesson 2
(Answer all questions in this section)
68. Using a subquery in which clause will return a syntax error? Mark for
Review
(1) Points
WHERE
FROM
HAVING
There are no places you cannot place subqueries. (*)
Incorrect. Refer to Section 6
69. Which statement about subqueries is true? Mark for Review
(1) Points
Subqueries should be enclosed in double quotation marks.
Subqueries cannot contain group functions.
Subqueries are often used in a WHERE clause to return values for an unknown
conditional value. (*)
Subqueries generally execute last, after the main or outer query executes.
Incorrect. Refer to Section 6
70. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use
subqueries? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id =
45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity >
0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity
> 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY
teacher_id);
Incorrect. Refer to Section 6
Page 7 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 2
(Answer all questions in this section)
71. You need to create a report to display the names of products with a cost
value greater than the average cost of all products. Which SELECT statement should
you use? Mark for Review
(1) Points
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost) FROM product);
(*)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
SELECT AVG(cost), product_name
FROM products
WHERE cost > AVG(cost)
GROUP by product_name;
SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
Correct
72. Which operator can be used with a multiple-row subquery? Mark for Review
(1) Points
IN (*)
<>
LIKE
Correct
Section 6 Lesson 3
(Answer all questions in this section)
73. If a single-row subquery returns a null value and uses the equality
comparison operator, what will the outer query return? Mark for Review
(1) Points
no rows (*)
all the rows in the table
a null value
an error
Correct
74. Which comparison operator can only be used with a single-row subquery? Mark
for Review
(1) Points
ANY
ALL
<> (*)
IN
Incorrect. Refer to Section 6
75. Which statement about the <> operator is true? Mark for Review
(1) Points
The <> operator is NOT a valid SQL operator.
The <> operator CANNOT be used in a single-row subquery.
The <> operator returns the same result as the ANY operator in a subquery.
The <> operator can be used when a single-row subquery returns only one row.
(*)
Incorrect. Refer to Section 6
Section 6 Lesson 4
(Answer all questions in this section)
76. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used.
(*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Incorrect. Refer to Section 6
77. Evaluate this SELECT statement:
SELECT customer_id, name
FROM customer
WHERE customer_id IN
(SELECT customer_id
FROM customer
WHERE state_id = 'GA' AND credit_limit > 500.00);
What would happen if the inner query returned null?
Mark for Review
(1) Points
An error would be returned.
No rows would be returned by the outer query. (*)
All the rows in the table would be selected.
Only the rows with CUSTOMER_ID values equal to null would be selected.
Incorrect. Refer to Section 6
78. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than
$30,000 and more than $50,000.
All employees who work in a department with employees who earn more than
$30,000, but less than $50,000. (*)
Incorrect. Refer to Section 6
79. Which of the following best describes the meaning of the ANY operator? Mark
for Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
Equal to each value in the list
Incorrect. Refer to Section 6
80. You are looking for Executive information using a subquery. What will the
following SQL statement display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id
FROM departments
WHERE department_name = 'Executive');
Mark for Review
(1) Points
The department ID, department name and last name for every employee in the
Executive department.
The department ID, last name, department name for every Executive in the
employees table.
The department ID, last name, job ID from departments for Executive employees.
The department ID, last name, job ID for every employee in the Executive
department. (*)
Incorrect. Refer to Section 6
Page 8 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. Which statement about the ANY operator when used with a multiple-row
subquery is true? Mark for Review
(1) Points
The ANY operator compares every value returned by the subquery. (*)
The ANY operator can be used with the DISTINCT keyword.
The ANY operator is a synonym for the ALL operator.
The ANY operator can be used with the LIKE and IN operators.
Correct
82. Which comparison operator would you use to compare a value to every value
returned by a subquery? Mark for Review
(1) Points
SOME
ANY
ALL (*)
IN
Incorrect. Refer to Section 6
83. A multiple-row operator expects how many values? Mark for Review
(1) Points
One or more (*)
Only one
Two or more
None
Correct
84. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT customer_id, payment_type
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
Mark for Review
(1) Points
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
Change the comparison operator to a single-row operator.
Correct
85. Which statement about single-row and multiple-row subqueries is true? Mark
for Review
(1) Points
Multiple-row subqueries cannot be used with the LIKE operator. (*)
Single-row operators can be used with both single-row and multiple-row
subqueries.
Multiple-row subqueries can be used with both single-row and multiple-row
operators.
Multiple-row subqueries can only be used in SELECT statements.
Correct
86. What would happen if you attempted to use a single-row operator with a
multiple-row subquery? Mark for Review
(1) Points
An error would be returned. (*)
No rows will be selected.
All the rows will be selected.
The data returned may or may not be correct.
Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table.
What could you use in the INSERT statement to accomplish this task? Mark for
Review
(1) Points
an ON clause
a SET clause
a subquery (*)
a function
Incorrect. Refer to Section 7
88. The STUDENTS table contains these columns:
STU_ID NUMBER(9) NOT NULL
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
DOB DATE
STU_TYPE_ID VARCHAR2(1) NOT NULL
ENROLL_DATE DATE
You create another table, named FT_STUDENTS, with an identical structure.You want
to insert all full-time students, who have a STU_TYPE_ID value of "F", into the new
table. You execute this INSERT statement:
INSERT INTO ft_students
(SELECT stu_id, last_name, first_name, dob, stu_type_id, enroll_date
FROM students
WHERE UPPER(stu_type_id) = 'F');
What is the result of executing this INSERT statement?
Mark for Review
(1) Points
All full-time students are inserted into the FT_STUDENTS table. (*)
An error occurs because the FT_STUDENTS table already exists.
An error occurs because you CANNOT use a subquery in an INSERT statement.
An error occurs because the INSERT statement does NOT contain a VALUES clause.
Correct
89. You need to add a row to an existing table. Which DML statement should you
use? Mark for Review
(1) Points
UPDATE
INSERT (*)
DELETE
CREATE
Incorrect. Refer to Section 7
90. Using the INSERT statement, and assuming that a column can accept null
values, how can you implicitly insert a null value in a column? Mark for Review
(1) Points
Use the NULL keyword.
Use the ON clause
Omit the column in the column list. (*)
It is not possible to implicitly insert a null value in a column.
Incorrect. Refer to Section 7
Page 9 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 7 Lesson 2
(Answer all questions in this section)
91. The EMPLOYEES table contains the following columns:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You need to increase the salary for all employees in department 10 by 10 percent.
You also need to increase the bonus for all employees in department 10 by 15
percent. Which statement should you use?
Mark for Review
(1) Points
UPDATE employees
SET salary = salary * 1.10, bonus = bonus * 1.15
WHERE dept = 10;
(*)
UPDATE employees
SET salary = salary * 1.10 AND bonus = bonus * 1.15
WHERE dept = 10;
UPDATE employees
SET (salary = salary * 1.10) SET (bonus = bonus * 1.15)
WHERE dept = 10;
UPDATE employees
SET salary = salary * .10, bonus = bonus * .15
WHERE dept = 10;
Correct
92. The EMPLOYEES table contains the following columns:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in
department 10 to equal the new salary of employee number 89898. Currently, all
employees in department 10 have the same salary value. Which statement should you
execute?
Mark for Review
(1) Points
UPDATE employee
SET salary = SELECT salary
FROM employee
WHERE emp_id = 89898;
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898);
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898)
WHERE dept = 10;
(*)
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10);
Incorrect. Refer to Section 7
93. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta.
Which script should you use?
Mark for Review
(1) Points
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
(*)
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
DELETE FROM products
WHERE supplier_id =
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ALANTA');
Correct
94. One of the sales representatives, Janet Roper, has informed you that she was
recently married, and she has requested that you update her name in the employee
database. Her new last name is Cooper. Janet is the only person with the last name
of Roper that is employed by the company. The EMPLOYEES table contains these
columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
Correct
95. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the
EMPLOYEE table using one UPDATE statement. Which clause should you include in the
UPDATE statement to update multiple columns? Mark for Review
(1) Points
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
Incorrect. Refer to Section 7
96. Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
Mark for Review
(1) Points
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner
(*)
To display each player, their manager, and their team name for all teams with a
id value greater than 5000
Incorrect. Refer to Section 7
97. What would happen if you issued a DELETE statement without a WHERE clause?
Mark for Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
Correct
98. When the WHERE clause is missing in a DELETE statement, what is the result?
Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Correct
99. You want to enter a new record into the CUSTOMERS table. Which two commands
can be used to create new rows? Mark for Review
(1) Points
INSERT, CREATE
MERGE, CREATE
INSERT, MERGE (*)
INSERT, UPDATE
Incorrect. Refer to Section 7
100. One of your employees was recently married. Her employee ID is still 189,
however, her last name is now Rockefeller. Which SQL statement will allow you to
reflect this change? Mark for Review
(1) Points
INSERT INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189; (*)
Incorrect. Refer to Section 7
Page 10 of 10
Incorrect. Refer to Section 4
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 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));
Incorrect. Refer to Section 8
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));
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct
3. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct
4. Which statement about table and column names is true? Mark for Review
(1) Points
Table and column names must begin with a letter. (*)
1. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
4 (*)
Incorrect. Refer to Section 8
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));
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Incorrect. Refer to Section 8
3. 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));
Correct
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
Correct
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.
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
Section 8 Lesson 2
(Answer all questions in this section)
6. 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 (*)
Correct
7. 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
8. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Correct
9. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
10. 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
Correct
11. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct
12. 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
Correct
Section 8 Lesson 3
(Answer all questions in this section)
13. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Correct
14. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
ALTER TABLE teams REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Incorrect. Refer to Section 8 Lesson 3
15. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
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
Incorrect. Refer to Section 8 Lesson 3
17. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct
18. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Correct
19. Examine the structure of the DONATIONS table.
DONATIONS:
PLEDGE_ID NUMBER
DONOR_ID NUMBER
PLEDGE_DT DATE
AMOUNT_PLEDGED NUMBER (7,2)
AMOUNT_PAID NUMBER (7,2)
PAYMENT_DT DATE
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
You CANNOT decrease the width of the AMOUNT_PLEDGED column.
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.
Incorrect. Refer to Section 8 Lesson 3
20. Which statement about a column is NOT true? Mark for Review
(1) Points
You can increase the width of a CHAR column.
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.
You can decrease the width of a VARCHAR2 column.
Incorrect. Refer to Section 8 Lesson 3
21. 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.
Incorrect. Refer to Section 8
22. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
23. 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. (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. 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
25. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
address VARCHAR2(25),
city VARCHAR2(25),
region VARCHAR2(25),
postal_code VARCHAR2(11),
CONSTRAINT customer_id_un UNIQUE(customer_id),
CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct
26. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
10
You can have as many NOT NULL constraints as you have columns in your table.
(*)
Correct
27. 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
28. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Correct
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE);
(*)
Correct
31. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
9
Correct
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
Correct
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
ON DELETE SET NULL
Incorrect. Refer to Section 9
34. How many PRIMARY KEY constraints can be created for each table? Mark for
Review
(1) Points
none
one and only one (*)
one or two
unlimited
Correct
35. 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
Correct
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. (*)
Incorrect. Refer to Section 9
37. 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.
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
39. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Correct
40. 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 (*)
ENABLE
Correct
41. 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
42. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct
43. 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;
Correct
44. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
Incorrect. Refer to Section 9
45. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Incorrect. Refer to Section 9
46. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Incorrect. Refer to Section 9
47. 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
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
WITH READ ONLY
Correct
49. 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
50. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Correct
51. 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
52. The FACULTY table contains these columns:
FACULTYID VARCHAR2(5) NOT NULL PRIMARY KEY
FIRST_NAME VARCHAR2(20)
LAST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
STATUS VARCHAR2(2) NOT NULL
The COURSE table contains these columns:
COURSEID VARCHAR2(5) NOT NULL PRIMARY KEY
SUBJECT VARCHAR2(5)
TERM VARCHAR2(6
FACULTYID VARCHAR2(5) NOT NULL FOREIGN KEY
You have been asked to compile a report that identifies all adjunct professors who
will be teaching classes in the upcoming term. You want to create a view that will
simplify the creation of this report. Which CREATE VIEW statements will accomplish
this task?
Mark for Review
(1) Points
CREATE VIEW
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty, course
WHERE facultyid = facultyid);
CREATE VIEW pt_view ON
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f and course c
WHERE f.facultyid = c.facultyid);
CREATE VIEW pt_view IN
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty course);
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
(*)
Incorrect. Refer to Section 10
53. 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
54. Which statement about the CREATE VIEW statement is false? Mark for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Incorrect. Refer to Section 10
55. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Incorrect. Refer to Section 10
Section 10 Lesson 2
(Answer all questions in this section)
56. 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
Correct
57. You create a view on the EMPLOYEES and DEPARTMENTS tables to display salary
information per department. What will happen if you issue the following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points
A complex view is created that returns the sum of salaries per department,
sorted by department name. (*)
A simple view is created that returns the sum of salaries per department,
sorted by department name.
A complex view is created that returns the sum of salaries per department,
sorted by department id.
Nothing, as the statement constains an error and will fail.
Correct
58. 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.
Correct
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 (*)
Correct
60. 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.
(*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in subquery
Correct
61. 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.
(*)
Incorrect. Refer to Section 10
62. 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
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 execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
64. 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
65. 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; (*)
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Correct
69. Which pseudocolumn returns the latest value supplied by a sequence? Mark
for Review
(1) Points
NEXTVAL
CURRVAL (*)
CURRENT
NEXT
Incorrect. Refer to Section 11
70. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Incorrect. Refer to Section 11
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 ; (*)
Incorrect. Refer to Section 11
72. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq CYCLE;
Which statement is true?
Mark for Review
(1) Points
The sequence cannot be used with more than one table.
The sequence preallocates values and retains them in memory.
The sequence cannot generate additional values after reaching its maximum
value.
The sequence will continue to generate values after the maximum sequence value
has been generated. (*)
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. 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
an index (*)
a FOREIGN KEY constraint
Correct
74. 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
75. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
76. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
77. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
78. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
79. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
80. Unique indexes are automatically created on columns that have which two
types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
81. 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
82. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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. (*)
Incorrect. Refer to Section 11
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
(1) Points
CREATE INDEX fl_idx ON employees(first_name || last_name);
CREATE INDEX fl_idx ON employees(first_name), employees(last_name);
CREATE INDEX fl_idx ON employees(first_name,last_name);
(*)
CREATE INDEX fl_idx ON employees(first_name);
CREATE INDEX fl_idx ON employees(last_name);
Correct
84. 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
85. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true?
Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index. (*)
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
87. 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
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
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
Incorrect. Refer to Section 12
89. 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
90. 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;
Correct
91. 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
Incorrect. Refer to Section 12
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.
GRANT SELECT ON employees_view TO public;
GRANT SELECT ON employees_view TO audrey; (*)
GRANT SELECT ON employees AND employees_view TO audrey;
Correct
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to grant privileges to a role? Mark for
Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
Correct
94. Which of the following simplifies the administration of privileges? Mark
for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
95. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other object privileges on the table to other users. True or False? Mark for
Review
(1) Points
True
False (*)
Correct
96. Which statement would you use to grant a role to users? Mark for Review
(1) Points
GRANT (*)
ALTER USER
CREATE USER
ASSIGN
Incorrect. Refer to Section 12
97. Which keyword would you use to grant an object privilege to all database
users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Correct
98. 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
Incorrect. Refer to Section 12
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
Incorrect. Refer to Section 14
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 (*)
None of the above
Correct
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
5. 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
Correct
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
INTERVAL YEAR TO MONTH
TIMESTAMP (*)
INTERVAL DAY TO SECOND
Correct
7. 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 (*)
Correct
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
Correct
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
Correct
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
column? Mark for Review
(1) Points
CHAR
DATE
NUMBER (*)
VARCHAR2
Correct
Page 1 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 2
(Answer all questions in this section)
11. A column that will be used to store binary data up to 4 Gigabyes in size
should be defined as which datatype? Mark for Review
(1) Points
LONG
NUMBER
BLOB (*)
LONGRAW
Correct
12. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege TRUNCATE TABLE employee;
Correct
14. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
15. 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
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect. Refer to Section 8 Lesson 3
17. 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. (*)
Correct
18. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct
19. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Correct
20. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Correct
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. 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
22. To do a logical delete of a column without the performance penalty of
rewriting all the table datablocks you can issue the following command: Mark for
Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Correct
23. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
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));
ALTER TABLE teams MODIFY (mgr_id VARCHAR2(15)); (*)
ALTER TABLE teams REPLACE (mgr_id VARCHAR2(15));
ALTER teams TABLE MODIFY COLUMN (mgr_id VARCHAR2(15));
You CANNOT modify the data type of the MGR_ID column.
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. What is the highest number of NOT NULL constraints you can have on a table?
Mark for Review
(1) Points
5
10
You can have as many NOT NULL constraints as you have columns in your table.
(*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. You need to add a NOT NULL constraint to the COST column in the PART table.
Which statement should you use to complete this task? Mark for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL); (*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Correct
28. A table can only have one unique key constraint defined. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
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
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct
Page 3 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 2
(Answer all questions in this section)
31. 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 (*)
Correct
32. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the same
datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Correct
33. 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
34. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Incorrect. Refer to Section 9
35. 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
36. 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) (*)
CHECK CONSTRAINT part_cost_ck (cost > 1.00)
CONSTRAINT CHECK part_cost_ck (cost > 1.00)
Correct
37. 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. (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
39. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Correct
40. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
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. The DEPARTMENT table contains these columns:
DEPT_ID NUMBER, Primary Key
DEPT_ABBR VARCHAR2(4)
DEPT_NAME VARCHAR2(30)
MGR_ID NUMBER
The EMPLOYEE table contains these columns:
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.
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.
Incorrect. Refer to Section 9
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';
ALTER TABLE employees DISABLE fk_dept_id_01;
ALTER TABLE employees DISABLE CONSTRAINT fk_dept_id_01; (*)
Correct
43. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
44. 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
Correct
45. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct
46. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct
47. 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
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. (*)
Correct
49. 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
50. 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.
Incorrect. Refer to Section 10
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. 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
52. Evaluate this view definition:
CREATE OR REPLACE VIEW part_name_v
AS SELECT DISTINCT part_name
FROM parts
WHERE cost >= 45;
Which of the following statements using the PART_NAME_V view will execute
successfully?
Mark for Review
(1) Points
SELECT *
FROM part_name_v;
(*)
UPDATE part_name_v
SET cost = cost * 1.23
WHERE part_id = 56990;
DELETE FROM part_name_v
WHERE part_id = 56897;
INSERT INTO part_name_v (part_id, part_name, product_id, cost) VALUES (857986,
'cylinder', 8790, 3.45);
Correct
53. Which statement would you use to alter a view? Mark for Review
(1) Points
ALTER VIEW
MODIFY VIEW
ALTER TABLE
CREATE OR REPLACE VIEW (*)
Incorrect. Refer to Section 10
54. Which of the following keywords cannot be used when creating a view? Mark
for Review
(1) Points
HAVING
WHERE
ORDER BY (*)
They are all valid keywords when creating views.
Correct
55. Which statement about the CREATE VIEW statement is false? Mark for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Correct
Section 10 Lesson 2
(Answer all questions in this section)
56. 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
Correct
57. You cannot create a view if the view subquery contains an inline view. True
or False? Mark for Review
(1) Points
True
False (*)
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. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
60. 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
Incorrect. Refer to Section 10
Page 6 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 2
(Answer all questions in this section)
61. 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
62. 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.
(*)
Incorrect. Refer to Section 10
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;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary "Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Correct
64. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
65. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Correct
66. The EMP_HIST_V view is no longer needed. Which statement should you use to
the remove this view? Mark for Review
(1) Points
DROP emp_hist_v;
DELETE emp_hist_v;
REMOVE emp_hist_v;
DROP VIEW emp_hist_v; (*)
Correct
67. 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
SELECT (*)
Correct
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. Evaluate this statement:
SELECT po_itemid_seq.CURRVAL FROM dual;
What does this statement accomplish?
Mark for Review
(1) Points
It resets the current value of the PO_ITEM_ID_SEQ sequence.
It displays the current value of the PO_ITEM_ID_SEQ sequence. (*)
It displays the next available 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.
Incorrect. Refer to Section 11
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct
Page 7 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 2
(Answer all questions in this section)
71. You need to retrieve the next available value for the SALES_IDX sequence.
Which would you include in your SQL statement? Mark for Review
(1) Points
sales_idx
sales_idx.NEXT
sales_idx.NEXTVAL (*)
sales_idx.CURRVAL
Correct
72. 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 ; (*)
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. 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 (*)
Incorrect. Refer to Section 11
74. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
75. Unique indexes are automatically created on columns that have which two
types of constraints? Mark for Review
(1) Points
NOT NULL and UNIQUE
UNIQUE and PRIMARY KEY (*)
UNIQUE and FOREIGN KEY
PRIMARY KEY and FOREIGN KEY
Correct
76. 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct
77. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
78. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct
79. 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
80. 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.
An index can prevent users from viewing certain data in a table.
Correct
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. You want to speed up the following query by creating an index:
SELECT * FROM employees WHERE (salary * 12) > 100000;
Which of the following will achieve this?
Mark for Review
(1) Points
Create a composite index on (salary,12).
Create a function-based index on (salary * 12). (*)
Create an index on (salary).
Create a function_based index on ((salary * 12) > 100000).
Correct
82. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Correct
83. 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; (*)
Correct
84. As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you own.
You created a public synonym on the EMPLOYEES table owned by user Sam.
You created a private synonym on the EMPLOYEES table owned by user Sam. (*)
Correct
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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. 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; (*)
REMOVE INSERT, DELETE ON employees FROM chang;
REVOKE INSERT AND DELETE ON employees FROM chang;
Correct
87. 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;
Correct
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
Incorrect. Refer to Section 12
89. 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
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.
A role is a name for a group of privileges. (*)
A role is an object privilege which allows a user to update a table.
Correct
Page 9 of 10
Test: 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 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;
Correct
92. 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
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
Section 12 Lesson 3
(Answer all questions in this section)
93. 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
Correct
94. Which statement would you use to remove an object privilege granted to a
user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
Correct
95. Which of the following simplifies the administration of privileges? Mark
for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct
96. Granting an object privilege WITH GRANT OPTION allows the recipient to grant
other object privileges on the table to other users. True or False? Mark for
Review
(1) Points
True
False (*)
Incorrect. Refer to Section 12
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;
Incorrect. Refer to Section 12
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.
Correct
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically rolled
back. True or False? Mark for Review
(1) Points
True (*)
False
Correct
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
Correct
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 statement about creating a table is true? Mark for Review
(1) Points
With a CREATE TABLE statement, a table will always be created in the current
user's schema.
If no schema is explicitly included in a CREATE TABLE statement, the table is
created in the current user's schema. (*)
If no schema is explicitly included in a CREATE TABLE statement, the CREATE
TABLE statement will fail.
If a schema is explicitly included in a CREATE TABLE statement and the schema
does not exist, it will be created.
Correct
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);
Correct
3. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Correct
4. 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));
Incorrect. Refer to Section 8
5. 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
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
Incorrect. Refer to Section 8
7. 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
8. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Incorrect. Refer to Section 8
9. 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
Incorrect. Refer to Section 8
10. 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.
(*)
Incorrect. Refer to Section 8
Page 1 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 2
(Answer all questions in this section)
11. Which statement about data types is true? Mark for Review
(1) Points
The BFILE data type stores character data up to four gigabytes in the database.
The TIMESTAMP data type is a character data type.
The VARCHAR2 data type should be used for fixed-length character data.
The CHAR data type requires that a minimum size be specified when defining a
column of this type. (*)
Incorrect. Refer to Section 8
12. 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
Section 8 Lesson 3
(Answer all questions in this section)
13. You need to change the name of the EMPLOYEE table to the EMP table. Which
statement should you use? Mark for Review
(1) Points
RENAME employee emp;
RENAME employee TO emp; (*)
ALTER TABLE employee TO emp;
ALTER TABLE employee RENAME TO emp;
Correct
14. 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;
ALTER TABLE orders MODIFY (amount DEFAULT 250);
(*)
DROP TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY
KEY,customerid varchar2(5) REFERENCES customers (customerid), orderdate date,
amount DEFAULT 250);
DELETE TABLE orders;
CREATE TABLE orders (orderno varchar2(5) CONSTRAINT pk_orders_01 PRIMARY KEY,
customerid varchar2(5) REFERENCES customers (customerid), orderdate date, amount
DEFAULT 250)
Incorrect. Refer to Section 8 Lesson 3
15. The PLAYERS table contains these columns:
PLAYER_ID NUMBER(9) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
TEAM_ID NUMBER(4)
SALARY NUMBER(9,2)
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));
ALTER TABLE players RENAME first_name VARCHAR2(10);
ALTER TABLE players MODIFY (first_name VARCHAR2(10)); (*)
Incorrect. Refer to Section 8 Lesson 3
16. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect. Refer to Section 8 Lesson 3
17. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is not
empty. (*)
Incorrect. Refer to Section 8 Lesson 3
18. Evaluate this statement:
ALTER TABLE employee SET UNUSED (fax);
Which task will this statement accomplish?
Mark for Review
(1) Points
Deletes the FAX column
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
drop of the column. (*)
Prevents a new FAX column from being added to the EMPLOYEE table
Incorrect. Refer to Section 8 Lesson 3
19. 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct
20. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct
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. 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. (*)
Correct
22. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Correct
23. 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 (*)
Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. A table can only have one unique key constraint defined. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
25. 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
26. Which statement about constraints is true? Mark for Review
(1) Points
A single column can have only one constraint applied.
PRIMARY KEY constraints can only be specified at the column level.
NOT NULL constraints can only be specified at the column level. (*)
UNIQUE constraints are identical to PRIMARY KEY constraints.
Incorrect. Refer to Section 9
27. 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 (*)
Incorrect. Refer to Section 9
28. You need to add a NOT NULL constraint to the COST column in the PART table.
Which statement should you use to complete this task? Mark for Review
(1) Points
ALTER TABLE part MODIFY (cost part_cost_nn NOT NULL);
ALTER TABLE part MODIFY (cost CONSTRAINT part_cost_nn NOT NULL); (*)
ALTER TABLE part MODIFY COLUMN (cost part_cost_nn NOT NULL);
ALTER TABLE part ADD (cost CONSTRAINT part_cost_nn NOT NULL);
Incorrect. Refer to Section 9
29. Which constraint can only be created at the column level? Mark for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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.
Incorrect. Refer to Section 9
Page 3 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 2
(Answer all questions in this section)
31. 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
32. Which of the following best describes the function of a CHECK constraint?
Mark for Review
(1) Points
A CHECK constraint enforces referential data integrity.
A CHECK constraint defines restrictions on the values that can be entered in a
column or combination of columns. (*)
A CHECK constraint enforces uniqueness of the values that can be entered in a
column or combination of columns.
A CHECK constraint is created automatically when a PRIMARY KEY constraint is
created.
Incorrect. Refer to Section 9
33. 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
34. How many PRIMARY KEY constraints can be created for each table? Mark for
Review
(1) Points
none
one and only one (*)
one or two
unlimited
Incorrect. Refer to Section 9
35. 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
Correct
36. Evaluate this CREATE TABLE statement:
CREATE TABLE part(
part_id NUMBER,
part_name VARCHAR2(25),
manufacturer_id NUMBER(9),
cost NUMBER(7,2),
retail_price NUMBER(7,2) NOT NULL,
CONSTRAINT part_id_pk PRIMARY KEY(part_id),
CONSTRAINT cost_nn NOT NULL(cost),
CONSTRAINT FOREIGN KEY (manufacturer_id) REFERENCES manufacturer(id));
Which line will cause an error?
Mark for Review
(1) Points
8 (*)
Correct
37. 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 (*)
Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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);
Incorrect. Refer to Section 9
39. You need to display the names and definitions of constraints only in your
schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct
40. 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
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. 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);
(*)
ALTER TABLE employee
MODIFY emp_id PRIMARY KEY;
ALTER TABLE employee
MODIFY CONSTRAINT PRIMARY KEY (emp_id);
Correct
42. What actions can be performed on or with Constraints? Mark for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct
43. The PO_DETAILS table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCTS table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_details
DISABLE CONSTRAINT product_id_pk CASCADE;
For which task would you issue this statement?
Mark for Review
(1) Points
To create a new PRIMARY KEY constraint on the PO_NUM column
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
Incorrect. Refer to Section 9
44. Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;
Which result will the statement provide?
Mark for Review
(1) Points
A syntax error will be returned. (*)
A constraint will be added to the EMPLOYEES table.
An existing constraint on the EMPLOYEES table will be overwritten.
An existing constraint on the EMPLOYEES table will be enabled.
Incorrect. Refer to Section 9
45. Which of the following would always cause an integrity constraint error?
Mark for Review
(1) Points
Using a subquery in an INSERT statement.
Using the MERGE statement to conditionally insert or update rows.
Using the DELETE command on a row that contains a primary key with a dependent
foreign key. (*)
Using the UPDATE command on rows based in another table.
Incorrect. Refer to Section 9
46. 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
Review
(1) Points
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY (employee_id) REFERENCES employees
(employee_id);
(*)
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY BETWEEN salary (employee_id) AND
employees (employee_id);
ALTER TABLE salary
FOREIGN KEY CONSTRAINT fk_employee_id_ REFERENCES employees (employee_id);
ALTER TABLE salary
ADD CONSTRAINT fk_employee_id_ FOREIGN KEY salary (employee_id) = employees
(employee_id);
Incorrect. Refer to Section 9
47. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Incorrect. Refer to Section 9
Section 10 Lesson 1
(Answer all questions in this section)
48. 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
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. (*)
Correct
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.
Incorrect. Refer to Section 10
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. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple
inline
complex (*)
Incorrect. Refer to Section 10
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 (*)
Incorrect. Refer to Section 10
53. 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
Incorrect. Refer to Section 10
54. Views must be used to select data from a table if one exist. As soon as a
view is created on a table, you can no longer select direct from the table. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
55. 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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct
Section 10 Lesson 2
(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.
(*)
Prohibits DML actions without administrator CHECK approval
Allows for DELETES from other tables, including ones not listed in subquery
Incorrect. Refer to Section 10
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.
Correct
58. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct
59. You create a view on the EMPLOYEES and DEPARTMENTS tables to display salary
information per department. What will happen if you issue the following statement:
CREATE OR REPLACE VIEW sal_dept
AS SELECT SUM(e.salary) sal, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
GROUP BY d.department_name
ORDER BY d.department_name;
Mark for Review
(1) Points
A complex view is created that returns the sum of salaries per department,
sorted by department name. (*)
A simple view is created that returns the sum of salaries per department,
sorted by department name.
A complex view is created that returns the sum of salaries per department,
sorted by department id.
Nothing, as the statement constains an error and will fail.
Incorrect. Refer to Section 10
60. 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
Page 6 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 2
(Answer all questions in this section)
61. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct
62. 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
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
64. 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
SELECT (*)
Correct
65. The CUSTOMER_FINANCE table contains these columns:
CUSTOMER_ID NUMBER(9)
NEW_BALANCE NUMBER(7,2)
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
FINANCE_CHARGE NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You execute this statement:
SELECT ROWNUM "Rank", customer_id, new_balancev
FROM
(SELECT customer_id, new_balance
FROM customer_finance)
WHERE ROWNUM <= 25
ORDER BY new_balance DESC;
What statement is true?
Mark for Review
(1) Points
The statement failed to execute because an inline view was used.
The statement will not necessarily return the 25 highest new balance values.
(*)
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.
Incorrect. Refer to Section 10
66. 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
Incorrect. Refer to Section 10
67. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE order_id_seq NOCYCLE NOCACHE;
Which statement is true?
Mark for Review
(1) Points
The sequence has no maximum value.
The sequence preallocates values and retains them in memory.
The sequence will continue to generate values after reaching its maximum value.
The sequence will start with 1. (*)
Incorrect. Refer to Section 11
69. A gap can occur in a sequence because a user generated a number from the
sequence and then rolled back the transaction. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 11
70. The ALTER SEQUENCE statement can be used to: Mark for Review
(1) Points
Change the START WITH value of a sequence
Change the maximum value to a lower number than was last used
Change the name of the sequence
Change how much a sequence increments by each time a number is generated (*)
Correct
Page 7 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 2
(Answer all questions in this section)
71. Sequences can be used to: (choose three) Mark for Review
(1) Points
(Choose all correct answers)
Ensure primary key values will be unique and consecutive
Ensure primary key values will be unique even though gaps may exist (*)
Generate a range of numbers and optionally cycle through them again (*)
Set a fixed interval between successively generated numbers. (*)
Guarantee that no primary key values are unused
Incorrect. Refer to Section 11
72. 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.
Incorrect. Refer to Section 11
Section 11 Lesson 3
(Answer all questions in this section)
73. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of
the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Correct
74. 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.
Incorrect. Refer to Section 11
75. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Correct
76. 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.
An index can prevent users from viewing certain data in a table.
Correct
77. 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';
SELECT index_name, table_name, uniqueness
FROM 'EMPLOYEES';
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE table_name = 'EMPLOYEES';
(*)
SELECT index_name, table_name, uniqueness
FROM user_indexes
WHERE index = EMPLOYEES;
Correct
78. 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
79. 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
80. For which column would you create an index? Mark for Review
(1) Points
A column which has only 4 distinct values.
A column that is updated frequently
A column with a large number of null values (*)
A column that is infrequently used as a query search condition
Incorrect. Refer to Section 11
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. The EMPLOYEE table contains these columns:
EMP_ID NOT NULL, Primary Key
SSNUM NOT NULL, Unique
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPT_ID NUMBER Foreign Key to DEPT_ID column of the DEPARTMENT table
SALARY NUMBER(8,2)
You execute this statement:
CREATE INDEX emp_name_idx
ON employee(last_name, first_name);
Which statement is true?
Mark for Review
(1) Points
The statement creates a function-based index.
The statement fails because of a syntax error.
The statement creates a composite unique index.
The statement creates a composite non-unique index. (*)
Incorrect. Refer to Section 11
82. The CUSTOMERS table exists in user Mary's schema. Which statement should you
use to create a synonym for all database users on the CUSTOMERS table? Mark for
Review
(1) Points
CREATE PUBLIC SYNONYM cust
ON mary.customers;
CREATE PUBLIC SYNONYM cust
FOR mary.customers;
(*)
CREATE SYNONYM cust
ON mary.customers FOR PUBLIC;
CREATE SYNONYM cust ON mary.customers;
GRANT SELECT ON cust TO PUBLIC;
Correct
83. When creating an index on one or more columns of a table, which of the
following statements are true? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
You should create an index if the table is large and most queries are expected
to retrieve less than 2 to 4 percent of the rows. (*)
You should always create an index on tables that are frequently updated.
You should create an index if one or more columns are frequently used together
in a join condition. (*)
You should create an index if the table is very small.
Incorrect. Refer to Section 11
84. 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.
Incorrect. Refer to Section 11
85. 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
an index (*)
a FOREIGN KEY constraint
Incorrect. Refer to Section 11
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;
Incorrect. Refer to Section 12
87. Which of the following are system privileges? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
CREATE TABLE (*)
UPDATE
CREATE PROCEDURE (*)
INDEX
Correct
88. 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
89. You want to grant privileges to user CHAN that will allow CHAN to update the
data in the EMPLOYEE table. Which type of privileges will you grant to CHAN? Mark
for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct
90. 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;
Correct
Page 9 of 10
Test: 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 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Correct
92. 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;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
(*)
GRANT CREATE SESSION TO jones;
GRANT CREATE TABLE TO jones;
CREATE USER jones IDENTIFIED BY mark;
GRANT CREATE SESSION TO jones;
Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. Which statement would you use to grant privileges to a role? Mark for
Review
(1) Points
CREATE ROLE
ALTER ROLE
GRANT (*)
ASSIGN
Incorrect. Refer to Section 12
94. 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
Incorrect. Refer to Section 12
95. Which keyword would you use to grant an object privilege to all database
users? Mark for Review
(1) Points
ADMIN
ALL
PUBLIC (*)
USERS
Incorrect. Refer to Section 12
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.
Correct
97. Which statement would you use to remove an object privilege granted to a
user? Mark for Review
(1) Points
ALTER USER
REVOKE (*)
REMOVE
DROP
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
Section 14 Lesson 1
(Answer all questions in this section)
99. 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
Incorrect. Refer to Section 14
100. 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;
What result will JANE see?
Mark for Review
(1) Points
22
20 (*)
JANE will receive an error message because she is not allowed to query the
table while BOB is updating it.
Incorrect. Refer to Section 14
Page 10 of 10
Skip navigation elements to page contents
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
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);
Correct Correct
2. 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;
CREATE TABLE emp (employee_id, first_name, last_name, salary, department_id);
CREATE TABLE emp
SELECT (employee_id, first_name, last_name, salary, department_id FROM employees);
CREATE TABLE emp
AS SELECT employee_id, first_name, last_name, salary, department_id
FROM employees; (*)
Correct Correct
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));
CREATE TABLE travel (destination_id number primary key, departure_date date,
return_date date, emp_id number(10) REFERENCES employees (emp_id)); (*)
Correct Correct
4. 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
You created the LINE_ITEM table in the public schema.
You created the LINE_ITEM table in the SYS schema.
You created the table in your schema. (*)
You created the table in the SYSDBA schema.
Incorrect Incorrect. Refer to Section 8
5. Evaluate this CREATE TABLE statement:
1. CREATE TABLE customer#1 (
2. cust_1 NUMBER(9),
3. sales$ NUMBER(9),
4. 2date DATE DEFAULT SYSDATE);
Which line of this statement will cause an error?
Mark for Review
(1) Points
4 (*)
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 2
(Answer all questions in this section)
6. Evaluate this CREATE TABLE statement:
CREATE TABLE sales
( sales_id NUMBER(9),
customer_id NUMBER(9),
employee_id NUMBER(9),
description VARCHAR2(30),
sale_date TIMESTAMP WITH LOCAL TIME ZONE DEFAULT SYSDATE,
sale_amount NUMBER(7,2));
Which business requirement will this statement accomplish?
Mark for Review
(1) Points
Sales identification values could be either numbers or characters, or a
combination of both.
All employee identification values are only 6 digits so the column should be
variable in length.
Description values can range from 0 to 30 characters so the column should be
fixed in length.
Today's date should be used if no value is provided for the sale date. (*)
Correct Correct
7. The TIMESTAMP data type allows what? Mark for Review
(1) Points
Time to be stored as an interval of years and months.
Time to be stored as a date with fractional seconds. (*)
Time to be stored as an interval of days to hours, minutes and seconds.
None of the above.
Incorrect Incorrect. Refer to Section 8
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
Correct Correct
9. 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 Correct
10. 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 Correct
Page 1 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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
12. 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
Incorrect Incorrect. Refer to Section 8
Section 8 Lesson 3
(Answer all questions in this section)
13. Evaluate this statement:
TRUNCATE TABLE employee;
Which statement about this TRUNCATE TABLE statement is true?
Mark for Review
(1) Points
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 reverse this statement by issuing the ROLLBACK statement.
You can produce the same results by issuing the 'DELETE inventory' statement.
Incorrect Incorrect. Refer to Section 8 Lesson 3
14. 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. (*)
Correct Correct
15. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
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.
Correct Correct
16. 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
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(2,8)
Alters the definition of the BACKORDER_AMOUNT column to NUMBER(8.2)
Changes the definition of the BACKORDER_AMOUNT column to NUMBER(8,2) (*)
Correct Correct
17. 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
Correct Correct
18. To do a logical delete of a column without the performance
penalty of rewriting all the table datablocks you can issue the following command:
Mark for Review
(1) Points
Alter table modify column
Alter table drop column
Alter table set unused (*)
Drop column 'columname'
Incorrect Incorrect. Refer to Section 8 Lesson 3
19. The EMPLOYEES contains these columns:
LAST_NAME VARCHAR2(15) NOT NULL
FIRST_NAME VARCHAR2(10) NOT NULL
EMPLOYEE_ID NUMBER(4) NOT NULL
HIRE_DATE DATE NOT NULL
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;
Correct Correct
20. Evaluate the structure of the EMPLOYEE table:
EMPLOYEE_ID NUMBER(9)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER(9)
MANAGER_ID NUMBER(9)
SALARY NUMBER(7,2)
The EMPLOYEE_ID column currently contains 500 employee identification numbers.
Business requirements have changed and you need to allow users to include text
characters in the identification values. Which statement should you use to change
this column's data type?
Mark for Review
(1) Points
ALTER TABLE employee MODIFY (employee_id VARCHAR2(9));
ALTER TABLE employee REPLACE (employee_id VARCHAR2(9));
ALTER employee TABLE MODIFY COLUMN (employee_id VARCHAR2(15));
You CANNOT modify the data type of the EMPLOYEE_ID column, as the table is
not empty. (*)
Incorrect Incorrect. Refer to Section 8 Lesson 3
Previous Page 2 of 10 Next Summary
Skip navigation elements to page contents
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. 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 (*)
the TRUNCATE ANY TABLE system privilege
the CREATE ANY TABLE system privilege
the ALTER ANY TABLE system privilege
Incorrect Incorrect. Refer to Section 8 Lesson 3
22. 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 (*)
Correct 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
Using the COMMENT ON TABLE or COMMENT on COLUMN (*)
Using an UPDATE statement on the USER_COMMENTS table
Correct Correct
Section 9 Lesson 1
(Answer all questions in this section)
24. Evaluate this CREATE TABLE statement:
CREATE TABLE customers
(customer_id NUMBER,
customer_name VARCHAR2(25),
 address VARCHAR2(25),
 city VARCHAR2(25),
 region VARCHAR2(25),
 postal_code VARCHAR2(11),
 CONSTRAINT customer_id_un UNIQUE(customer_id),
 CONSTRAINT customer_name_nn NOT NULL(customer_name));
Why does this statement fail when executed?
Mark for Review
(1) Points
The NUMBER data types require precision values.
UNIQUE constraints must be defined at the column level.
The CREATE TABLE statement does NOT define a PRIMARY KEY.
NOT NULL constraints CANNOT be defined at the table level. (*)
Correct Correct
25. 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 Correct
26. 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
Correct Correct
27. Which constraint can only be created at the column level? Mark
for Review
(1) Points
NOT NULL (*)
FOREIGN KEY
UNIQUE
CHECK
Correct Correct
28. A table can only have one unique key constraint defined. True or
False? Mark for Review
(1) Points
True
False (*)
Correct Correct
29. 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 Correct
Section 9 Lesson 2
(Answer all questions in this section)
30. 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 automatically increments by a
value of 1 each time a new record is entered into the table.
Data that is entered into a primary key column references a column of the
same datatype in another table.
Data that is entered into a primary key column is restricted to a range of
numbers that is defined by the local Oracle database.
Incorrect Incorrect. Refer to Section 9
Previous Page 3 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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 of the following types of constraints enforces uniqueness?
Mark for Review
(1) Points
CHECK
FOREIGN KEY
PRIMARY KEY (*)
NOT NULL
Correct Correct
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.
Incorrect Incorrect. Refer to Section 9
33. 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 Correct
34. Evaluate the structure of the DONATIONS table.
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);
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);
CREATE TABLE donations
pledge_id NUMBER PRIMARY KEY, donor_id NUMBER FOREIGN KEY donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE;
CREATE TABLE donations
(pledge_id NUMBER PRIMARY KEY, donor_id NUMBER CONSTRAINT donor_id_fk REFERENCES
donors(donor_id), pledge_date DATE, amount_pledged NUMBER(7,2), amount_paid
NUMBER(7,2), payment_dt DATE);
(*)
Incorrect Incorrect. Refer to Section 9
35. 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
Correct Correct
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 (*)
Correct Correct
37. 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. (*)
Incorrect Incorrect. Refer to Section 9
Section 9 Lesson 3
(Answer all questions in this section)
38. 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
to activate a new constraint while preventing the creation of a PRIMARY KEY
index
to activate the previously disabled constraint on the EMP_ID column while
creating a PRIMARY KEY index (*)
Correct Correct
39. 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
Incorrect Incorrect. Refer to Section 9
40. The LINE_ITEM table contains these columns:
LINE_ITEM_ID NUMBER PRIMARY KEY
PRODUCT_ID NUMBER(9) FOREIGN KEY references the ID column of the PRODUCT table
QUANTITY NUMBER(9)
UNIT_PRICE NUMBER(5,2)
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;
ALTER TABLE line_item DELETE CONSTRAINT product_id_fk;
Correct Correct
Previous Page 4 of 10 Next Summary
Skip navigation elements to page contents
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. This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES
employees(employee_id);
Mark for Review
(1) Points
Alter the table employees and disable the emp_manager_fk constraint.
Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager
must already be an employee. (*)
Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to
match every employee ID.
Alter table employees and add a FOREIGN KEY constraint that indicates each
employee ID must be unique.
Correct Correct
42. You need to display the names and definitions of constraints only
in your schema. Which data dictionary view should you query? Mark for Review
(1) Points
DBA_CONSTRAINTS
USER_CONSTRAINTS (*)
ALL_CONS_COLUMNS
USER_CONS_COLUMNS
Correct 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. (*)
Incorrect Incorrect. Refer to Section 9
44. 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;
Correct Correct
45. 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 (*)
ENABLE
Incorrect Incorrect. Refer to Section 9
46. What actions can be performed on or with Constraints? Mark
for Review
(1) Points
Add, Drop, Enable, Disable, Cascade (*)
Add, Minus, Enable, Disable, Collapse
Add, Subtract, Enable, Cascade
Add, Drop, Disable, Disregard
Correct Correct
47. 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);
ALTER TABLE employee
ADD CONSTRAINT dept_id_fk FOREIGN KEY (dept_id) REFERENCES department(id);
(*)
ALTER TABLE employee
ADD FOREIGN KEY CONSTRAINT dept_id_fk ON (dept_id) REFERENCES department(id);
ALTER TABLE employee
ADD FOREIGN KEY department(id) REFERENCES (dept_id);
Correct Correct
Section 10 Lesson 1
(Answer all questions in this section)
48. 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 Correct
49. 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 Correct
50. 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. (*)
Incorrect Incorrect. Refer to Section 10
Previous Page 5 of 10 Next Summary
Skip navigation elements to page contents
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 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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, 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;
Which statement is true?
Mark for Review
(1) Points
When both statements are executed all of the desired results are achieved.
The CREATE VIEW statement will fail if the EMPLOYEE table does not exist. (*)
The statements will NOT return all of the desired results because the WITH
CHECK OPTION clause is NOT included in the CREATE VIEW statement.
To achieve all of the desired results this ORDER ON clause should be added to
the CREATE VIEW statement: 'ORDER ON salary, last_name, first_name'.
Correct Correct
54. Evaluate this CREATE VIEW statement:
CREATE VIEW pt_view AS
(SELECT first_name, last_name, status, courseid, subject, term
FROM faculty f, course c
WHERE f.facultyid = c.facultyid);
Which type of view will this statement create?
Mark for Review
(1) Points
nested
simple (*)
inline
complex
Incorrect Incorrect. Refer to Section 10
55. Which statement about the CREATE VIEW statement is false? Mark
for Review
(1) Points
A CREATE VIEW statement CANNOT contain a join query. (*)
A CREATE VIEW statement can contain an ORDER BY clause.
A CREATE VIEW statement can contain a function.
A CREATE VIEW statement can contain a GROUP BY clause.
Incorrect Incorrect. Refer to Section 10
Section 10 Lesson 2
(Answer all questions in this section)
56. 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 Correct
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 (*)
Incorrect Incorrect. Refer to Section 10
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 Correct
59. 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;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.empid "Employee", d.department_name "Department", e.salary "Salary",
j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id NOT e.salary BETWEEN j.lowest_sal and
j.highest_sal;
CREATE OR REPLACE VIEW salary_vu
AS SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees e, departments d, job_grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal;
(*)
CREATE OR REPLACE VIEW salary_vu
AS (SELECT e.last_name "Employee", d.department_name "Department", e.salary
"Salary", j.grade_level "Grade"
FROM employees emp, departments d, job grades j
WHERE e.department_id = d.department_id AND e.salary BETWEEN j.lowest_sal and
j.highest_sal);
Correct 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
Correct Correct
Previous Page 6 of 10 Next Summary
Skip navigation elements to page contents
Test: 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. 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.
Correct Correct
62. 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;
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o. orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid);
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;
(*)
Correct Correct
Section 10 Lesson 3
(Answer all questions in this section)
63. 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
SELECT (*)
Correct 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 Correct
65. Evaluate this SELECT statement:
SELECT ROWNUM "Rank", customer_id, new_balance
FROM
(SELECT customer_id, new_balance
FROM customer_finance
ORDER BY new_balance DESC)
WHERE ROWNUM <= 25;
Which type of query is this SELECT statement?
Mark for Review
(1) Points
A Top-n query (*)
A complex view
A simple view
A hierarchical view
Correct Correct
66. Evaluate this CREATE VIEW statement:
CREATE VIEW sales_view
AS SELECT customer_id, region, SUM(sales_amount)
FROM sales
WHERE region IN (10, 20, 30, 40) GROUP BY region, customer_id;
Which statement is true?
Mark for Review
(1) Points
You can modify data in the SALES table using the SALES_VIEW view.
You cannot modify data in the SALES table using the SALES_VIEW view. (*)
You can only insert records into the SALES table using the SALES_VIEW view.
The CREATE VIEW statement generates an error.
Incorrect Incorrect. Refer to Section 10
67. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
JOB_ID NUMBER
MANAGER_ID NUMBER
SALARY NUMBER(9,2)
COMMISSOIN NUMBER(7,2)
HIRE_DATE DATE
Which SELECT statement could be used to display the 10 lowest paid clerks that
belong to department 70?
Mark for Review
(1) Points
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary
FROM employees
ORDER BY salary)
WHERE ROWNUM <=10 AND job_id LIKE 'CLERK' AND department_id = 70;
SELECT ROWNUM "Ranking",last_name||','||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary, job_id
FROM employees
WHERE job_id LIKE 'CLERK' AND department_id = 70
ORDER BY salary)
WHERE ROWNUM <=10;
(*)
SELECT ROWNUM "Ranking", last_name||' ,'||first_name "Employee", salary
"Salary"
FROM
(SELECT last_name, first_name, salary,job_id,dept_id
FROM employees
WHERE ROWNUM <=10
ORDER BY salary)
WHERE job_id LIKE 'CLERK' AND department_id = 70;
The only way is to use the data dictionary.
Incorrect Incorrect. Refer to Section 10
Section 11 Lesson 2
(Answer all questions in this section)
68. You issue this statement:
ALTER SEQUENCE po_sequence INCREMENT BY 2;
Which statement is true?
Mark for Review
(1) Points
Sequence numbers will be cached.
Future sequence numbers generated will increase by 2 each time a number is
generated. (*)
If the PO_SEQUENCE sequence does not exist, it will be created.
The statement fails if the current value of the sequence is greater than the
START WITH value.
Correct Correct
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
Correct Correct
70. What is the most common use for a Sequence? Mark for Review
(1) Points
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
Correct Correct
Previous Page 7 of 10 Next Summary
Skip navigation elements to page contents
Test: Final Exam - Database Programming with SQL
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. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq INCREMENT BY -1;
Which statement is true?
Mark for Review
(1) Points
The statement will not execute successfully.
The sequence will generate sequential descending values. (*)
The starting value of the LINE_ITEM_ID_SEQ sequence will by -1.
The minimum value of the LINE_ITEM_ID_SEQ will be the smallest possible
integer value.
Correct Correct
72. Evaluate this statement:
CREATE SEQUENCE sales_item_id_seq
START WITH 101 MAXVALUE 9000090 CYCLE;
Which statement about this CREATE SEQUENCE statement is true?
Mark for Review
(1) Points
The sequence will reuse numbers and will start with 101. (*)
The sequence will generate decrementing sequence numbers starting at 101.
The statement fails because no INCREMENT BY value is specified.
The sequence will generate sequence numbers starting with 101, but will not
reuse numbers.
Correct Correct
Section 11 Lesson 3
(Answer all questions in this section)
73. Which statement about an index is true? Mark for Review
(1) Points
An index can only be created on a single table column.
Creating an index will always improve query performance.
Creating an index reorders the data in the underlying table.
An index created on multiple columns is called a composite or concatenated
index. (*)
Incorrect Incorrect. Refer to Section 11
74. The EMPLOYEES table has an index named LN_IDX on the LAST_NAME
column. You want to change this index so that it is on the FIRST_NAME column
instead. Which SQL statement will do this? Mark for Review
(1) Points
ALTER INDEX ln_idx ON employees(first_name);
ALTER INDEX ln_idx TO employees(first_name);
ALTER INDEX ln_idx TO fn_idx ON employees(first_name);
None of the above; you cannot ALTER an index. (*)
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 (*)
Incorrect Incorrect. Refer to Section 11
76. 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; (*)
Incorrect Incorrect. Refer to Section 11
77.
As user Julie, you issue this statement:
CREATE SYNONYM emp FOR sam.employees;
Which task was accomplished by this statement?
Mark for Review
(1) Points
You created a public synonym on the EMP table owned by user Sam.
You created a private synonym on the EMPLOYEES table that you
own.
You created a public synonym on the EMPLOYEES table owned by user
Sam.
You created a private synonym on the EMPLOYEES table owned by
user Sam. (*)
Incorrect Incorrect. Refer to Section 11
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.
(*)
An index must be created by a database administrator when a PRIMARY KEY
constraint is created.
An index is never created for a unique constraint.
An index cannot be created before a PRIMARY KEY constraint is created.
Correct 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;
CREATE d_sum SYNONYM
FOR dept_sum_vu;
UPDATE dept_sum_vu
ON SYNONYM d_sum;
CREATE SYNONYM d_sum
FOR dept_sum_vu;
(*)
Correct Correct
80. 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.
An index can prevent users from viewing certain data in a table.
Correct Correct
Previous Page 8 of 10 Next Summary
Skip navigation elements to page contents
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. 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 Correct
82. The following indexes exist on the EMPLOYEES table:
- A unique index on the EMPLOYEE_ID primary key column
- a non-unique index on the JOB_ID column
- a composite index on the FIRST_NAME and LAST_NAME columns.
If the EMPLOYEES table is dropped, which indexes are automatically dropped at the
same time?
Mark for Review
(1) Points
EMP_ID only
SSNUM only
DEPT_ID only
EMP_ID and SSNUM (*)
Correct Correct
83. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DEPARTMENT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCT table
HIRE_DATE DATE DEFAULT SYSDATE
SALARY NUMBER (8,2) NOT NULL
On which column is an index automatically created for the EMPLOYEES table?
Mark for Review
(1) Points
SALARY
LAST_NAME
HIRE_DATE
EMPLOYEE_ID (*)
DEPARTMENT_ID
Correct Correct
84. The CLIENTS table contains these columns:
CLIENT_ID NUMBER(4) NOT NULL PRIMARY KEY
LAST_NAME VARCHAR2(15)
FIRST_NAME VARCHAR2(10)
CITY VARCHAR2(15)
STATE VARCHAR2(2)
You want to create an index named ADDRESS_INDEX on the CITY and STATE columns of
the CLIENTS table. You issue this statement:
CREATE INDEX clients
ON address_index (city, state);
Which result does this statement accomplish?
Mark for Review
(1) Points
An index named ADDRESS_INDEX is created on the CITY and STATE columns.
An index named CLIENTS is created on the CITY and STATE columns.
An index named CLIENTS_INDEX is created on the CLIENTS table.
An error message is produced, and no index is created. (*)
Incorrect Incorrect. Refer to Section 11
85. Evaluate this statement:
CREATE PUBLIC SYNONYM testing FOR chan.testing;
Which task will this statement accomplish?
Mark for Review
(1) Points
It recreates the synonym if it already exists.
It forces all users to access TESTING using the synonym.
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 Correct
Section 12 Lesson 2
(Answer all questions in this section)
86. You want to grant privileges to user CHAN that will allow CHAN to
update the data in the EMPLOYEE table. Which type of privileges will you grant to
CHAN? Mark for Review
(1) Points
user privileges
object privileges (*)
system privileges
administrator privileges
Correct Correct
87. 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
Incorrect Incorrect. Refer to Section 12
88. 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
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.
Incorrect Incorrect. Refer to Section 12
89. 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;
Incorrect Incorrect. Refer to Section 12
90. 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 Correct
Previous Page 9 of 10 Next Summary
Skip navigation elements to page contents
Test: 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 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;
Incorrect Incorrect. Refer to Section 12
92. 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. (*)
ADAM's CREATE USER privilege has been revoked.
ADAM's user account has been removed from the database.
Incorrect Incorrect. Refer to Section 12
Section 12 Lesson 3
(Answer all questions in this section)
93. 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 Correct
94. 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;
Incorrect Incorrect. Refer to Section 12
95. To join a table in your database to a table on a second (remote)
Oracle database, you need to use: Mark for Review
(1) Points
A remote procedure call
An Oracle gateway product
An ODBC driver
A database link (*)
Correct Correct
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.
Incorrect Incorrect. Refer to Section 12
97. Which of the following simplifies the administration of
privileges? Mark for Review
(1) Points
an index
a view
a trigger
a role (*)
Correct 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;
Incorrect Incorrect. Refer to Section 12
Section 14 Lesson 1
(Answer all questions in this section)
99. If a database crashes, all uncommitted changes are automatically
rolled back. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect Incorrect. Refer to Section 14
100. Examine the following statements:
UPDATE employees SET salary = 15000;
SAVEPOINT upd1_done;
UPDATE employees SET salary = 22000;
SAVEPOINT upd2_done;
DELETE FROM employees;
You want to retain all the employees with a salary of 15000; What statement would
you execute next?
Mark for Review
(1) Points
ROLLBACK;
ROLLBACK TO SAVEPOINT upd1_done; (*)
ROLLBACK TO SAVEPOINT upd2_done;
ROLLBACK TO SAVE upd1_done;
There is nothing you can do, either all changes must be rolled back, or none
of them can be rolled back.
Correct Correct
Previous Page 10 of 10 Summary
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1 Lesson 1
(Answer all questions in this section)
1. The PRICE table contains this data:
PRODUCT_ID MANUFACTURER_ID
86950 59604
You query the database and return the value 95. Which script did you use?
Mark for Review
(1) Points
SELECT SUBSTR(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
(*)
SELECT LENGTH(product_id, 3, 2)
FROM price
WHERE manufacturer_id = 59604;
SELECT SUBSTR(product_id, -1, 3)
FROM price
WHERE manufacturer_id = 59604;
SELECT TRIM(product_id, -3, 2)
FROM price
WHERE manufacturer_id = 59604;
Correct
2. Which SQL function can be used to remove heading or trailing characters (or
both) from a character string? Mark for Review
(1) Points
LPAD
CUT
NVL2
TRIM (*)
Incorrect. Refer to Section 1
3. Which SQL function is used to return the position where a specific character
string begins within a larger character string? Mark for Review
(1) Points
CONCAT
INSTR (*)
LENGTH
SUBSTR
Incorrect. Refer to Section 1
4. You query the database with this SQL statement:
SELECT CONCAT(last_name, (SUBSTR(LOWER(first_name), 4))) "Default Password"
FROM employees;
Which function will be evaluated first?
Mark for Review
(1) Points
CONCAT
SUBSTR
LOWER (*)
All three will be evaluated simultaneously.
Incorrect. Refer to Section 1
5. You need to display each employee's name in all uppercase letters. Which
function should you use? Mark for Review
(1) Points
CASE
UCASE
UPPER (*)
TOUPPER
Incorrect. Refer to Section 1
6. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979 12.00
You query the database and return the value 79. Which script did you use?
Mark for Review
(1) Points
SELECT INSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT INSTR(category, -2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, 2,2)
FROM styles
WHERE style_id = 895840;
SELECT SUBSTR(category, -2,2)
FROM styles
WHERE style_id = 758960;
(*)
Incorrect. Refer to Section 1
7. What will the following SQL statemtent display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees;
Mark for Review
(1) Points
The last name of employees that have a salary that includes a $ in the value,
size of 15 and the column labeled SALARY.
The last name and the format of the salary limited to 15 digits to the left of
the decimal and the column labeled SALARY.
The last name and salary for all employees with the format of the salary 15
characters long, left-padded with the $ and the column labeled SALARY. (*)
The query will result in an error: "ORA-00923: FROM keyword not found where
expected."
Incorrect. Refer to Section 1
Section 1 Lesson 2
(Answer all questions in this section)
8. Which two functions can be used to manipulate number or date column values,
but NOT character column values? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
RPAD
TRUNC (*)
ROUND (*)
INSTR
CONCAT
Incorrect. Refer to Section 1
9. You issue this SQL statement:
SELECT ROUND (1282.248, -2)
FROM dual;
What value does this statement produce?
Mark for Review
(1) Points
1200
1282
1282.25
1300 (*)
Incorrect. Refer to Section 1
10. Evaluate this function: MOD (25, 2) Which value is returned? Mark for
Review
(1) Points
1 (*)
25
Correct
Page 1 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1 Lesson 3
(Answer all questions in this section)
11. Which of the following Date Functions will add calendar months to a date?
Mark for Review
(1) Points
Months + Calendar (Month)
ADD_MONTHS (*)
MONTHS + Date
NEXT_MONTH
Incorrect. Refer to Section 1
12. Which function would you use to return the current database server date and
time? Mark for Review
(1) Points
DATE
SYSDATE (*)
DATETIME
CURRENTDATE
Incorrect. Refer to Section 1
13. Which SELECT statement will return a numeric value? Mark for Review
(1) Points
SELECT SYSDATE + 600 / 24
FROM employee;
SELECT ROUND(hire_date, DAY)
FROM employee;
SELECT (SYSDATE - hire_date) / 7
FROM employee;
(*)
SELECT SYSDATE - 7
FROM employee;
Incorrect. Refer to Section 1
14. You need to subtract three months from the current date. Which function
should you use? Mark for Review
(1) Points
ROUND
TO_DATE
ADD_MONTHS (*)
MONTHS_BETWEEN
Incorrect. Refer to Section 1
15. Which SELECT statement will NOT return a date value? Mark for Review
(1) Points
SELECT (30 + hire_date) + 1440/24
FROM employees;
SELECT (SYSDATE - hire_date) + 10*8
FROM employees;
(*)
SELECT SYSDATE - TO_DATE('25-JUN-02') + hire_date
FROM employees;
SELECT (hire_date - SYSDATE) + TO_DATE('25-JUN-02')
FROM employees;
Incorrect. Refer to Section 1
Section 2 Lesson 1
(Answer all questions in this section)
16. Which statement concerning single row functions is true? Mark for Review
(1) Points
Single row functions can accept only one argument, but can return multiple
values.
Single row functions cannot modify a data type.
Single row functions can be nested. (*)
Single row functions return one or more results per row.
Incorrect. Refer to Section 2
17. Which two statements concerning SQL functions are true? (Choose two.) Mark
for Review
(1) Points
(Choose all correct answers)
Character functions can accept numeric input.
Not all date functions return date values. (*)
Number functions can return number or character values.
Conversion functions convert a value from one data type to another data type.
(*)
Single-row functions manipulate groups of rows to return one result per group
of rows.
Incorrect. Refer to Section 2
18. Which three statements concerning explicit data type conversions are true?
(Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
Use the TO_NUMBER function to convert a number to a character string.
Use the TO_DATE function to convert a character string to a date value. (*)
Use the TO_NUMBER function to convert a character string of digits to a number.
(*)
Use the TO_DATE function to convert a date value to character string or number.
Use the TO_CHAR function to convert a number or date value to character string.
(*)
Incorrect. Refer to Section 2
19. Which arithmetic operation will return a numeric value? Mark for Review
(1) Points
TO_DATE('01-JUN-2004') - TO_DATE('01-OCT-2004') (*)
NEXT_DAY(hire_date) + 5
SYSDATE - 6
SYSDATE + 30 / 24
Correct
20. If you use the RR format when writing a query using the date 27-OCT-17 and
the year is 2001, what year would be the result? Mark for Review
(1) Points
2001
1901
2017 (*)
1917
Incorrect. Refer to Section 2
Page 2 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 2 Lesson 1
(Answer all questions in this section)
21. All Human Resources data is stored in a table named EMPLOYEES. You have been
asked to create a report that displays each employee's name and salary. Each
employee's salary must be displayed in the following format: $000,000.00. Which
function should you include in a SELECT statement to achieve the desired result?
Mark for Review
(1) Points
TO_CHAR (*)
TO_DATE
TO_NUMBER
CHARTOROWID
Correct
Section 2 Lesson 2
(Answer all questions in this section)
22. The PRODUCT table contains this column: PRICE NUMBER(7,2)
Evaluate this statement:
SELECT NVL(10 / price, '0')
FROM PRODUCT;
What would happen if the PRICE column contains null values?
Mark for Review
(1) Points
The statement would fail because values cannot be divided by 0.
A value of 0 would be displayed. (*)
A value of 10 would be displayed.
The statement would fail because values cannot be divided by null.
Incorrect. Refer to Section 2
23. Which of the following General Functions will return the first non-null
expression in the expression list? Mark for Review
(1) Points
NVL
NVL2
NULLIF
COALESCE (*)
Incorrect. Refer to Section 2
24. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
Evaluate this SELECT statement:
SELECT style_id, style_name, category, cost
FROM styles
WHERE style_name LIKE 'SANDAL' AND NVL(cost, 0) < 15.00
ORDER BY category, cost;
Which result will the query provide?
Mark for Review
(1) Points
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
758960 SANDAL 86979
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85909 12.00
968950 SANDAL 85909 10.00
758960 SANDAL 86979
869506 SANDAL 89690 15.00
STYLE_ID STYLE_NAME CATEGORY COST
968950 SANDAL 85909 10.00
895840 SANDAL 85940 12.00
758960 SANDAL 86979
(*)
Incorrect. Refer to Section 2
Section 3 Lesson 2
(Answer all questions in this section)
25. The PATIENTS and DOCTORS tables contain these columns:
PATIENTS
PATIENT_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
DOCTORS
DOCTOR_ID NUMBER(9)
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
You issue this statement:
SELECT patient_id, doctor_id
FROM patients, doctors;
Which result will this statement provide?
Mark for Review
(1) Points
A report containing all possible combinations of the PATIENT_ID and DOCTOR_ID
values (*)
A report containing each patient's id value and their doctor's id value
A report with NO duplicate PATIENT_ID or DOCTOR_ID values
A syntax error
Correct
26. Your have two tables named EMPLOYEES and SALES. You want to identify the
sales representatives who have generated at least $100,000 in revenue.
Which query should you issue? Mark for Review
(1) Points
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
SELECT e.fname, e.lname, s.sales
FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
(*)
SELECT e.fname, e.lname, s.sales
FROM employees, sales
WHERE e.emp_id = s.emp_id AND revenue >= 100000;
SELECT fname, lname, sales
Q FROM employees e, sales s
WHERE e.emp_id = s.emp_id AND revenue > 100000;
Incorrect. Refer to Section 3
27. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id AND employees.department_id > 5000
ORDER BY 4;
Which clause contains a syntax error?
Mark for Review
(1) Points
SELECT e.employee_id, e.last_name, e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND employees.department_id > 5000 (*)
ORDER BY 4;
Incorrect. Refer to Section 3
28. What happens when you create a Cartesian product? Mark for Review
(1) Points
All rows from one table are joined to all rows of another table (*)
The table is joined to itself, one column to the next column, exhausting all
possibilities
The table is joined to another equal table
All rows that do not match in the WHERE clause are displayed
Correct
29. When joining 3 tables in a SELECT statement, how many join conditions are
needed in the WHERE clause? Mark for Review
(1) Points
0
2 (*)
Incorrect. Refer to Section 3
30. Your company stores its business information in an Oracle9i database. The
EMPLOYEES table includes the following columns:
EMP_ID NUMBER(5) NOT NULL PRIMARY KEY
FNAME VARCHAR2(25)
LNAME VARCHAR2(25)
ADDRESS VARCHAR2(35)
CITY VARCHAR2(25)
STATE VARCHAR2(2)
ZIP NUMBER(9)
TELEPHONE NUMBER(10)
DEPT_ID NUMBER(5) NOT NULL FOREIGN KEY
The BONUS table includes the following columns:
BONUS_ID NUMBER(5) NOT NULL PRIMARY KEY
ANNUAL_SALARY NUMBER(10)
BONUS_PCT NUMBER(3, 2)
EMP_ID VARCHAR2(5) NOT NULL FOREIGN KEY
You want to determine the amount of each employee's bonus. Which of the following
queries should you issue?
Mark for Review
(1) Points
SELECT e.fname, e.lname, b.annual_salary * b. bonus_pct
FROM employees e, bonus b
WHERE e.emp_id = b.emp_id;
(*)
SELECT e.fname, e.lname, b.annual_salary, b. bonus_pct
FROM employees e, bonus b
WHERE e.emp_id = b.emp_id;
SELECT e.fname, e.lname, b.annual_salary, b. bonus_pct
FROM employees, bonus
WHERE e.emp_id = b.emp_id;
SELECT fname, lname, annual_salary * bonus_pct
FROM employees, bonus NATURAL JOIN;
Correct
Page 3 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 3 Lesson 4
(Answer all questions in this section)
31. Which of the following best describes the function of an outer join? Mark
for Review
(1) Points
An outer join will return only those rows that do not meet the join criteria.
An outer join will return only data from the far left column in one table and
the far right column in the other table.
An outer join will return data only if both tables contain an identical pair of
columns.
An outer join will return all rows that meet the join criteria and will return
NULL values from one table if no rows from the other table satisfy the join
criteria. (*)
Incorrect. Refer to Section 3
32. Evaluate this SELECT statement:
SELECT p.player_id, m.last_name, m.first_name, t.team_name
FROM player p
LEFT OUTER JOIN player m ON (p.manager_id = m.player_id)
LEFT OUTER JOIN team t ON (p.team_id = t.team_id);
Which join is evaluated first?
Mark for Review
(1) Points
the self-join of the player table (*)
the join between the player table and the team table on TEAM_ID
the join between the player table and the team table on MANAGER_ID
the join between the player table and the team table on PLAYER_ID
Correct
33. Which two operators can be used in an outer join condition using the outer
join operator (+)? Mark for Review
(1) Points
AND and = (*)
OR and =
BETWEEN...AND... and IN
IN and =
Correct
Section 4 Lesson 2
(Answer all questions in this section)
34. Which of the following best describes a natural join? Mark for Review
(1) Points
A join between two tables that includes columns that share the same name,
datatypes and lengths (*)
A join that produces a Cartesian product
A join between tables where matching fields do not exist
A join that uses only one table
Correct
35. You need to join all the rows in the EMPLOYEE table to all the rows in the
EMP_REFERENCE table. Which type of join should you create? Mark for Review
(1) Points
An equijoin
A cross join (*)
An inner join
A full outer join
Incorrect. Refer to Section 4
36. Which statement about a natural join is true? Mark for Review
(1) Points
Columns with the same names must have identical data types.
Columns with the same names must have the same precision and datatype. (*)
Columns with the same names must have compatible data types.
Columns with the same names cannot be included in the SELECT list of the query.
Incorrect. Refer to Section 4
Section 4 Lesson 3
(Answer all questions in this section)
37. For which condition would you use an equijoin query with the USING keyword?
Mark for Review
(1) Points
You need to perform a join of the CUSTOMER and ORDER tables but limit the
number of columns in the join condition. (*)
The ORDER table contains a column that has a referential constraint to a column
in the PRODUCT table.
The CUSTOMER and ORDER tables have no columns with identical names.
The CUSTOMER and ORDER tables have a corresponding column, CUST_ID. The CUST_ID
column in the ORDER table contains null values that need to be displayed.
Correct
38. Which SELECT clause creates an equijoin by specifying a column name common
to both tables? Mark for Review
(1) Points
A HAVING clause
The FROM clause
The SELECT clause
A USING clause (*)
Incorrect. Refer to Section 4
39. The primary advantage of using JOIN ON is: Mark for Review
(1) Points
The join happens automatically based on matching column names and data types
It will display rows that do not meet the join condition
It permits columns with different names to be joined (*)
It permits columns that don't have matching data types to be joined
Incorrect. Refer to Section 4
40. You created the CUSTOMERS and ORDERS tables by issuing these CREATE TABLE
statements in sequence:
CREATE TABLE customers
(custid varchar2(5),
companyname varchar2(30),
contactname varchar2(30),
address varchar2(30),
city varchar2(20),
state varchar2(30),
phone varchar2(20),
constraint pk_customers_01 primary key (custid));
CREATE TABLE orders
(orderid varchar2(5) constraint pk_orders_01 primary key,
orderdate date,
total number(15),
custid varchar2(5) references customers (custid));
You have been instructed to compile a report to present the information about
orders placed by customers who reside in Nashville . Which query should you issue
to achieve the desired results?
Mark for Review
(1) Points
SELECT custid, companyname
FROM customers
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
NATURAL JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
SELECT orderid, orderdate, total
FROM orders o
JOIN customers c ON o.custid = c.custid
WHERE city = 'Nashville';
(*)
SELECT orderid, orderdate, total
FROM orders
WHERE city = 'Nashville';
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 4 Lesson 4
(Answer all questions in this section)
41. Which query represents the correct syntax for a left outer join? Mark for
Review
(1) Points
SELECT companyname, orderdate, total
FROM customers c
LEFT JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
OUTER JOIN orders o
ON c.cust_id = o.cust_id;
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER JOIN orders o ON c.cust_id = o.cust_id;
(*)
SELECT companyname, orderdate, total
FROM customers c
LEFT OUTER JOIN orders o
ON c.cust_id = o.cust_id;
Incorrect. Refer to Section 4
42. Which two sets of join keywords create a join that will include unmatched
rows from the first table specified in the SELECT statement? Mark for Review
(1) Points
LEFT OUTER JOIN and FULL OUTER JOIN (*)
RIGHT OUTER JOIN and LEFT OUTER JOIN
USING and HAVING
OUTER JOIN and USING
Correct
43. Which type of join returns rows from one table that have NO direct match in
the other table? Mark for Review
(1) Points
equijoin
self join
outer join (*)
natural join
Incorrect. Refer to Section 4
Section 5 Lesson 1
(Answer all questions in this section)
44. Group functions can be nested to a depth of? Mark for Review
(1) Points
three
four
two (*)
Group functions cannot be nested.
Incorrect. Refer to Section 5
45. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
The first column listed in the GROUP BY clause is the most major grouping. (*)
The last column listed in the GROUP BY clause is the most major grouping.
The GROUP BY clause can contain an aggregate function.
A GROUP BY clause cannot be used without an ORDER BY clause.
Correct
46. Evaluate this SELECT statement:
SELECT MIN(hire_date), dept_id
FROM employee
GROUP BY dept_id;
Which values are displayed?
Mark for Review
(1) Points
The earliest hire date in each department. (*)
The the earliest hire date in the EMPLOYEE table.
The latest hire date in the EMPLOYEE table.
The hire dates in the EMPLOYEE table that contain NULL values.
Correct
47. Which statement about group functions is true? Mark for Review
(1) Points
Group functions ignore null values. (*)
Group functions can only be used in a SELECT list.
Group functions can be used in a WHERE clause.
A query that includes a group function in the SELECT list must include a GROUP
BY clause.
Correct
Section 5 Lesson 2
(Answer all questions in this section)
48. You need to calculate the standard deviation for the cost of products
produced in the Birmingham facility. Which group function will you use? Mark for
Review
(1) Points
STDEV
STDDEV (*)
VAR_SAMP
VARIANCE
Incorrect. Refer to Section 5
49. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
You need to determine the average payment amount made by each customer in January,
February and March of 2003. Which SELECT statement should you use?
Mark for Review
(1) Points
SELECT AVG(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' AND '31-MAR-2003';
(*)
SELECT AVG(payment_amount)
FROM payment;
SELECT SUM(payment_amount)
FROM payment
WHERE payment_date BETWEEN '01-JAN-2003' and '31-MAR-2003';
SELECT AVG(payment_amount)
FROM payment
WHERE TO_CHAR(payment_date) IN (JAN, FEB, MAR);
Correct
50. Which aggregate function can be used on a column of the DATE data type?
Mark for Review
(1) Points
AVG
MAX (*)
STDDEV
SUM
Incorrect. Refer to Section 5
Page 5 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 5 Lesson 2
(Answer all questions in this section)
51. The VENDORS table contains these columns:
VENDOR_ID NUMBER Primary Key
NAME VARCHAR2(30)
LOCATION_ID NUMBER
ORDER_DT DATE
ORDER_AMOUNT NUMBER(8,2)
Which two clauses represent valid uses of aggregate functions for this table?
Mark for Review
(1) Points
(Choose all correct answers)
FROM MAX(order_dt)
SELECT SUM(order_dt)
SELECT SUM(order_amount) (*)
WHERE MAX(order_dt) = order_dt
SELECT location_id, MIN(AVG(order_amount)) (*)
Incorrect. Refer to Section 5
52. Which group function would you use to display the total of all salary values
in the EMPLOYEE table? Mark for Review
(1) Points
SUM (*)
AVG
COUNT
MAX
Correct
53. You need to compute the total salary for all employees in department 10.
Which group function will you use? Mark for Review
(1) Points
MAX
SUM (*)
VARIANCE
COUNT
Incorrect. Refer to Section 5
54. The CUSTOMER table contains these columns:
CUSTOMER_ID NUMBER(9)
FNAME VARCHAR2(25)
LNAME VARCHAR2(30)
CREDIT_LIMIT NUMBER (7,2)
CATEGORY VARCHAR2(20)
You need to calculate the average credit limit for all the customers in each
category. The average should be calculated based on all the rows in the table
excluding any customers who have not yet been assigned a credit limit value. Which
group function should you use to calculate this value?
Mark for Review
(1) Points
AVG (*)
SUM
COUNT
STDDEV
Correct
55. The AVG, SUM, VARIANCE, and STDDEV functions can be used with which of the
following? Mark for Review
(1) Points
Only numeric data types (*)
Integers only
Any data type
All except numeric
Correct
Section 5 Lesson 3
(Answer all questions in this section)
56. Which SELECT statement will calculate the number of rows in the PRODUCTS
table? Mark for Review
(1) Points
SELECT COUNT(products);
SELECT COUNT FROM products;
SELECT COUNT (*) FROM products; (*)
SELECT ROWCOUNT FROM products;
Incorrect. Refer to Section 5
57. Examine the data from the LINE_ITEM table:
LINE_ITEM_ID ORDER_ID PRODUCT_ID PRICE DISCOUNT
890898 847589 848399 8.99 0.10
768385 862459 849869 5.60 0.05
867950 985490 945809 5.60
954039 439203 438925 5.25 0.15
543949 349302 453235 4.50
You query the LINE_ITEM table and a value of 5 is returned. Which SQL statement did
you execute?
Mark for Review
(1) Points
SELECT COUNT(discount) FROM line_item;
SELECT COUNT(*) FROM line_item; (*)
SELECT SUM(discount) FROM line_item;
SELECT AVG(discount) FROM line_item;
Incorrect. Refer to Section 5
58. The STYLES table contains this data:
STYLE_ID STYLE_NAME CATEGORY COST
895840 SANDAL 85940 12.00
968950 SANDAL 85909 10.00
869506 SANDAL 89690 15.00
809090 LOAFER 89098 10.00
890890 LOAFER 89789 14.00
857689 HEEL 85940 11.00
758960 SANDAL 86979
You issue this SELECT statement:
SELECT COUNT(category)
FROM styles;
Which value is displayed?
Mark for Review
(1) Points
7 (*)
The statement will NOT execute successfully.
Incorrect. Refer to Section 5
59. Evaluate this SQL statement:
SELECT COUNT (amount)
FROM inventory;
What will occur when the statement is issued?
Mark for Review
(1) Points
The statement will return the greatest value in the INVENTORY table.
The statement will return the total number of rows in the AMOUNT column.
The statement will replace all NULL values that exist in the AMOUNT column.
The statement will count the number of rows in the INVENTORY table where the
AMOUNT column is not null. (*)
Incorrect. Refer to Section 5
Section 6 Lesson 1
(Answer all questions in this section)
60. The PRODUCTS table contains these columns:
PRODUCT_ID NUMBER(9) PK
CATEGORY_ID VARCHAR2(10)
LOCATION_ID NUMBER(9)
DESCRIPTION VARCHAR2(30)
COST NUMBER(7,2)
PRICE NUMBER(7,2)
QUANTITY NUMBER
You display the total of the extended costs for each product category by location.
You need to include only the products that have a price less than $25.00. The
extended cost of each item equals the quantity value multiplied by the cost value.
Which SQL statement will display the desired result?
Mark for Review
(1) Points
SELECT category_id, SUM(cost * quantity) TOTAL,location_id
FROM products
WHERE price > 25.00
GROUP BY category_id, location_id;
SELECT SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY location_id;
SELECT category_id, SUM(cost * quantity) TOTAL, location_id
FROM products
WHERE price < 25.00
GROUP BY category_id, location_id;
(*)
SELECT SUM(cost * quantity) TOTAL
FROM products
WHERE price < 25.00;
Incorrect. Refer to Section 6
Page 6 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 1
(Answer all questions in this section)
61. You want to write a report that returns the average salary of all employees
in the company, sorted by departments. The EMPLOYEES table contains the following
columns:
EMPLOYEES:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which SELECT statement will return the information that you require?
Mark for Review
(1) Points
SELECT salary (AVG)
FROM employees
GROUP BY dept;
SELECT AVG (salary)
FROM employees
GROUP BY dept;
(*)
SELECT AVG (salary)
FROM employees
BY dept;
SELECT AVG salary
FROM employees
BY dept;
Incorrect. Refer to Section 6
62. Which statement about the GROUP BY clause is true? Mark for Review
(1) Points
To exclude rows before dividing them into groups using the GROUP BY clause, you
use should a WHERE clause. (*)
You can use a column alias in a GROUP BY clause.
By default, rows are not sorted when a GROUP BY clause is used.
You must use the HAVING clause with the GROUP BY clause.
Correct
63. Evaluate this SELECT statement:
SELECT SUM(salary), dept_id, department_name
FROM employee
WHERE dept_id = 1
GROUP BY department;
Which clause of the SELECT statement contains a syntax error?
Mark for Review
(1) Points
SELECT
FROM
WHERE
GROUP BY (*)
Incorrect. Refer to Section 6
64. Evaluate this statement:
SELECT department_id, AVG(salary)
FROM employees
WHERE job_id <> 69879
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000
ORDER BY department_id;
Which clauses restricts the result? Choose two.
Mark for Review
(1) Points
(Choose all correct answers)
SELECT department_id, AVG(salary)
WHERE job_id <> 69879 (*)
GROUP BY job_id, department_id
HAVING AVG(salary) > 35000 (*)
Incorrect. Refer to Section 6
65. The EMPLOYEES table contains the following columns:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
You want to create a report that includes each employee's last name, employee
identification number, date of hire and salary. The report should include only
those employees who have been with the company for more than one year and whose
salary exceeds $40,000.
Which of the following SELECT statements will accomplish this task?
Mark for Review
(1) Points
SELECT emp_id, lname, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT emp_id, lname, hire_date, salary
FROM employees
WHERE salary > 40000
AND hire_date = (SELECT hire_date FROM employees
WHERE (sysdate-hire_date) / 365 > 1);
SELECT emp_id, lname, hire_date, salary
FROM employees
WHERE salary > 40000
AND (sysdate-hire_date) / 365 > 1;
(*)
SELECT emp_id, lname, salary
FROM employees
WHERE salary > 40000
AND hire_date IN (sysdate-hire_date) / 365 > 1);
Incorrect. Refer to Section 6
66. Evaluate this SELECT statement:
SELECT COUNT(emp_id), dept_id
FROM employee
GROUP BY dept_id;
You only want to include employees who earn more than 15000.
Which clause should you include in the SELECT statement?
Mark for Review
(1) Points
WHERE salary > 15000 (*)
HAVING salary > 15000
WHERE SUM(salary) > 15000
HAVING SUM(salary) > 15000
Correct
67. What is the correct order of clauses in a SELECT statement? Mark for Review
(1) Points
SELECT
FROM
WHERE
ORDER BY
HAVING
SELECT
FROM
HAVING
GROUP BY
WHERE
ORDER BY
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
(*)
SELECT
FROM
WHERE
HAVING
ORDER BY
GROUP BY
Incorrect. Refer to Section 6
Section 6 Lesson 2
(Answer all questions in this section)
68. Using a subquery in which clause will return a syntax error? Mark for
Review
(1) Points
WHERE
FROM
HAVING
There are no places you cannot place subqueries. (*)
Incorrect. Refer to Section 6
69. Which statement about subqueries is true? Mark for Review
(1) Points
Subqueries should be enclosed in double quotation marks.
Subqueries cannot contain group functions.
Subqueries are often used in a WHERE clause to return values for an unknown
conditional value. (*)
Subqueries generally execute last, after the main or outer query executes.
Incorrect. Refer to Section 6
70. The TEACHERS and CLASS_ASSIGNMENTS tables contain these columns:
TEACHERS
TEACHER_ID NUMBER(5) Primary Key
NAME VARCHAR2 (25)
SUBJECT_ID NUMBER(5)
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
START_DATE DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use
subqueries? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE class_id =
45963);
(*)
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM class_assignments WHERE max_capacity >
0);
SELECT *
FROM teachers
WHERE teacher_id LIKE (SELECT teacher_id FROM class_assignments WHERE max_capacity
> 0);
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments GROUP BY
teacher_id);
Incorrect. Refer to Section 6
Page 7 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 2
(Answer all questions in this section)
71. You need to create a report to display the names of products with a cost
value greater than the average cost of all products. Which SELECT statement should
you use? Mark for Review
(1) Points
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost) FROM product);
(*)
SELECT product_name
FROM products
WHERE cost > AVG(cost);
SELECT AVG(cost), product_name
FROM products
WHERE cost > AVG(cost)
GROUP by product_name;
SELECT product_name
FROM (SELECT AVG(cost) FROM product)
WHERE cost > AVG(cost);
Correct
72. Which operator can be used with a multiple-row subquery? Mark for Review
(1) Points
IN (*)
<>
LIKE
Correct
Section 6 Lesson 3
(Answer all questions in this section)
73. If a single-row subquery returns a null value and uses the equality
comparison operator, what will the outer query return? Mark for Review
(1) Points
no rows (*)
all the rows in the table
a null value
an error
Correct
74. Which comparison operator can only be used with a single-row subquery? Mark
for Review
(1) Points
ANY
ALL
<> (*)
IN
Incorrect. Refer to Section 6
75. Which statement about the <> operator is true? Mark for Review
(1) Points
The <> operator is NOT a valid SQL operator.
The <> operator CANNOT be used in a single-row subquery.
The <> operator returns the same result as the ANY operator in a subquery.
The <> operator can be used when a single-row subquery returns only one row.
(*)
Incorrect. Refer to Section 6
Section 6 Lesson 4
(Answer all questions in this section)
76. What is wrong with the following query?
SELECT employee_id, last_name
FROM employees
WHERE salary =
(SELECT MIN(salary) FROM employees GROUP BY department_id);
Mark for Review
(1) Points
Single rows contain multiple values and a logical operator is used.
Subquery returns more than one row and single row comparison operator is used.
(*)
Subquery references the wrong table in the WHERE clause.
Nothing, it will run without problems.
Incorrect. Refer to Section 6
77. Evaluate this SELECT statement:
SELECT customer_id, name
FROM customer
WHERE customer_id IN
(SELECT customer_id
FROM customer
WHERE state_id = 'GA' AND credit_limit > 500.00);
What would happen if the inner query returned null?
Mark for Review
(1) Points
An error would be returned.
No rows would be returned by the outer query. (*)
All the rows in the table would be selected.
Only the rows with CUSTOMER_ID values equal to null would be selected.
Incorrect. Refer to Section 6
78. Evaluate this SQL statement:
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE salary > 30000 AND salary < 50000);
Which values will be displayed?
Mark for Review
(1) Points
Only employees who earn more than $30,000.
Only employees who earn less than $50,000.
All employees who work in a department with employees who earn more than
$30,000 and more than $50,000.
All employees who work in a department with employees who earn more than
$30,000, but less than $50,000. (*)
Incorrect. Refer to Section 6
79. Which of the following best describes the meaning of the ANY operator? Mark
for Review
(1) Points
Equal to any member in the list
Compare value to each value returned by the subquery (*)
Compare value to every value returned by the subquery
Equal to each value in the list
Incorrect. Refer to Section 6
80. You are looking for Executive information using a subquery. What will the
following SQL statement display?
SELECT department_id, last_name, job_id
FROM employees
WHERE department_id IN
(SELECT department_id
FROM departments
WHERE department_name = 'Executive');
Mark for Review
(1) Points
The department ID, department name and last name for every employee in the
Executive department.
The department ID, last name, department name for every Executive in the
employees table.
The department ID, last name, job ID from departments for Executive employees.
The department ID, last name, job ID for every employee in the Executive
department. (*)
Incorrect. Refer to Section 6
Page 8 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 6 Lesson 4
(Answer all questions in this section)
81. Which statement about the ANY operator when used with a multiple-row
subquery is true? Mark for Review
(1) Points
The ANY operator compares every value returned by the subquery. (*)
The ANY operator can be used with the DISTINCT keyword.
The ANY operator is a synonym for the ALL operator.
The ANY operator can be used with the LIKE and IN operators.
Correct
82. Which comparison operator would you use to compare a value to every value
returned by a subquery? Mark for Review
(1) Points
SOME
ANY
ALL (*)
IN
Incorrect. Refer to Section 6
83. A multiple-row operator expects how many values? Mark for Review
(1) Points
One or more (*)
Only one
Two or more
None
Correct
84. Examine the data in the PAYMENT table:
PAYMENT_ID CUSTOMER_ID PAYMENT_DATE PAYMENT_TYPE PAYMENT_AMOUNT
86590586 8908090 10-JUN-03 BASIC 859.00
89453485 8549038 15-FEB-03 INTEREST 596.00
85490345 5489304 20-MAR-03 BASIC 568.00
This statement fails when executed:
SELECT customer_id, payment_type
FROM payment
WHERE payment_id =
(SELECT payment_id
FROM payment
WHERE payment_amount = 596.00 OR payment_date = '20-MAR-2003');
Which change could correct the problem?
Mark for Review
(1) Points
Change the outer query WHERE clause to 'WHERE payment_id IN'. (*)
Remove the quotes surrounding the date value in the OR clause.
Remove the parentheses surrounding the nested SELECT statement.
Change the comparison operator to a single-row operator.
Correct
85. Which statement about single-row and multiple-row subqueries is true? Mark
for Review
(1) Points
Multiple-row subqueries cannot be used with the LIKE operator. (*)
Single-row operators can be used with both single-row and multiple-row
subqueries.
Multiple-row subqueries can be used with both single-row and multiple-row
operators.
Multiple-row subqueries can only be used in SELECT statements.
Correct
86. What would happen if you attempted to use a single-row operator with a
multiple-row subquery? Mark for Review
(1) Points
An error would be returned. (*)
No rows will be selected.
All the rows will be selected.
The data returned may or may not be correct.
Correct
Section 7 Lesson 1
(Answer all questions in this section)
87. You need to copy rows from the EMPLOYEE table to the EMPLOYEE_HIST table.
What could you use in the INSERT statement to accomplish this task? Mark for
Review
(1) Points
an ON clause
a SET clause
a subquery (*)
a function
Incorrect. Refer to Section 7
88. The STUDENTS table contains these columns:
STU_ID NUMBER(9) NOT NULL
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
DOB DATE
STU_TYPE_ID VARCHAR2(1) NOT NULL
ENROLL_DATE DATE
You create another table, named FT_STUDENTS, with an identical structure.You want
to insert all full-time students, who have a STU_TYPE_ID value of "F", into the new
table. You execute this INSERT statement:
INSERT INTO ft_students
(SELECT stu_id, last_name, first_name, dob, stu_type_id, enroll_date
FROM students
WHERE UPPER(stu_type_id) = 'F');
What is the result of executing this INSERT statement?
Mark for Review
(1) Points
All full-time students are inserted into the FT_STUDENTS table. (*)
An error occurs because the FT_STUDENTS table already exists.
An error occurs because you CANNOT use a subquery in an INSERT statement.
An error occurs because the INSERT statement does NOT contain a VALUES clause.
Correct
89. You need to add a row to an existing table. Which DML statement should you
use? Mark for Review
(1) Points
UPDATE
INSERT (*)
DELETE
CREATE
Incorrect. Refer to Section 7
90. Using the INSERT statement, and assuming that a column can accept null
values, how can you implicitly insert a null value in a column? Mark for Review
(1) Points
Use the NULL keyword.
Use the ON clause
Omit the column in the column list. (*)
It is not possible to implicitly insert a null value in a column.
Incorrect. Refer to Section 7
Page 9 of 10
Test: Mid Term Exam - Database Programming with SQL
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 7 Lesson 2
(Answer all questions in this section)
91. The EMPLOYEES table contains the following columns:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You need to increase the salary for all employees in department 10 by 10 percent.
You also need to increase the bonus for all employees in department 10 by 15
percent. Which statement should you use?
Mark for Review
(1) Points
UPDATE employees
SET salary = salary * 1.10, bonus = bonus * 1.15
WHERE dept = 10;
(*)
UPDATE employees
SET salary = salary * 1.10 AND bonus = bonus * 1.15
WHERE dept = 10;
UPDATE employees
SET (salary = salary * 1.10) SET (bonus = bonus * 1.15)
WHERE dept = 10;
UPDATE employees
SET salary = salary * .10, bonus = bonus * .15
WHERE dept = 10;
Correct
92. The EMPLOYEES table contains the following columns:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(9,2)
BONUS NUMBER(9,2)
You want to execute one DML statement to change the salary of all employees in
department 10 to equal the new salary of employee number 89898. Currently, all
employees in department 10 have the same salary value. Which statement should you
execute?
Mark for Review
(1) Points
UPDATE employee
SET salary = SELECT salary
FROM employee
WHERE emp_id = 89898;
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898);
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898)
WHERE dept = 10;
(*)
UPDATE employee
SET salary = (SELECT salary FROM employee WHERE emp_id = 89898 AND dept = 10);
Incorrect. Refer to Section 7
93. Examine the structures of the PRODUCTS and SUPPLIERS tables:
SUPPLIERS
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta.
Which script should you use?
Mark for Review
(1) Points
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
(*)
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
DELETE FROM products
WHERE supplier_id =
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ATLANTA');
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM suppliers
WHERE UPPER(city) = 'ALANTA');
Correct
94. One of the sales representatives, Janet Roper, has informed you that she was
recently married, and she has requested that you update her name in the employee
database. Her new last name is Cooper. Janet is the only person with the last name
of Roper that is employed by the company. The EMPLOYEES table contains these
columns and all data is stored in lowercase:
EMP_ID NUMBER(10) PRIMARY KEY
LNAME VARCHAR2(20)
FNAME VARCHAR2(20)
DEPT VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
Mark for Review
(1) Points
UPDATE employees
SET lname = 'cooper'
WHERE lname = 'roper';
(*)
UPDATE employees lname = 'cooper'
WHERE lname = 'roper';
UPDATE employees
SET lname = 'roper'
WHERE lname = 'cooper';
UPDATE employees
SET cooper = 'lname'
WHERE lname = 'roper';
Correct
95. You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the
EMPLOYEE table using one UPDATE statement. Which clause should you include in the
UPDATE statement to update multiple columns? Mark for Review
(1) Points
the USING clause
the ON clause
the WHERE clause
the SET clause (*)
Incorrect. Refer to Section 7
96. Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
Mark for Review
(1) Points
To display the names each player on the Lions team
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner
(*)
To display each player, their manager, and their team name for all teams with a
id value greater than 5000
Incorrect. Refer to Section 7
97. What would happen if you issued a DELETE statement without a WHERE clause?
Mark for Review
(1) Points
All the rows in the table would be deleted. (*)
An error message would be returned.
No rows would be deleted.
Only one row would be deleted.
Correct
98. When the WHERE clause is missing in a DELETE statement, what is the result?
Mark for Review
(1) Points
All rows are deleted from the table. (*)
The table is removed from the database.
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
Correct
99. You want to enter a new record into the CUSTOMERS table. Which two commands
can be used to create new rows? Mark for Review
(1) Points
INSERT, CREATE
MERGE, CREATE
INSERT, MERGE (*)
INSERT, UPDATE
Incorrect. Refer to Section 7
100. One of your employees was recently married. Her employee ID is still 189,
however, her last name is now Rockefeller. Which SQL statement will allow you to
reflect this change? Mark for Review
(1) Points
INSERT INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
INSERT my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189; (*)
Incorrect. Refer to Section 7
Page 10 of 10
Incorrect. Refer to Section 4
Page 4 of 10