Ch. 9 Joining Tables Flashcards Preview

Oracle 11g SQL > Ch. 9 Joining Tables > Flashcards

Flashcards in Ch. 9 Joining Tables Deck (30):
1


Which of the following SQL statements will list the name of each customer stored in the CUSTOMERS table, and, if the customer has placed an order that is contained in the ORDERS table, the order# of any order each customer has placed?


SELECT lastname, firstname, order#
FROM customers NATURAL JOIN orders
WHERE orders.customer# IS NOT NULL;


SELECT lastname, firstname, order#
FROM customers, orders
WHERE orders.customer# (+) = customers.customer#;


SELECT lastname, firstname, order#
FROM customers, orders
WHERE orders.customer# = customers.customer# (+);


SELECT lastname, firstname, order#
FROM customers NATURAL JOIN orders
WHERE orders.customer# IS NULL;

SELECT lastname, firstname, order#
FROM customers, orders
WHERE orders.customer# (+) = customers.customer#;

2


Which of the following SQL statements will display the names of all customers who have purchased a copy of E-BUSINESS THE EASY WAY?


SELECT lastname, firstname
FROM customers NATURAL JOIN books
WHERE title LIKE '%BUSI%';


SELECT lastname, firstname
FROM customers c, books b, orders o, orderitems oi
WHERE title LIKE '%BUSI%';


SELECT lastname, firstname
FROM customers c, books b, orders o, orderitems oi
WHERE c.customer# = o.customer# AND o.order# = oi.order# AND
oi.isbn = b.isbn AND title LIKE '%BUSI%';


none of the above

SELECT lastname, firstname
FROM customers c, books b, orders o, orderitems oi
WHERE c.customer# = o.customer# AND o.order# = oi.order# AND
oi.isbn = b.isbn AND title LIKE '%BUSI%';

3


Which of the following types of joins is created by matching equivalent values in each table?


Cartesian join


equality join


non-equality join


outer join

equality join

4


Which of the following keywords is used to create a Cartesian join?


OUTER JOIN


CROSS JOIN


NATURAL JOIN


JOIN...USING

CROSS JOIN

5



Which of the following queries will display data from both the ORDERS and CUSTOMERS tables?


SELECT * FROM orders, customers;


SELECT lastname, firstname, order#
FROM orders NATURAL JOIN customers;


SELECT lastname, firstname, order#
FROM orders, customers
WHERE orders.customer# = customers.customer#;


all of the above

all of the above

6


A table alias can consist of a maximum of ____ characters.


12


225


255


30

30

7


Which of the following types of joins refers to joining a table to itself?


Cartesian join


equality join


self-join


outer join

self-join

8


Which of the following SQL statements will return the names of all customers who placed an order on April 12, 2003?


SELECT lastname, firstname
FROM customers
WHERE orderdate = '12-APR-03';


SELECT lastname, firstname
FROM customers NATURAL JOIN orders
WHERE orderdate = '12-APR-03';


