Professional Documents
Culture Documents
DBMSregi
DBMSregi
DBMSregi
1. Question 1
The interface between an application program and the DBMS is usually provided by the
1. back end
2. front end
3. data access APIPI
4. programmer
4. Question 4
The SQL statements that work with the data in a database are called
1. data manipulation language
2. data manipulation statements
3. data modification language
4. data modification statements
5. Question 5
Which of the following types of statements does not modify the data in a table?
1. SELECT
2. INSERT
3. UPDATE
4. DELETE
7. Question 7
Which of the following recommendations won’t improve the readability of your SQL statements?
1. Break long clauses into multiple lines.
2. Use comments to describe what each statement does.hat each statement does.
3. Start each clause on a new line.
4. Indent continued lines
8. Question 8
E2
1. Question 1
To model a database on a real-world system, you typically represent each real-world entity as a
1. column
2. row
3. table
4. cell
2. Question 2
When you identify the data elements in a new database, you typically subdivide data elements into
1. the largest practical components
2. the smallest practical components
3. components that can be easily parsed each time you use them
3. Question 3
If two tables have a one-to-many relationship, which of the following do you typically need to add to
the table on the “many” side?
1. a primary key column
2. a foreign key column
3. an indexed column
4. a linking column
4. Question 4
If two tables have a many-to-many relationship, which of the following do you typically use to relate
their rows?
1. a linking table
2. a master table
3. an index in each table
4. a foreign key column in each table
5. Question 5
Which of the following statements about the primary key for a table is not true?
1. Its values must be unique.
2. Its values can never change.
3. Its values should be short.
4. It can consist of two or more columns.
6. Question 6
What type of constraints do you need to define to use declarative referential integrity?
1. unique
2. not null
3. primary key
4. foreign key
7. Question 7
Which of the following does not violate the referential integrity of a database?
1. inserting a new row into a table with a foreign key that doesn’t match a primary key in the
related table
2. updating a foreign key with a value that doesn’t match a primary key in the related table
3. updating a primary key in a primary key table without also updating the foreign keys for the
related rows in all related tables
4. deleting a row in a foreign key table without deleting the related row in the related
primary key table
8. Question 8
To enforce referential integrity for a delete operation, a MySQL database can (Choose all applied)
1. return an error instead of deleting any rows
2. set the foreign key values in the related rows to null
3. delete the related rows in the foreign key table
9. Question 9
Which of the following is not a good guideline for deciding when to create an index for a column?
1. The column is a foreign key.
2. The column is frequently updated.
3. The column is frequently used in search conditions or joins.
4. The column contains a large number of distinct values.
10. Question 10
To apply the second normal form, you move columns that don’t depend on the entire primary key to
another table and establish a relationship between the two tables. This
1. reduces redundancy but makes maintenance more difficult
2. reduces redundancy and makes maintenance easier
3. increases redundancy but makes maintenance easier
4. increases redundancy but makes the data more consistent
12. Question 12
Before you can normalize a data structure, you must do all but one of the following. Which one is it?
1. identify the data elements
2. identify the tables and assign columns
3. identify the primary and foreign keys
4. identify the indexes
15. Question 15
Which of the following statements is not true about a database that’s normalized to the fifth normal
form?
1. It contains no multivalued dependencies.
2. Fewer joins are required to retrieve data.
3. Data redundancy is minimized or eliminated.
E3
1. Question 1
Which of the following statements is not true about the CHAR type?
1. It uses the same amount of storage for each value.
2. It includes one byte that indicates the actual length of the string.of the string.
3. When used with the utf8mb4 character set, four bytes must be reserved for each character.
4. It can be used to store numbers that aren’t used in numeric operations.
4. Question 4
All of the following values can be stored in a column that’s defined as DECIMAL(6,2), except
1. -246
2. 0
3. 2479.95
4. 32492.05
7. Question 7
Which of the following indicates the total number of digits that can be stored in a real number?
1. Size
2. precisionion
3. scale
4. significance
8. Question 8
Which of the following types of real numbers is considered an exact numeric type?
1. DOUBLE
2. FLOAT
3. DECIMALL
4. all of the given options
9. Question 9
Which of the following types of data would you not store in a binary large object (BLOB) type?
1. image files
2. text files
3. sound files
4. video files
14. Question 14
Which of the following is not true if you use a string in a numeric expression?
1. If the string contains only numbers, MySQL returns those numbers.
2. If the string starts with a number, MySQL returns that number and each successive number
until it encounters a letter or special character.
3. If the string starts with a letter or special character, MySQL returns a value of zero.
4. If the string doesn’t contain any numbers, an error occurs.
E4a
Which of the following engines supports foreign keys and transactions and is the default storage
engine for MySQL 5.5 and later.
1. InnoDB
2. MyISAM
3. BLACKHOLE
4. none of the given options
5. Question 5
A character set determines the characters that are used to represent
1. the binary types in a database
2. the character types in a databasee
3. the numeric types in a database
4. all of the given options
E4b
1. Question 1
You use data definition language (DDL) to create, modify, and delete
1. tables only
2. databases and tables only
3. tables and indexes only
4. databases, tables, and indexess
2. Question 2
Which of the following attributes do you use to generate the values for a column as unique numbers in
sequence?
1. AUTO_NUMBER
2. UNIQUE_NUMBER
3. AUTO_INCREMENT
4. UNIQUE_INCREMENT
5. Question 5
Which of the following can you not specify for a column when you create a table using the CREATE
TABLE statement?
1. data type
2. value
3. column name
4. attributes
7. Question 7
Which of the following statements do you use to delete all data from a table without deleting the
definition for the table?
1. RENAME TABLE
2. TRUNCATE TABLELE
3. CREATE TABLE
4. DROP TABLE
9. Question 9
When you code a table-level constraint, the constraint can refer to data in more than one
1. database
2. table
3. column
4. value
13. Question 13
If you omit both NULL and NOT NULL from the list of column attributes in a CREATE TABLE
statement, which is the default setting?
1. NULL
2. NOT NULL
3. This will cause an error
4. none of the given options
14. Question 14
E5
1. Which of the following statements is true when you use MySQL Workbench to run INSERT,
UPDATE, and DELETE statements?
1. By default, the changes are automatically committed to the database.
2. If autocommit mode is on, you can rollback the changes by clicking on the Rollback button.
3. If autocommit mode is on, you can commit the changes by clicking on the Commit button.
4. By default, the changes are rolled back when you exit MySQL Workbench unless you
commit them.
2. Question 2
Assuming that all of the table and column names are spelled correctly, what’s wrong with the INSERT
statement that follows?
INSERT INTO invoices
(vendor_id, invoice_number, invoice_total, payment_total, credit_total,
terms_id, invoice_date, invoice_due_date)
VALUES
(97, '456789', 8344.50, 0, 0, 1, '2012-08-31')
1. The column names in the column list are in the wrong sequence.
2. All of the values should be enclosed by single quotes.
3. There are too many items in the VALUES list.
4. The number of items in the column list doesn’t match the number in the VALUES list.
match the number in the VALUES list.
3. Question 3
Which of the following statements best describes what this INSERT statement does?
INSERT INTO invoices_copy
SELECT *
FROM invoices
WHERE terms_id = 1
1. Adds one row from the Invoices table to the Invoices_Copy table.
2. Adds all of the rows in the Invoices table that have 1 in the terms_id column to the
Invoices_Copy table.
3. Adds all of the rows in the Invoices table to the Invoices_Copy table and sets the terms_id
column to 1 in each row.
4. Updates all of the rows in the Invoices_Copy table that have 1 in the terms_id column to the
rows in the Invoices table.
4. Question 4
Which of the following statements best describes what this UPDATE statement does?
UPDATE invoices
SET credit_total = invoice_total - payment_total
WHERE vendor_id = 10
AND invoice_total - payment_total - credit_total > 0
1. Updates the credit_total column for all invoices with a balance due so they don’t have a
balance due.
2. Updates the credit_total column for the first invoice with 10 in the vendor_id column and a
balance so it doesn’t have a balance due.
3. Updates the credit_total column for all invoices with 10 in the vendor_id column and
a balance due so they don’t have a balance due.
4. Updates the credit_total column for all invoices with a balance due
5. Question 5
Which of the following statements about creating a table using the CREATE TABLE AS statement
with a SELECT statement is not true?
1. The table must not exist.
2. Each column name in the SELECT clause must be unique.
3. You can include any of the clauses of the SELECT statement.
4. The definitions of primary keys, foreign keys, and indexes are included in the new
table.cluded in the new table.
6. Question 6
(Refer to code example 5-1.) What are the values of the team_id, team_name, and team_rank columns
after the following statement is executed, assuming that the Teams table has one row in it with a
team_id of 1?
INSERT INTO teams
VALUES (DEFAULT, NULL, 3)
1. 0, NULL, 0
2. 2, NULL, 1
3. 0, NULL, 3
4. 2, NULL, 3
7. Question 7
When you use a subquery to insert rows from one table into another table, which of the following
statements is not true?
1. The target table must already exist.
2. You must omit the column list from the INSERT statement.ent.
3. You must omit the VALUES clause from the INSERT statement.
4. You must include a SELECT statement that retrieves the rows to be inserted.
8. Question 8
Which of the following statements would you use to change the invoice_total value in the Invoices
table so it’s 1% less than the current invoice total for every vendor in the state of Arizona?
1. UPDATE invoices
SET invoice_total = invoice_total - (invoice_total * .01)
WHERE vendor_id IN
(SELECT vendor_id
FROM vendors
WHERE vendor_state = 'AZ')UPDATE invoices
2. UPDATE invoices
SET invoice_total = invoice_total * .01
WHERE vendor_id IN
(SELECT vendor_id
FROM vendors
WHERE vendor_state = 'AZ')
3. UPDATE invoices
SET invoice_total = invoice_total - (invoice_total * .01)
WHERE vendor_id =
(SELECT vendor_id
FROM vendors
WHERE vendor_state = 'AZ')
4. UPDATE invoices
SET invoice_total = invoice_total * .01
WHERE vendor_id =
(SELECT vendor_id
FROM vendors
WHERE vendor_state = 'AZ')
9. Question 9
Before you can delete a row that has related rows in another table, you should
1. turn safe mode off
2. change all of the related rows so they point to a row other than the one you want to delete
3. delete the related rows
4. delete the related table
E6
1. Question 1
When you code a SELECT statement, you must code the four main clauses in the following order
1. SELECT, FROM, ORDER BY, WHERE
2. SELECT, ORDER BY, FROM, WHERE
3. SELECT, WHERE, ORDER BY, FROM
4. SELECT, FROM, WHERE, ORDER BY
2. Question 2
Which clause of the SELECT statement specifies the table that contains the data to be retrieved?
1. SELECT
2. FROM
3. WHERE
4. ORDER BY
3. Question 3
Which clause do you use to filter the rows returned by a SELECT statement?
1. SELECT
2. FROM
3. WHERE
4. ORDER BY
4. Question 4
How would you code a SELECT clause so it returns all columns from the base table?
1. SELECT ALL
2. SELECT COLUMNS
3. SELECT *.*
4. SELECT *
5. Question 5
When you code a calculated value in a SELECT clause, the expression for the calculated value can
include
1. arithmetic operators only
2. arithmetic operators and functions onlys only
3. arithmetic operators, comparison operators, and functions only
4. arithmetic operators, comparison operators, logical operators, and functions
6. Question 6
Which of the following SELECT clauses could you use to assign an alias to the invoice_total column?
(Choose all applied)
1. SELECT invoice_number, invoice_date, invoice_total total
2. SELECT invoice_number, invoice_date, invoice_total AS total
3. SELECT invoice_number, invoice_date, invoice_total : total
8. Question 8
Which of the following expressions does not compute 10% of the balance due if balance due is the
invoice total minus the credit total minus the payment total?
1. invoice_total - credit_total - payment_total / 10
2. (invoice_total - payment_total - credit_total) / 10
3. (invoice_total - (payment_total + credit_total)) * 0.10
4. ((invoice_total - payment_total) - credit_total) / 10
9. Question 9
Which of the following can you not code in a SELECT clause when you omit the FROM clause from
a SELECT statement?
1. a literal value
2. an arithmetic expression
3. a function
4. a base table columnumn
10. Question 10
Which of the following WHERE clauses will return vendor names from A to C?
1. WHERE vendor_name = D
2. WHERE vendor_name < 'D'
3. WHERE vendor_name = 'D'
4. WHERE vendor_name < 'C'
11. Question 11
When coded in a WHERE clause, which of the following search conditions will not return a result set
that includes all invoices with an invoice_total value of $1000 or less?
1. invoice_total <= 1000
2. NOT (invoice_total > 1000)
3. invoice_total IN (0, 1000)
4. invoice_total BETWEEN 0 AND 1000
12. Question 12
When coded in a WHERE clause, which search condition will return invoices when payment_date
isn’t null and invoice_total is greater than or equal to $500?
1. payment_date IS NULL AND invoice_total > 500
2. payment_date IS NOT NULL OR invoice_total >= 500
3. NOT (payment_date IS NULL AND invoice_total <= 500)
4. payment_date IS NOT NULL AND invoice_total >= 500
13. Question 13
Which of the following would return a maximum of 7 rows, starting with the 5th row?
1. LIMIT 7, 4
2. LIMIT 4, 7
3. LIMIT 4
4. LIMIT 4, 6
16. Question 16
When coded in a WHERE clause, which of the following would not return rows for vendors in the
cities of San Diego and Santa Ana?
1. vendor_city LIKE 'SAN%'
2. vendor_city REGEXP 'NA$'
3. vendor_city REGEXP '^SA'
17. Question 17
Which of the following statements about sorting the rows in a result set is not true?
1. Null values always appear first in the sort sequence.
2. The sort order is determined by the character set you’re using.
3. A column that’s used for sorting must be included in the SELECT clause.T clause.
4. The rows can be sorted by any number of columns in either ascending or descending
sequence
18. Question 18
Which of the following SELECT statements would you use to prevent duplicate rows from being
returned?
1. SELECT vendor_id DISTINCT
FROM invoices
ORDER BY vendor_id
2. SELECT DISTINCT vendor_id
FROM invoices
ORDER BY vendor_id
3. SELECT vendor_id
FROM DISTINCT invoices
ORDER BY vendor_id
4. SELECT vendor_id
FROM invoices
WHERE DISTINCT
ORDER BY vendor_id
E7
1. Question 1
Which of the following is not a reason for using the explicit syntax instead of the implicit syntax for
joins? The explicit syntax
1. is easier to read and understand
2. lets you separate the join and search conditions
3. is an older syntax that works with legacy code
4. lets you combine inner and outer joins
6. Question 6
In a cross join, all of the rows in the first table are joined with all of the
1. distinct rows in the second table
2. matched rows in the second table
3. unmatched columns in the second table
4. rows in the second table
7. Question 7
When you code a union that combines two result sets, which of the following is not true?
1. Each result set must have the same number of columns.
2. The result sets may or may not have any duplicate rows.
3. The corresponding columns in the result sets must have compatible data types.
4. The result sets must be derived from different tables.
8. Question 8
To join each row from the first table with each row from the second table, you use a
1. cross join
2. natural join
3. left join
4. right join
16. Question 16
When you use the implicit syntax for coding inner joins, the join conditions
1. are coded on the ON clause
2. are coded on the USING clause
3. are coded on the WHERE clause
4. aren’t coded
17. Question 17
To use a self join, you must do all but one of the following. Which one is it?
1. assign aliases to the tables
2. qualify each column name with an alias
3. Include the DISTINCT keyword
E8
Question 1
The six clauses of the SELECT statement must be coded in the following order:
1. SELECT, FROM, GROUP BY, HAVING, WHERE, ORDER BY
2. SELECT, FROM, WHERE, ORDER BY, GROUP BY, HAVING
3. SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY
4. SELECT, FROM, ORDER BY, WHERE, GROUP BY, HAVING
Question 2
You can code an expression that results in a date value for all but one of the following aggregate
functions. Which one is it?
1. MIN
2. MAX
3. AVG
4. COUNT
Question 3
Which of the statements below best describes the result set returned by this SELECT statement?
SELECT COUNT(DISTINCT invoice_id) AS 'count',
ROUND(AVG(line_item_amount), 2) AS average_amount
FROM invoice_line_items
5. A single row with a count of the rows in the invoice_line_items table and the average amount of all
the line items
1. A single row with a count of the invoices in the invoice_line_items table and the
average amount of all the line items
2. A row for each of the invoices in the invoice_line_items table with a count of the line items
and the average amount of the line items for that invoice
Question 4
Question 5
5. 3. can use non-aggregate search conditions but can’t use aggregate search
conditionsconditions
4.must refer to columns in the SELECT clause
Question 6
When a SELECT statement includes a GROUP BY clause, the SELECT clause can include all but one of
the following. Which one is it?
1. columns used for grouping
2. columns that are functionally dependent on a column used for grouping
3. columns that are not functionally dependent on a column used for groupingng
4. aggregate functions
2. Question 7
Which of the statements below best describes the result set returned by this SELECT statement?
SELECT vendor_id,
SUM(invoice_total - payment_total - credit_total) AS column_2
FROM invoices
WHERE invoice_total - payment_total - credit_total > 0
GROUP BY vendor_id
ORDER BY vendor_id
1. The unpaid balance for each invoice
2. The total unpaid balance due for each vendor_id
3. The total amount invoiced by each vendor_id
4. The total of paid invoices for each vendor_id
Question 8
Which of the statements below best describes the result set returned by this SELECT statement?
SELECT vendor_state, COUNT(*) AS column_2
FROM vendors
GROUP BY vendor_state
HAVING COUNT(*) > 1
ORDER BY vendor_state
1.The names of the vendors in each state
2.The duplicate vendors from each state
3. The number of vendors in each state
4. The number of vendors in each state that has more than one vendors more than one as more
than one vendor
Question 9
(Please refer to code example 6-1.) When this summary query is executed, the result set will contain
one summary row for
1. each city with invoice totals over $500
2. each vendor with invoice totals over $500
3. each city with invoice average over $500
4. each vendor with invoice average over $500
5. Question 10
(Please refer to code example 6-1.) Although this query runs as coded, it contains this logical error:
1. The condition in the WHERE clause should be coded in the HAVING clause.
2. The column name for the fifth column in the result set doesn’t match the data.
3. The three columns in the ORDER BY clause should use the DESC keyword so the city totals
will be in the right sequence.
4. The condition in the HAVING clause should be coded in the WHERE clause.
6. Question 11
All but one of the following is true about the WITH ROLLUP operator. Which one is it?
1. It adds a summary row for each group specified in the GROUP BY clause.
2. It adds a summary row to the end of the result set.
3. It is part of standard SQL.
4. It is coded on the GROUP BY clause.
7. Question 12
Which of the following is a common reason for using the IF function with the GROUPING function?
1. To replace the nulls that are generated by WITH ROLLUP with literal values.
2. To replace the nulls in grouped columns with literal values.
3. To add a summary row for each group only if the group has more than one row.
4. To add a summary row for the result set only if the result set has more than one row.
9. Question 14
(Refer to code example 6-2.) What rows make up the partitions for the first SUM function?
1. Each row is treated as a separate partition.
2. The rows for each invoice date are treated as a separate partition.
3. The rows for each vendor are treated as a separate partition.
4. All of the rows are treated as a single partition.
10. Question 15
(Refer to code example 6-2.) What rows make up the partitions for the second SUM function?
1. Each row is treated as a separate partition.
2. The rows for each invoice date are treated as a separate partition.
3. The rows for each vendor are treated as a separate partition.partition.
4. All of the rows are treated as a single partition.
11. Question 16
Which of the following statements is not true about a frame for an aggregate window function?
1. It defines a subset of the current partition.
2. If you don’t specify the ending row for a frame, the ending row is the last row in the
partition.
3. It can be defined as the number of rows before and after the current row.
4. It can be defined as a range of values based on the value of the current row.
13. Question 18
To define peer rows for an aggregate window function, you must include all but one of the following
clauses. Which one is it?
1. PARTITION BY
2. RANGE
3. BETWEEN
4. ORDER BY
14. Question 19
Which of the following is not true about calculating a moving average for an aggregate window
function?
1. The frame must be defined using the ROWS clause.
2. The moving average always includes the current row.
3. The moving average for the first row in a partition can only include the value of the current
row plus the values of any following rows.
4. To calculate the average, you must use both the SUM and AVG functions.
15. Question 20
Which of the following best describes when you should consider using a named window?
1. Any time a SELECT statement includes two or more aggregate window functions.
2. Any time a SELECT statement includes two or more aggregate window functions that use
partitions.
3. Any time a SELECT statement includes two or more aggregate window functions that
use the same partitions.r more aggregate window functions that use the same partitions.
4. Any time you want to be able to add to the definitions of two or more aggregate window
functions.
E9
1. If introduced as follows, the subquery can return which of the values listed below?
WHERE vendor_id NOT IN (subquery)
1. a single value
2. a list of values
3. a table of values
4. a subquery can’t be introduced in this way
2. If introduced as follows, the subquery can return which of the values listed below?
WHERE (subquery)
1. a single value
2. a list of values
3. a table of values
4. a subquery can’t be introduced in this way
3. If introduced as follows, the subquery can return which of the values listed below?
WHERE 2 < (subquery)
1. a single value
2. a list of values
3. a table of values
4. a subquery can’t be introduced in this way
If introduced as follows, the subquery can return which of the values listed below?
WHERE invoice_total > ALL (subquery)
1. a single value
2. a list of values
3. a table of values
4. a subquery can’t be introduced in this way
5. Question 5
If introduced as follows, the subquery can return which of the values listed below?
SELECT (subquery)
1. a single value
2. a list of values
3. a table of values
4. a subquery can’t be introduced in this way
6. Question 6
If introduced as follows, the subquery can return which of the values listed below?
FROM (subquery)
1. a single value
2. a list of values
3. a table of values
4. a subquery can’t be introduced in this way
7. Question 7
(Refer to code example 7-1.) When this query is executed, the result set will contain
1. one row for each invoice that has a larger balance due than the average balance due for all
invoices
2. one row for the invoice with the largest balance due for each vendor
3. one row for each invoice for each vendor that has a larger balance due than the average
balance due for all invoices
4. one row for each vendor that shows the largest balance due for any of the vendor’s
invoices, but only if the balance due is larger than the average balance due for all
invoices
8. Question 8
(Refer to code example 7-1.) When this query is executed, the number_of_invoices for each row will
show the number
1. 1
2. of invoices in the Invoices table
3. of invoices for each vendor
4. of invoices for each vendor that has a larger balance due than the average balance
due for all invoices
9. Question 9
(Refer to code example 7-1.) When this query is executed, the rows will be sorted by
1. invoice_id
2. vendor_id
3. balance_due in descending sequencedescending sequence
4. vendor_id and then by balance_due in descending sequence
10. Question 10
(Refer to code example 7-2.) When this query is executed, the result table will contain one row for
1. each vendor
2. each vendor in the table named iahe table named ia
3. each invoice
4. each invoice in the table named ia
11. Question 11
(Refer to code example 7-2.) When this query is executed, each row in the result table will show
1. the largest invoice total related to that row
2. the average invoice total related to that row
3. the largest invoice total related to that row, but only if it’s larger than the average for all
invoices
4. the average invoice total related to that row, but only if it’s greater than 100
12. Question 12
In which of the following ways can you not use a subquery in a SELECT statement?
1. In a SELECT clause as a column specification
2. In a FROM clause as a table specification
3. In a WHERE clause as part of a search condition
4. In an ORDER BY clause as a column specification
14. Question 14
Which of the following is not an advantage of using subqueries over using joins?
1. You can use a subquery to pass an aggregate value to the main query.
2. A subquery tends to be more intuitive when it uses an existing relationship between
the two tables.
3. Long, complex queries can sometimes be easier to code using subqueries.
16. Question 16
When the following query is executed, the result set will include one row for each invoice with an
invoice total that’s greater than
SELECT vendor_name, invoice_number, invoice_total
FROM vendors JOIN invoices ON vendors.vendor_id = invoices.vendor_id
WHERE invoice_total > ANY
(SELECT invoice_total
FROM invoices
WHERE vendor_state = 'CA')
1. the minimum invoice total for vendors in California
2. the maximum invoice total for vendors in California
3. the minimum invoice total for vendors in states other than California
4. the maximum invoice total for vendors in states other than California
18. Question 18
Which of the following keywords would you use to introduce a subquery if you want to determine if
the subquery returns one or more rows?
1. ANY
2. SOME
3. EXISTS
4. ALL
19. Question 19
Which of the following statements about common table expressions (CTEs) is not true?
1. A CTE consists of a SELECT statement.
2. A CTE can be used with SELECT, INSERT, UPDATE, and DELETE statements.
3. A CTE can refer to itself
4. A CTE can refer to any other CTE in the same WITH clause.
E10a
1. Question 1
Which of the following is the way to sort a VARCHAR column that contains numbers in numeric
sequence? In the ORDER BY clause
1. use the CAST function to convert the column values to numbers
2. add zeros to the column values using + 0
3. use the LPAD function to pad the numbers with leading zeros
4. all of the given options
2. Question 2
Which of the following statements best describes what this SELECT statement does?
SELECT invoice_number, invoice_date,
CASE
WHEN (SYSDATE() - invoice_date) >= 30 AND (SYSDATE() -
invoice_date) < 60
THEN invoice_total
ELSE 0
END AS "30-60",
CASE
WHEN (SYSDATE() - invoice_date) >= 60 AND (SYSDATE() -
invoice_date) < 90
THEN invoice_total
ELSE 0
END AS "60-90",
CASE
WHEN (SYSDATE() - invoice_date) > 90 THEN invoice_total
ELSE 0
END AS "Over 90"
FROM invoices
1. Displays three columns for each invoice with a value in the third column that indicates how
many days have elapsed between the invoice date and the current date.
2. Displays five columns for each invoice with the invoice total in one of the last three
columns based on how many days have elapsed between the invoice date and the
current date.
3. Displays three columns for each invoice with one of these messages in the third column: 30-
60, 60-90, or Over 90.
4. Displays five columns for each invoice with a message in one of the last three columns based
on how many days have elapsed between the invoice date and the current date.
3. Question 3
Which of the following functions would you use to test an expression and return a value depending on
whether that expression is true or false?
IF
1. REPLACE
2. CASE
3. COALESCE
4. Question 4
Which of the following functions would you use to substitute a non-null value for a null value?
1. IF
2. REPLACE
3. CASE
4. COALESCE
E10c
1. Question 1
If expiration_date contains a value that’s equivalent to November 2, 2018 and the SYSDATE function
returns a value that’s equivalent to December 17, 2018, what will the exp_days column contain when
this code is executed?
expiration_date - SYSDATE() AS exp_days
1. -45
2. -1.5
3. 45
4. 1.5
2. Question 2
Which of the following is not a valid way to avoid search problems when you want to search for rows
that have a specific date in a column that’s defined with the DATETIME data type?
1. use the MONTH, DAYOFMONTH, and YEAR functions in the WHERE clause to search for
just those components
2. search for a range of dates that are greater than or equal to the date you’re looking for, and
less than the date that follows the date you’re looking for
3. use the DATE_FORMAT function in the WHERE clause to return a formatted string that
only contains the month, day, and year
4. use the DATE_ADD function to remove the time values from the dates in each
columnhe dates in each column
3. Question 3
Which code returns the date in the format Friday, April 20th, 2019?
1. DATE_FORMAT('2019-04-20', '%D, %M, %Y')
2. DATE_FORMAT('2019-04-20', '%m/%d/%y')
3. DATE_FORMAT('2019-04-20', '%W, %M %D, %Y'))
4. DATE_FORMAT('2019-04-20', '%e-%b-%y')
4. Question 4
Which of the following functions would you use to add a specified number of date parts to a date?
1. TO_DAYS
2. DAYOFYEAR
3. LAST_DAY
4. DATE_ADD
5. Question 5
If the current date is 2019-02-10, what value is returned by the function that follows?
MONTH(CURDATE())
2
1. Feb
2. February
3. February 2019
6. Question 6
Which of the following statements best describes what this SELECT statement does?
SELECT invoice_number, invoice_date,
CASE
WHEN (SYSDATE() - invoice_date) >= 30 AND (SYSDATE() -
invoice_date) < 60
THEN invoice_total
ELSE 0
END AS "30-60",
CASE
WHEN (SYSDATE() - invoice_date) >= 60 AND (SYSDATE() -
invoice_date) < 90
THEN invoice_total
ELSE 0
END AS "60-90",
CASE
WHEN (SYSDATE() - invoice_date) > 90 THEN invoice_total
ELSE 0
END AS "Over 90"
FROM invoices
1. Displays three columns for each invoice with a value in the third column that indicates how
many days have elapsed between the invoice date and the current date.
2. Displays five columns for each invoice with the invoice total in one of the last three
columns based on how many days have elapsed between the invoice date and the
current date.
3. Displays three columns for each invoice with one of these messages in the third column: 30-
60, 60-90, or Over 90.
4. Displays five columns for each invoice with a message in one of the last three columns based
on how many days have elapsed between the invoice date and the current date.
7. Question 7
Which of the following statements best describes what the following SELECT statement does?
SELECT MONTH(invoice_date) AS month, vendor_name, invoice_total,
FIRST_VALUE(vendor_name) OVER (PARTITION BY MONTH(invoice_date)
ORDER BY invoice_total DESC) AS 'first_value'
FROM invoices JOIN vendors ON invoices.vendor_id = vendors.vendor_id
1. Sorts the invoices by invoice total in descending sequence within each month and displays the
name of the vendor with the smallest invoice total for each row of that month.
2. Sorts the invoices by invoice total in descending sequence within each month and
displays the name of the vendor with the largest invoice total for each row of that
month.
3. Sorts the invoices by invoice total in descending sequence within vendor name and displays
the value of the smallest invoice for each vendor and month.
4. Sorts the invoices by invoice total in descending sequence within vendor name and displays
the value of the largest invoice for each vendor and month.
E10d
1. Question 1
Which of the following functions returns the smallest integer that is greater than or equal to the
number?
1. FLOOR
2. TRUNCATE
3. SIGN
4. CEILING
5. CEILING
3. Question 3
If the column named float_value is a DOUBLE type, which of the following queries will not return
values that are approximately equal to 5?
1. SELECT float_value
FROM float_sample
WHERE float_value BETWEEN 4.99 AND 5.01
SELECT float_value
FROM float_sample
WHERE float_value = 5
2. SELECT float_value
FROM float_sample
WHERE ROUND(float_value, 2) = 5.00
4. Question 4
1. Question 1
Which of the following is not typically used to parse a string into its individual components?
1. SUBSTRING
2. SUBSTRING_INDEX
3. LENGTH
4. LOCATE
2. Question 2
Which of the following functions would you use to find a character in a string?
1. SUBSTRING
2. SUBSTRING_INDEX
3. ENGTH
4. LOCATE
3. Question 3
If first_name contains Edward and last_name contains Williams, what will the solution column
contain when this code is executed?
CONCAT(LOWER(LEFT('Edward',1)), LOWER(LEFT('Williams',7))) AS solution
1. EWilliams
2. EWilliam
3. Ewilliams
4. ewiliam
6. Question 6
Which function concatenates a string with the specified separator string added in between?
1. LTRIM
2. CONCAT
3. CONCAT_WS
4. SUBSTRING_INDEX
E11
1. Question 1
Each of the following is a benefit provided by using views except for one. Which one is it?
1. Views can be used to update multiple tables with a single statement.
2. You can use views to restrict access to the tables in your database to certain rows.
3. Views can be used to hide the complexity of retrieval operations.
4. You can code views that join tables.
4. Question 4
The statement
CREATE VIEW example_3
AS
SELECT *
FROM invoices
WHERE invoice_total - payment_total - credit_total > 0
1. will create an updatable view
2. will create a read-only view
3. will fail because the * operator isn’t allowed
4. will create a view through which you can delete rows, but not insert or update rows
10. Question 10
You usually don’t insert rows into a table through a view because
1. due to table constraints, using a view to insert rows often results in errors
2. the view would have to include all of the required columns for the base table that require a
value
3. if the view names more than one base table, the INSERT statement can insert data into only
one of those tables
4. All of the given options
11. Question 11
By default,
1. columns from different tables with the same name do not have to be renamed
2. columns in a view are given the same names as the columns in the base tables
3. calculated columns do not need to be named in the SELECT statement
4. all of the given options
13. Question 13
One of the best reasons for using views is that they can limit the exposure of the tables in your
database to external
1. users only
2. applications only
3. users and applications only
4. users, applications, and databases
14. Question 14