Vous êtes sur la page 1sur 7

Section 7 Quiz

(Answer all questions in this section)

1.You need to join the EMPLOYEES table and the SCHEDULES table, Mark for Review
but the two tables do not have any corresponding columns. Which type (1) Points
of join will you create?

A full outer join


An equijoin
A non-equijoin (*)
It is not possible to join these two tables.

Correct

2.Which statement about joining tables with a non-equijoin is false? Mark for Review
(1) Points

A WHERE clause must specify a column in one table that is


compared to a column in the second table (*)
The number of join conditions required is always one less than the
number of tables being joined
The columns being joined must have compatible data types
None of the above

Correct

3.Nonequijoins are normally used with which of the following? (Choose Mark for Review
two) (1) Points

(Choose all correct answers)

Ranges of text
Ranges of rowids
Ranges of dates (*)
ranges of columns
Ranges of numbers (*)

Correct

4.The EMPLOYEE_ID column in the EMPLOYEES table corresponds Mark for Review
to the EMPLOYEE_ID column of the ORDERS table. (1) Points
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?
Self-join
Natural join
Equijoin
Outer join (*)

Correct

5.Which statement about outer joins is true? Mark for Review


(1) Points

The FULL, RIGHT, or LEFT keyword must be included.


The OR operator cannot be used to link outer join conditions. (*)
The tables must be aliased.
Outer joins are always evaluated before other types of joins in the
query.

Correct
6.Evaluate this Mark for Review
SELECT (1) Points
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?
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
The self-join of the player table (*)
The join between the player table and the team table on
TEAM_ID

Correct

7. The ID column in the CLIENT table that corresponds to Mark for Review
the CLIENT_ID column of the ORDER table contains null (1) Points
values for rows that need to be displayed. Which type of
join should you use to display the data?

Outer join (*)


Self join
Nonequi-Join
Equijoin

Correct

8. What is the result of a query that selects from two tables Mark for Review
but includes no join condition? (1) Points

A syntax error
A selection of matched rows from both tables
A Cartesian product (*)
A selection of rows from the first table only

Correct

9. When must column names be prefixed by table names in Mark for Review
join syntax? (1) Points

Only when query speed and database performance is a


concern
When the more than two tables participate in the join
When the same column name appears in more than one
table of the query (*)
Never

Correct
10. You have the following EMPLOYEES table: Mark for Review
(1) Points
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?

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 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 first_name, last_name, annual_salary *
bonus_pct
FROM employees, bonus NATURAL JOIN;

Correct
11.Evaluate this SQL Mark for Review
statement: (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;

Which clause contains a


syntax error?

AND employees.department_id > 5000 (*)


FROM employees e, departments d
WHERE e.department_id =
d.department_id
ORDER BY 4;
SELECT e.employee_id, e.last_name,
e.first_name, d.department_name

Correct

12. You have two tables named EMPLOYEES Mark for Review
and SALES. You want to identify the sales (1) Points
representatives who have generated at least
$100,000 in revenue.
Which query should you issue?

SELECT e.first_name, e.last_name, s.sales


FROM employees e, sales s
WHERE e.employee_id = s.employee_id
AND revenue >= 100000;

(*)
SELECT first_name, last_name, sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id
AND revenue > 100000;
SELECT e.first_name, e.last_name, s.sales
FROM employees, sales
WHERE e.employee_id = s.employee_id
AND revenue >= 100000;
SELECT e.first_name, e.last_name, s.sales
FROM employees e, sales s
WHERE e.employee_id = s.employee_id
AND revenue > 100000;

Correct

13. You have been asked to create a report that Mark for Review
lists all corporate customers and all orders that (1) Points
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?

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 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 ASC, amount
ASC;
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;

Correct
14. If table A has 10 rows and table B has 5 rows, Mark for Review
how many rows will be returned if you (1) Points
perform a equi-join on those two tables?

50
It depends on how many rows have
matching data in each of the two tables.
(*)
5
10

Correct

15. Oracle proprietary JOINS can use the Mark for Review
WHERE clause for conditions other than the (1) Points
join-condition. True or False?

True (*)
False

Correct