SELECT lastname, firstname
FROM customers JOIN orders ON (customer#)
WHERE orderdate = '12-APR-03';


both a and b

SELECT lastname, firstname
FROM customers NATURAL JOIN orders
WHERE orderdate = '12-APR-03';

9


Which of the following types of joins refers to results consisting of each row from the first table being replicated from every row in the second table?


outer join


non-equality join


self-join


Cartesian join

Cartesian join

10


In a Cartesian join, linking a table that contains 10 rows to a table that contains 9 rows will result in ____ rows being displayed in the output.


19


18


90


89

90

11


Which of the following set operators will display the results of the combined SQL statements without suppressing duplicate rows?


UNION


UNION ALL


INTERSECT


MINUS

UNION ALL

12


Which of the following SQL statements will display the gift that should be sent to any customer who orders the book titled THE WOK WAY TO COOK?


SELECT title FROM promotion
WHERE retail BETWEEN minretail AND maxretail;


SELECT title FROM promotion NATURAL JOIN books
WHERE retail BETWEEN minretail AND maxretail;


SELECT title FROM promotion JOIN books
USING retail BETWEEN minretail AND maxretail;


none of the above

none of the above

13


The JOIN keyword is included in which of the following clauses?


SELECT


FROM


WHERE


ORDER BY

FROM

14


Which of the following SQL statements will display the gift that should be sent to any customer who orders the book titled SHORTEST POEMS?


SELECT gift FROM promotion
WHERE gift = minretail;


SELECT gift FROM promotion, books
WHERE retail >= minretail AND title = 'SHORTEST POEMS';


SELECT gift FROM promotion, books
WHERE retail BETWEEN minretail AND maxretail
AND title = 'SHORTEST POEMS';


none of the above

SELECT gift FROM promotion, books
WHERE retail BETWEEN minretail AND maxretail
AND title = 'SHORTEST POEMS';

15


Which of the following SQL statements will display the title of all books that have had multiple copies requested in a single order?


SELECT title
FROM books NATURAL JOIN orderitems
WHERE qty > 1;


SELECT title
FROM books JOIN orderitems
WHERE qty > 1;


SELECT title
FROM books JOIN orderitems ON (isbn) JOIN orders ON (order#)
WHERE qty>1;


SELECT title
FROM books JOIN orderitems USING(isbn);

SELECT title
FROM books NATURAL JOIN orderitems
WHERE qty > 1;

16



Which of the following SQL statements will display the name of each publisher that publishes a book classified in the COMPUTER category?


SELECT UNIQUE name
FROM books, publisher;


SELECT UNIQUE name
FROM books NATURAL JOIN publisher
WHERE category = 'COMPUTER';


SELECT DISTINCT name
FROM books JOIN publisher
WHERE category = 'COMPUTER';


both b and c

SELECT UNIQUE name
FROM books NATURAL JOIN publisher
WHERE category = 'COMPUTER';

17


In Oracle11g, tables can be linked through which clause(s)?


SELECT


FROM


WHERE


both b and c

both b and c

18


Which of the following is a valid SQL statement?



SELECT c.customer#, order#, orderdate, shipdate
FROM customers c NATURAL JOIN orders c;



SELECT * FROM customers JOIN orders ON (customer#);



SELECT c.customer#, order#, orderdate, shipdate
FROM customers c, orders o
WHERE c.customer# = o.customer#;



both b and c

SELECT c.customer#, order#, orderdate, shipdate
FROM customers c, orders o
WHERE c.customer# = o.customer#;

19


Which of the following SQL statements will display books that have not been ordered recently?


SELECT title
FROM books, orderitems
WHERE books.isbn orderitems.isbn;


SELECT title
FROM books NATURAL JOIN orderitems
WHERE JOIN IS NULL;


SELECT title FROM books NATURAL JOIN orderitems
MINUS
SELECT title FROM books;


SELECT title FROM books
MINUS
SELECT title FROM books NATURAL JOIN orderitems;

SELECT title FROM books
MINUS
SELECT title FROM books NATURAL JOIN orderitems;

20


Which of the following can only be used to link tables that have a common column?


FULL OUTER JOIN


JOIN...ON


NATURAL JOIN


CROSS JOIN

NATURAL JOIN

21


A column qualifier is separated from the column using which symbol?


comma (,)


plus sign (+)


period (.)


percent sign (%)

period (.)

22


The outer join operator in the WHERE clause cannot be used with which of the following operators?


IN


OR


AND


both a and b

both a and b

23


Which of the following queries will display the first and last name of the individual who referred another customer, along with the customer# of the referred customer?


SELECT r.firstname, r.lastname, c.customer#
FROM customers r, customers c
WHERE r.customer# = c.referred;


SELECT r.firstname, r.lastname, c.customer#
FROM customers r JOIN customers c
ON r.customer# = c.referred;


SELECT r.firstname, r.lastname, c.customer#
FROM customers r NATURAL JOIN customers c;


both a and b

both a and b

24


Which of the following SQL statements will display the title of each book in the BOOKS table and the name of its publisher?


SELECT title, name
FROM publisher, books;


SELECT title, name
FROM publisher NATURAL JOIN books;


SELECT title, name
FROM publisher, books
WHERE p.pubid = b.pubid;


both b and c

SELECT title, name
FROM publisher NATURAL JOIN books;

25


Which SQL statement will return the same results as the following SQL statement?
SELECT * FROM orders, customers;


SELECT * FROM orders CROSS JOIN customers;


SELECT * FROM orders, customers
WHERE orders.customer# = customers.customer#;


SELECT * FROM orders, customers
WHERE orders.customer# > customers.customer#;


SELECT * FROM o orders , c customers
WHERE o.customer# = c.customer#;

SELECT * FROM orders CROSS JOIN customers;

26


To display the name of each customer and the ISBN of each book purchased by the customers would require how many joins in the FROM clause of the SQL statement?


4


3


2


1

2

27


How many joining conditions will be required in an SQL statement that is used to determine the gift that corresponds to each book in the BOOKS table?


4


3


2


1

1

28


Which of the following keywords is used to create an equality join?


NATURAL JOIN


JOIN...ON


JOIN...USING


all of the above

all of the above

29



Which of the following SQL statements will display the gift or gifts that should be sent with order# 1003?


SELECT gift
FROM promotion
WHERE order# = 1003;


SELECT gift
FROM promotion NATURAL JOIN books
WHERE order# = 1003;


SELECT gift
FROM promotion, orderitems oi, books b
WHERE retail BETWEEN minretail AND maxretail
AND oi.isbn = b.isbn AND order# = 1003;


none of the above

SELECT gift
FROM promotion, orderitems oi, books b
WHERE retail BETWEEN minretail AND maxretail
AND oi.isbn = b.isbn AND order# = 1003;

30


Which of the following SQL statements will display the title and cost of each book stored in the BOOKS table, as well as the name of the contact person and the phone number to call to reorder the book?


SELECT title, cost, contact, phone
FROM publisher, books;


SELECT title, cost, contact, phone
FROM publisher JOIN books
USING (pubid);


SELECT title, cost, contact, phone
FROM publisher JOIN books
USING (isbn);


SELECT title, cost, contact, phone
FROM publisher JOIN books
USING (contact);

SELECT title, cost, contact, phone
FROM publisher JOIN books
USING (pubid);