Practice Q's 1-7
Practice Q's 1-7
(Chapter 1 - 7)
Chapter 1
1.
2.
3.
4.
5.
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 1 of 17
Version: 5/2/2009
1.
Yes
2.
No
3.
Yes
4.
No
5.
Yes
Chapter 2
1.
2.
3.
No
Yes
4.
Files saved with a .sql extension can be executed with the @ command.
Yes
No
5.
The push pin icon in SQL Developer allows you to toggle between the
worksheets.
Yes
No
6.
The SQL*Plus buffer shows the last SQL command you typed.
No
Yes
7.
8.
9.
You must always type column and table names in lowercase letters for the
SQL statement to execute correctly.
Yes
No
1.
Yes
2.
No
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 3 of 17
Version: 5/2/2009
3.
No
4.
Yes
5.
No
The push pin icon in SQL Developer allows you to toggle between the
worksheets.
6.
Yes
The SQL*Plus buffer shows the last SQL command you typed.
7.
Yes
8.
Yes
9.
No
You must always type column and table names in lowercase letters
for the SQL statement to execute correctly.
Note: The SQL language's keywords are not case-sensitive. For clarity and
readability you follow a naming convention. The convention used in this book
is listed in Appendix B, "SQL Formatting Guidelines."
Chapter 3
1.
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 4 of 17
Version: 5/2/2009
2.
3.
You can test for null values by using an empty string such as the following:
SELECT * FROM course WHERE prerequisite = ''.
No
Yes
4.
5.
The AND and OR logical operators can only be combined with the use of
parentheses.
Yes
No
6.
7.
8.
9.
1.
Yes
2.
No
3.
No
You can test for null values by using an empty such as the following:
4.
Yes
5.
No
The AND and OR logical operators can only be combined with the use
of parentheses.
6.
Yes
7.
Yes
8.
Yes
9.
No
Chapter 4
1.
easily.
Yes
No
2.
3.
4.
5.
6.
7.
Unlike many other character functions, the LENGTH and INSTR function
return a NUMBER.
No
Yes
8.
The following SQL query returns -1: SELECT SIGN(-45) FROM dual
Yes
No
9.
You can substitute the NVL function with the COALESCE function.
No
Yes
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 7 of 17
Version: 5/2/2009
10 .
1.
No
2.
Yes
3.
Yes
4.
No
5.
Yes
6.
No
7.
Yes
8.
Yes
The following SQL query returns -1: SELECT SIGN(-45) FROM dual
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 8 of 17
Version: 5/2/2009
9.
Yes
You can substitute the NVL function with the COALESCE function.
10.
Yes
Chapter 5
1.
No
Yes
2.
3.
4.
TO_CHAR(TO_NUMBER(-999.999))
dual
TO_CHAR(TO_NUMBER('$-999.999'))
dual
TO_NUMBER(TO_CHAR(999.999))
dual
TO_CHAR(TO_NUMBER('-999.999'))
dual
5.
6.
Invalid query.
Yes
No
7.
No
Yes
8.
No
Yes
9.
The following shows one of the default formats for the TIMESTAMP WITH
TIME ZONE data type. 'DD-MON-RR HH.MI.SS.FF AM TZH:TZM'.
Yes
No
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 10 of 17
Version: 5/2/2009
10.
1.
Yes
2.
Oracle error
message
SELECT TO_NUMBER('ABC')
FROM dual
A text literal such as 'ABC' cannot be converted into a number.
Which of the following SQL statements results in this error: ORA01722: invalid number
3.
SELECT TO_CHAR(TO_NUMBER('$-999.999'))
FROM dual
A text literal such as '$-999.99' cannot be converted into a number. Use the
SUBSTR function to remove the $ symbol, and then convert to a number.
4.
5.
FmDay
mm/dd/yyyy
6.
No
SELECT *
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 11 of 17
Version: 5/2/2009
FROM section
WHERE start_date_time BETWEEN
TO_DATE('31-DEC-2200','DD-MON YYYY')
AND TO_DATE('01/01/1900','MM/DD/YYYY')
The BETWEEN operator requires the lowest end of the range first, then the
highest. Instead, write it as follows:
SELECT *
FROM section
WHERE start_date_time BETWEEN
TO_DATE('01/01/1900','MM/DD/YYYY')
AND TO_DATE('31-DEC-2200','DD-MON-YYYY')
7.
Yes
SELECT start_date_time
FROM section
WHERE TO_CHAR(start_date_time, 'DD-MON-YYYY') < '01JAN-2010'
Do not use the TO_CHAR function on the START_DATE_TIME column, because
the query returns the incorrect result.
8.
No
This query does not result in an error. But there are two ways to improve the
query. Firstly, the text literal '22-MAR-99' relies on implicit conversion to the
DATE data type and does not specify the format mask. If this statement is
executed on a system with a different default format mask, it results in an
error. Secondly, it does not specify the century in the text literal. Lastly, always
consider the time component. The query could be improved as follows:
9.
Yes
The following shows one of the default formats for the TIMESTAMP
WITH TIME ZONE data type. 'DD-MON-RR HH.MI.SS.FF AM TZH:TZM'.
10.
Yes
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 12 of 17
Version: 5/2/2009
Chapter 6
1.
2.
3.
4.
5.
The MIN and MAX functions work only on the NUMBER data type.
No
Yes
6.
Yes
No
7.
Yes
No
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 13 of 17
Version: 5/2/2009
1.
Yes
2.
Yes
3.
Yes
4.
Yes
5.
No
The MIN and MAX functions work only on the NUMBER data type.
6.
No
7.
No
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 14 of 17
Version: 5/2/2009
Chapter 7
1.
2.
SELECT
FROM
ON
WHERE
Yes
No
3.
Show the course description of the course 330 in which the student
with the id 221 is enrolled. Show also the grade type.
Show the description, grade type, and grade for course number 330
and the student with the id of 221.
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 15 of 17
Version: 5/2/2009
Invalid query.
The SELECT statement causes a Cartesian product.
4.
Show students with the first and last name of Torres and their
corresponding zip code. Include all the columns of the ZIPCODE
table in the result.
Invalid query.
Show the first and last name of students with the last name of Torres.
1.
SELECT
FROM
WHERE
AND
AND
2.
Yes
SELECT
FROM
WHERE
AND
SELECT
FROM
ON
WHERE
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 16 of 17
Version: 5/2/2009
3.
SELECT
FROM
WHERE
AND
AND
AND
AND
AND
Show the description, grade type, and grade for course number 330
and the student with the id of 221.
4.
SELECT
FROM
ON
WHERE
Show the first and last name of students with the last name of Torres
and their corresponding zip code. Include all the columns of the
ZIPCODE table in the result.
Additional Q&A for Chapters 1-7; Oracle SQL by Example by Alice Rischert; Prentice Hall (2009)
Page 17 of 17
Version: 5/2/2009