DP Database Programming With SQL - Final Exam
DP Database Programming With SQL - Final Exam
Final
Section 12
(Answer all the questions in this section)
1. An insert statement into multiple tables can be inserted into more than
a table. (True or false?)
TRUE (*)
FALSE
Correct
(1/1) Points
2. With MERGE, __________ and __________ are executed at the same time.
UPDATE; SELECT
UPDATE; DELETE
INSERT; SELECT
INSERT; UPDATE (*)
Correct
Points
3. An employee has the last name 'King' in the employees table. How many rows
Will they be removed from the employees table with the following statement?
DELETE FROM employees
WHERE last_name = 'king';
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)
To show each player, their manager, and the name of their team for
all teams with an ID value greater than 5000
To show the minimum and maximum salary of the players of each team
One of the saleswomen, Janet Roper, has informed you that she has gotten married.
recently and has requested that you update your name in the database
Employee data. Her new last name is Cooper. Janet is the only person.
with the last name Roper hired by the company. The EMPLOYEES table
it 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)
UPDATE employees
SET last_name = 'cooper'
WHERE last_name = 'roper'; (*)
UPDATE employees
SET cooper = 'last_name'
WHERE last_name = 'roper';
UPDATE employees
SET last_name = 'roper'
WHERE last_name = 'cooper';
UPDATE employees SET last_name = 'cooper'
WHERE last_name = 'roper';
Incorrect. Please refer to section 12 of lesson 2.
(0/1) Points
7. Can more than one row be inserted at once using a statement?
INSERT with a VALUES clause?
No, there is nothing like INSERT... VALUES.
No, you can only create one row at a time when using the clause
VALUES. (*)
Yes, you can show as many rows as you want; you just have to remember to separate
Section 13
(Answer all the questions in this section)
9. 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)
Section 13
(Answer all the questions in this section)
11. Comments can be added to a table using the statement
COMMENT ON TABLE. The comments that are added are included between:
Braces { }
Double quotes " "
Parenthesis ( )
Single quotes ' ' (*)
Correct
Points
12. The TEAMS table contains these columns:
TEAM_ID NUMBER(4) Primary Key
TEAM_NAME VARCHAR2(20)
MGR_ID NUMBER(9)
He is a member of the SYSDBA role, but is connected with his own schema.
Emit this CREATE TABLE statement. Which statement is true?
Section 14
(Answer all the questions in this section)
20. A table can only have one unique key constraint defined.
True or false?
TRUE
FALSE (*)
Correct
(1/1) Points
21. Which statement is true about the NOT NULL constraint?
The NOT NULL constraint must be defined at the column level.
The NOT NULL constraint requires a column to contain values
alphanumeric.
The NOT NULL constraint can be defined at the column level or at the table level.
table.
The NOT NULL constraint prevents a column from containing values
alphanumeric.
Correct
Points
22. Which of the following is not a valid Oracle constraint type?
EXTERNAL KEY (*)
NOT NULL
UNIQUE KEY
PRIMARY KEY
Correct
(1/1) Points
23. You must add a PRIMARY KEY constraint to the DEPARTMENTS table.
What sentence should I use?
ALTER TABLE departments
ADD CONSTRAINT PRIMARY KEY dept_id_pk (dept_id);
ALTER TABLE departments
ADD CONSTRAINT dept_id_pk PRIMARY KEY (dept_id); (*)
ALTER TABLE departments
ADD PRIMARY KEY dept_id_pk (dept_id);
ALTER TABLE departments
ADD CONSTRAINT dept_id_pk PK (dept_id);
Correct
Points
24. What is the syntax for removing a PRIMARY KEY constraint and
all their dependent restrictions?
ALTER TABLE table_name
DROP CONSTRAINT constraint_name CASCADE;
ALTER TABLE table_name
DROP CONSTRAINT constraint_name;
DROP CONSTRAINT table_name (constraint_name);
ALTER TABLE table_name
DROP CONSTRAINT FOREIGN KEY CASCADE;
Incorrect. See section 14 of lesson 3.
(0/1) Points
25. 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
Section 15
(Answer all the questions in this section)
27. 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)
The statement has not been executed because the ORDER BY clause does NOT use the
Top-n column.
The statement has not been executed because an online view has been used.
The sentence will not necessarily return the 25 new balance values.
higher, since the view does not have an ORDER BY clause. (*)
Correct
Points
28. An analysis of the top N is capable of classifying a game of
superior or inferior results. True or false?
TRUE (*)
FALSE
Correct
Points
29. A view can be used to maintain a historical record of the
old data from the underlying tables, so that, even though it
If you delete a row from a table, you will still be able to select the row in the view.
True or false?
TRUE
FALSE (*)
Correct
Points
30. Which of the following keywords cannot be used when creating a
view?
HAVING
WHERE
ORDER BY
All are valid keywords when creating views. (*)
Correct
Points
31. Manage an Oracle database that contains a table
called EMPLOYEES. Luke, a database user, must create
a report that includes the names and addresses of all
employees. You do not wish to grant Luke access to the EMPLOYEES table.
because it contains confidential data. Which of the following actions
What should I do first?
Create a view.
Create a subquery.
Create an index.
Create a report for him.
Correct
Points
32. You must create a new view in the EMPLOYEES table to update the
salary information for employees of department 50. Must
ensure that DML operations on the view cannot change the
salary values from other departments. What clause should be included in
the CREATE VIEW statement?
WITH READ ONLY
WITH CHECK OPTION (*)
FORCE
OR REPLACE
Correct
Points
33. Manages an Oracle database. Jack manages the department of
sales. He and his employees often find it appropriate to consult 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
personal. The view should not accept INSERT, UPDATE, or operations.
DELETE. Which of the following statements should be issued?
CREATE VIEW sales_view
(SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid)
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT c.companyname, c.city, o.orderid, o.orderdate, o.total
FROM customers c, orders o
WHERE c.custid = o.custid
WITH READ ONLY;
CREATE VIEW sales_view
AS (SELECT 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 companyname, city, orderid, orderdate, total
FROM customers, orders
WHERE custid = custid)
WITH READ ONLY;
Correct
Points
34. Which of the following DML operations is not allowed when using
a simple view created as read-only?
INSERT
UPDATE
DELETE
All of the above (*)
Correct
Points
Section 16
(Answer all the questions in this section)
35. Evaluate this CREATE SEQUENCE statement:
CREATE SEQUENCE line_item_id_seq INCREMENT BY -1;
my_seq.(currval)
my_seq.currval (*)
my_seq.nextval
my_seq.(lastval)
Correct
Points
38. What statement should I use to drop the index LAST_NAME_IDX
in the LAST_NAME column of the EMPLOYEES table?
DROP INDEX last_name_idx;
DROP INDEX last_name_idx(last_name);
ALTER TABLE employees
DROP INDEX last_name_idx;
DROP INDEX last_name_idx(employees.last_name);
Correct
(1/1) Points
39. The following indexes exist in the EMPLOYEES table:
Only EMP_ID
Only JOB_ID
Only DEPT_ID
EMP_ID y JOB_ID
All indexes (*)
Correct
Points
40. You want to create a composite index on the FIRST_NAME and columns.
LAST_NAME from the EMPLOYEES table. What SQL statement will be used to perform this?
this task?
CREATE INDEX fl_idx
ON employees(first_name || last_name);
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);
CREATE INDEX fl_idx ON employees(last_name);
Correct
Points
Section 17
(Answer all the questions in this section)
41. The user SUSAN creates a table EMPLOYEES and then creates a view.
EMP_VIEW that only shows the FIRST_NAME and LAST_NAME columns of
EMPLOYEES. The user RUDI must be able to access the names of
the employees, but to no other data of EMPLOYEES. What statement should
run SUSAN to allow this?
Correct
Points
Correct
Points
43. The REGULAR EXPRESSION functions perform exactly the same action
that LIKE, neither more nor less. (True or false?)
TRUE
FALSE (*)
Correct
Points
44. The REGULAR EXPRESSION functions can be used on CHAR data types,
CLOB and VARCHAR2? (True or false)
TRUE (*)
FALSE
Correct
Points
45. User BOB's schema contains a table EMPLOYEES. BOB executes the
next sentence:
Correct
Points
46. What Oracle function simplifies the process of granting and revoking
privileges?
Outline
Object
Data dictionary
Role (*)
Correct
(1/1) Points
47. What data dictionary view shows the system privileges that are
has been granted to a user?
USER_TAB_PRIVS
USER_SYSTEM_PRIVILEGES
USER_SYSTEM_PRIVS
USER_SYS_PRIVS (*)
(0/1) Points
Section 18
(Answer all the questions in this section)
TRUE (*)
FALSE
Correct
(1/1) Points
49. The row of Steven King in the EMPLOYEES table has an EMPLOYEE_ID value of 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;
78000
24000
48000 (*)
30000
Correct
Points
Section 19
(Answer all the questions in this section)
50. Unit tests are performed before the database goes to the
production phase to ensure that a random number of requirements of
Business functions correctly. True or false?
TRUE
FALSE (*)
(0/1) Points