Database Programming Section 12 Quiz
Section 12 Quiz
(Answer all questions in this section)
1. When the WHERE clause is missing in a DELETE statement,
what is the result? Mark for Review
(1) Points
An error message is displayed indicating incorrect syntax.
Nothing. The statement will not execute.
The table is removed from the database.
All rows are deleted from the table. (*)
2. One of your employees was recently married. Her employee ID is
still 189, however, her last name is now Rockefeller. Which SQL
statement will allow you to reflect this change? Mark for Review
(1) Points
INSERT INTO my_employees SET last_name = 'Rockefeller'
WHERE employee_ID = 189;
INSERT my_employees SET last_name = 'Rockefeller' WHERE
employee_ID = 189;
UPDATE INTO my_employees SET last_name = 'Rockefeller'
WHERE employee_ID = 189;
UPDATE my_employees SET last_name = 'Rockefeller' WHERE
employee_ID = 189; (*)
3. You need to update both the DEPARTMENT_ID and
LOCATION_ID columns in the EMPLOYEES table using one
UPDATE statement. Which clause should you include in the UPDATE
statement to update multiple columns? Mark for Review
(1) Points
The WHERE clause
The ON clause
The SET clause (*)
The USING clause
4. Examine the structures of the PRODUCTS and SUPPLIERS
tables:
SUPPLIERS:
SUPPLIER_ID NUMBER NOT NULL, Primary Key
SUPPLIER_NAME VARCHAR2 (25)
ADDRESS VARCHAR2 (30)
CITY VARCHAR2 (25)
REGION VARCHAR2 (10)
POSTAL_CODE VARCHAR2 (11)
PRODUCTS:
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the
SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located
in Atlanta. Which script should you use?
Mark for Review
(1) Points
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';
DELETE FROM suppliers
WHERE supplier_id IN
(SELECT supplier_id FROM suppliers WHERE UPPER(city) =
'ALANTA');
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id FROM suppliers WHERE UPPER(city) =
'ATLANTA');
(*)
DELETE FROM products
WHERE supplier_id =
(SELECT supplier_id FROM suppliers WHERE UPPER(city) =
'ATLANTA');
5. If you are performing an UPDATE statement with a subquery, it
MUST be a correlated subquery? (True or False) Mark for Review
(1) Points
True
False (*)
(Answer all questions in this section)
6. Which statement below will not insert a row of data into a table?
Mark for Review
(1) Points
INSERT INTO student_table (id, lname, fname, lunch_num)
VALUES (143354, 'Roberts', 'Cameron', 6543);
INSERT INTO student_table (id, lname, fname, lunch_num)
VALUES (143352, 'Roberts', 'Cameron', DEFAULT);
INSERT INTO student_table
VALUES (143354, 'Roberts', 'Cameron', 6543);
INSERT INTO (id, lname, fname, lunch_num)
VALUES (143354, 'Roberts', 'Cameron', 6543);
(*)
7. A column in a table can be given a default value. This option
prevents NULL values from automatically being assigned to the
column if a row is inserted without a specified value for the column.
True or False ? Mark for Review
(1) Points
True (*)
False
8. In a conditional multi-table insert, you can specify either
__________ or __________. Mark for Review
(1) Points
All; Second
Null; Default
All; First (*)
First; Second
9. The default value must match the __________ of the column.
Mark for Review
(1) Points
Datatype (*)
Size
Column name
Table
10. A multi-table insert statement must have a subquery at the end
of the statement. (True or False?) Mark for Review
(1) Points
True (*)
False
11. You need to copy rows from the EMPLOYEE table to the
EMPLOYEE_HIST table. What could you use in the INSERT
statement to accomplish this task? Mark for Review
(1) Points
A function
An ON clause
A SET clause
A subquery (*)
12. To return a table summary on the customers table, which of the
following is correct? Mark for Review
(1) Points
DESCRIBE customers, or DESC customers (*)
SHOW customers, or SEE customers
DEFINE customers, or DEF customers
DISTINCT customers, or DIST customers
13. You need to add a row to an existing table. Which DML
statement should you use? Mark for Review
(1) Points
UPDATE
INSERT (*)
CREATE
DELETE
14. Which of the following statements will add a new customer to the
customers table in the Global Fast Foods database? Mark for Review
(1) Points
INSERT INTO customers
(id 145, first_name 'Katie', last_name 'Hernandez', address '92 Chico
Way', city 'Los Angeles', state 'CA', zip 98008, phone_number
8586667641);
INSERT INTO customers (id, first_name, last_name, address, city,
state, zip, phone_number)
VALUES (145, 'Katie', 'Hernandez', '92 Chico Way', 'Los Angeles',
'CA', 98008, 8586667641);
(*)
INSERT INTO customers (id, first_name, last_name, address, city,
state, zip, phone_number)
VALUES ("145", 'Katie', 'Hernandez', '92 Chico Way', 'Los Angeles',
'CA', "98008", "8586667641");
INSERT IN customers (id, first_name, last_name, address, city, state,
zip, phone_number);
15. Which statement about the VALUES clause of an INSERT
statement is true? Mark for Review
(1) Points
If no column list is specified, the values must be listed in the same
order that the columns are listed in the table. (*)
To specify a null value in the VALUES clause, use an empty string ("
").
Character, date, and numeric data must be enclosed within single
quotes in the VALUES clause.
The VALUES clause in an INSERT statement is mandatory in a
subquery.