Final Exam-Review Questions
Final Exam-Review Questions
2. SQL is considered difficult to learn; its command set has a vocabulary of more than 300 words.
a. True
b. False
4. The COMMIT command does not permanently save all changes. In order to do that, you must use SAVE.
a. True
b. False
6. Although SQL commands can be grouped together on a single line, complex command sequences are best shown on
separate lines, with space between the SQL command and the command’s components.
a. True
b. False
7. An alias cannot be used when a table is required to be joined to itself in a recursive query.
a. True
b. False
8. Oracle users can use the Access QBE (query by example) query generator.
a. True
b. False
9. You can select partial table contents by naming the desired fields and by placing restrictions on the rows to be included
in the output.
a. True
Page 1
Final Exam Review on Chpter 7: Introduction to Structured Query Language (SQL)
b. False
12. Date procedures are often more software-specific than other SQL procedures.
a. True
b. False
13. SQL allows the use of logical restrictions on its inquiries such as OR, AND, and NOT.
a. True
b. False
14. You cannot insert a row containing a null attribute value using SQL.
a. True
b. False
15. ANSI-standard SQL allows the use of special operators in conjunction with the WHERE clause.
a. True
b. False
16. The conditional LIKE must be used in conjunction with wildcard characters.
a. True
b. False
18. Some RDBMSs, such as Microsoft Access, automatically make the necessary conversions to eliminate case
sensitivity.
a. True
b. False
19. The COUNT function is designed to tally the number of non-null "values" of an attribute, and is often used in
conjunction with the DISTINCT clause.
Page 2
Final Exam Review on Chpter 7: Introduction to Structured Query Language (SQL)
a. True
b. False
20. Numeric functions take one numeric parameter and return one value.
a. True
b. False
Multiple Choice
21. The SQL data manipulation command HAVING:
a. restricts the selection of rows based on a conditional b. restricts the selection of grouped rows based on a
expression. condition.
c. modifies an attribute’s values in one or more table’s d. groups the selected rows based on one or more
rows. attributes.
22. The SQL command that allows a user to permanently save data changes is _____.
a. INSERT b. SELECT
c. COMMIT d. UPDATE
23. The _____ command defines a default value for a column when no value is given.
a. CHECK b. UNIQUE
c. NOT NULL d. DEFAULT
24. The _____ command restricts the selection of grouped rows based on a condition.
a. DISPLAY b. HAVING
c. FROM d. CONVERT
25. A(n) _____ query specifies which data should be retrieved and how it should be filtered, aggregated, and displayed.
a. INSERT b. SELECT
c. COMMIT d. UPDATE
26. A(n) _____ is an alternate name given to a column or table in any SQL statement.
a. alias b. data type
c. stored function d. trigger
27. According to the rules of precedence, which of the following computations should be completed first?
a. Additions and subtractions b. Multiplications and divisions
c. Operations within parentheses d. Power operations
28. Which query is used to list a unique value for V_CODE, where the list will produce only a list of those values that are
different from one another?
Page 3
Final Exam Review on Chpter 7: Introduction to Structured Query Language (SQL)
a. SELECT ONLY V_CODE b. SELECT UNIQUE V_CODE
FROM PRODUCT; FROM PRODUCT;
c. SELECT DIFFERENT V_CODE d. SELECT DISTINCT V_CODE
FROM PRODUCT; FROM PRODUCT;
29. When using a(n) _____ join, only rows from the tables that match on a common value are returned.
a. full b. outer
c. inner d. set
30. A(n) _____ join will select only the rows with matching values in the common attribute(s).
a. natura b. outer
l
c. full d. cross
31. If a designer wishes to create an inner join, but the two tables do not have a commonly named attribute, he can use
a(n) _____ clause.
a. OF b. USING
c. HAS d. JOIN ON
32. A(n) _____ join returns not only the rows matching the join condition (that is, rows with matching values in the
common columns) but also the rows with unmatched values.
a. outer b. inner
c. equi- d. cross
34. A(n) _____ join performs a relational product (also known as the Cartesian product) of two tables.
a. full b. cross
c. natura d. equi-
l
35. How many rows would be returned from a cross join of tables A and B, if A contains 8 rows and B contains 18?
a. 8 b. 18
c. 2 d. 144
6
38. The special operator used to check whether an attribute value is within a range of values is _____.
a. BETWEE b. NULL
N
c. LIKE d. IN
39. The special operator used to check whether an attribute value matches a given string pattern is _____.
a. BETWEE b. IS NULL
N
c. LIKE d. IN
40. The SQL aggregate function that gives the number of rows containing non-null values for a given column is _____.
a. COUNT b. MIN
c. MAX d. SUM
41. A(n) _____ is a query that is embedded (or nested) inside another query.
a. alias b. operato
r
c. subquery d. view
42. In subquery terminology, the first query in the SQL statement is known as the _____ query.
a. oute b. left
r
c. inne d. base
r
43. The special operator used to check whether a subquery returns any rows is _____.
a. BETWEEN b. EXISTS
c. LIKE d. IN
45. The _____ function returns the current system date in MS Access.
a. TO_DATE() b. SYSDATE()
c. DATE() d. TODAY()
46. When using the Oracle TO_DATE function, the code _____ represents a three-letter month name.
a. MON b. MM3
c. MONTH d. MM
47. _____ is a string function that returns the number of characters in a string value.
a. LENGTH b. SUBSTRING
c. CONCAT d. UCASE
48. The Oracle _____ function compares an attribute or expression with a series of values and returns an associated value
or a default value if no match is found.
a. NVL b. TO_CHAR
c. DECODE d. CONVERT
Completion
51. The basic SQL vocabulary has fewer than _100_words.
52. The _unique_ specification is used to avoid having duplicated values in a column.
53. In the SQL environment, the word _query_ covers both questions and actions.
54. A(n) _wildcard_ character is a symbol that can be used as a general substitute for other characters or commands.
55. The _join_ condition is generally composed of an equality comparison between the foreign key and the primary key of
related tables.
Page 6
Final Exam Review on Chpter 7: Introduction to Structured Query Language (SQL)
56. A(n) _cascading_ order sequence is a multilevel ordered sequence that can be created easily by listing several
attributes, separated by commas, after the ORDER BY clause.
57. An alias is especially useful when a table must be joined to itself in a(n) _recursive_ query.
58. The _SELECT_ command, coupled with appropriate search conditions, is an incredibly powerful tool that enables a
user to transform data into information.
59. A specialty field in mathematics, known as _boolean_ algebra, is dedicated to the use of logical operators.
61. Rows can be grouped into smaller collections quickly and easily using the _GROUP BY_ clause within the SELECT
statement.
62. The _HAVING_ clause of the GROUP BY statement operates very much like the WHERE clause in the SELECT
statement.
63. A(n) _subquery_, also known as a nested query or an inner query, is a query that is embedded (or nested) inside
another query.
64. DATE() and SYSDATE are special functions that return today’s date in MS Access and _Oracle_, respectively.
65. _CAST and CONVERT_ functions allow you to take a value of a given data type and convert it to the equivalent
value in another data type.
66. “_Union-compatible_” means that the names of the relation attributes must be the same and their data types must be
alike.
67. The _MINUS_ statement in SQL combines rows from two queries and returns only the rows that appear in the first set
but not in the second.
68. The _IN_ operator could be used in place of INTERSECT if the DBMS does not support it.
69. The _NOT IN_ operator could be used in place of EXCEPT (MINUS) if the DBMS does not support it.
70. The syntax of the EXCEPT statement in Oracle is _____.SELECT expression1, expression2, ...
expression_n
FROM tables
Page 7
Final Exam Review on Chpter 7: Introduction to Structured Query Language (SQL)
[WHERE conditions]
MINUS
SELECT expression1, expression2, ... expression_n
FROM tables
[WHERE conditions];
Essay
71. Explain the SQL function categories.
1. SQL is a data definition language (DDL). It includes commands to create database objects such
as tables, indexes, and views, as well as commands to define access rights to those databases
objects.
2. SQL is a data manipulation language (DML). It includes commands to insert, update, delete,
and retrieve data within the database tables.
.
72. What are the wildcard characters that are used with the LIKE command? Provide one or more examples of each.
The LIKE special operator is used in conjunction with wildcards to find patterns within string
attributes. Standard SQL allows a user to use the percentage sign (%) and underscore (_) wildcard
characters to make matches when the entire string is not known:
% means any and all following or preceding characters are eligible. For example:
‘J%’ includes Johnson, Jones, Jernigan, July, and J-231Q.
‘Jo%’ includes Johnson and Jones.
‘%n’ includes Johnson and Jernigan.
_ means any one character may be substituted for the underscore. For example:
‘_23-456-6789’ includes 123-456-6789, 223-456-6789, and 323-456-6789.
‘_23-_56-678_’ includes 123-156-6781, 123-256-6782, and 823-956-6788.
‘_o_es’ includes Jones, Cones, Cokes, totes, and roles.
Can contain SQL Procedural Language statements and features which support the implementation of control-flow logic
around traditional static and dynamic SQL statements.
Are easy to implement, because they use a simple high-level, strongly typed language.
SQL functions are more reliable than equivalent external functions.
Support input parameters.
SQL scalar functions return a scalar value.
SQL table functions return a table result set.
Support a simple, but powerful condition and error-handling model.
Allow you to easily access the SQLSTATE and SQLCODE values as special variables.
Page 8
Final Exam Review on Chpter 7: Introduction to Structured Query Language (SQL)
Reside in the database and are automatically backed up and restored as part of backup and restore operations.
Can be invoked wherever expressions in an SQL statement are supported.
Support nested functions calls to other SQL functions or functions implemented in other languages.
Support recursion (when dynamic SQL is used in compiled functions).
Can be invoked from triggers.
Page 9