Database Programming With SQL Section 12 Quiz Parte II
Database Programming With SQL Section 12 Quiz Parte II
Section 12 Quiz
(Answer all questions in this section)
1. You need to update the area code of employees that live in Atlanta. Evaluate this partial UPDATE
statement:
UPDATE employee
SET area_code = 770
Which of the following should you include in your UPDATE statement to achieve the desired results?
LIKE 'At%';
Correct Correct
2. One employee has the last name of 'King' in the employees table. How many rows will be deleted
from the employees table with the following statement?
DELETE FROM employees
WHERE last_name = 'king';
3. Using your knowledge of the employees table, what would be the result of the following statement:
DELETE FROM employees; Mark for Review
(1) Points
All rows in the employees table will be deleted if there are no constraints on the table. (*)
Correct Correct
CLASS_ASSIGNMENTS:
CLASS_ID NUMBER(5)
TEACHER_ID NUMBER(5)
START_DATE DATE
MAX_CAPACITY NUMBER(3)
You need to display the start date for each class taught by a given teacher.
You need to create a report to display the teachers who were hired more than five years ago.
You need to display the names of the teachers who teach classes that start within the next week.
You need to create a report to display the teachers who teach more classes than the average number of
classes taught by each teacher. (*)
5. DELETE statements can use correlated subqueries? (True or False) Mark for Review
(1) Points
True (*)
False
Correct Correct
Section 12 Quiz
(Answer all questions in this section)
6. Multi-table inserts are used when the same source data should be inserted into _____________ target
table. Mark for Review
(1) Points
Ten
A very large
7. A multi-table insert statement can insert into more than one table. (True or False?) Mark for Review
(1) Points
True (*)
False
Correct Correct
8. Using MERGE accomplishes an __________ and __________ simultaneously. Mark for Review
(1) Points
INSERT; SELECT
UPDATE; SELECT
UPDATE; DELETE
Correct Correct
9. The default value must match the __________ of the column. Mark for Review
(1) Points
Column name
Table
Datatype (*)
Size
10. If a default value was set for a null column, Oracle sets the column to the default value. However, if
no default value was set when the column was created, Oracle inserts an empty space. True or False?
Mark for Review
(1) Points
True
False (*)
Section 12 Quiz
(Answer all questions in this section)
11. Insert statements can be combined with subqueries to create more than one row per statement. True
or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
12. What is the quickest way to use today's date when you are creating a new row? Mark for Review
(1) Points
13. 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 IN customers (id, first_name, last_name, address, city, state, zip, phone_number);
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");
14. Using the INSERT statement and assuming that a column can accept null values, how can you
implicitly insert a null value in a column? Mark for Review
(1) Points
It is not possible to implicitly insert a null value in a column.
15. When inserting rows into a table, all columns must be given values. True or False? Mark for
Review
(1) Points
True
False (*)
Section 12 Quiz
(Answer all questions in this section)
1. You want to enter a new record into the CUSTOMERS table. Which two commands can be used to
create new rows? Mark for Review
(1) Points
INSERT, CREATE
MERGE, CREATE
INSERT, MERGE (*)
INSERT, UPDATE
2. One employee has the last name of 'King' in the employees table. How many rows will be deleted
from the employees table with the following statement?
DELETE FROM employees
WHERE last_name = 'king';
Correct Correct
You want to execute one DML statement to change the salary of all employees in department 10 to equal
the new salary of employee number 89898. Currently, all employees in department 10 have the same
salary value. Which statement should you execute?
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898);
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898 AND department_id =
10);
UPDATE employees
SET salary = SELECT salary FROM employees WHERE employee_id = 89898;
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898)
WHERE department_id = 10;
(*)
You need to increase the salary of each player for all players on the Tiger team by 12.5 percent. The
TEAM_ID value for the Tiger team is 5960. Which statement should you use?
UPDATE players
SET salary = salary * .125
WHERE team_id = 5960;
UPDATE players
SET salary = salary * 1.125
WHERE team_id = 5960;
(*)
5. You need to update the area code of employees that live in Atlanta. Evaluate this partial UPDATE
statement:
UPDATE employee
SET area_code = 770
Which of the following should you include in your UPDATE statement to achieve the desired results?
LIKE 'At%';
Correct Correct
Section 12 Quiz
(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
8. 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
Correct Correct
9. The DEFAULT keyword can be used in the following statements: Mark for Review
(1) Points
Correct Correct
10. Aliases can be used with MERGE statements. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
Section 12 Quiz
(Answer all questions in this section)
11. Insert statements can be combined with subqueries to create more than one row per statement. True
or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
You want to add the following row of data to the PRODUCTS table:
The row was created completely wrong. No data ended up in the correct columns.
The row was created with the correct data in two of three columns.
The row was created with the correct data in all three columns. (*)
The row was created with the correct data in one of the three columns.
Incorrect Incorrect. Refer to Section 12 Lesson 1.
13. 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. (*)
Character, date, and numeric data must be enclosed within single quotes in the VALUES clause.
To specify a null value in the VALUES clause, use an empty string (" ").
14. You need to add a row to an existing table. Which DML statement should you use? Mark for
Review
(1) Points
DELETE
CREATE
INSERT (*)
UPDATE
15. Assume all the column names are correct. The following SQL statement will execute which of the
following?
INSERT INTO departments
(department_id, department_name, manager_id, location_id)
VALUES (70, 'Public Relations', 100, 1700);
Mark for Review
(1) Points
Section 12 Quiz
(Answer all questions in this section)
1. You have been instructed to add a new customer to the CUSTOMERS table. Because the new
customer has not had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
2. Assume all the column names are correct. The following SQL statement will execute which of the
following?
INSERT INTO departments
(department_id, department_name, manager_id, location_id)
VALUES (70, 'Public Relations', 100, 1700);
Correct Correct
3. When inserting rows into a table, all columns must be given values. True or False? Mark for Review
(1) Points
True
False (*)
Correct Correct
4. If the employees table has 7 rows, how many rows are inserted into the copy_emps table with the
following statement:
INSERT INTO copy_emps (employee_id, first_name, last_name, salary, department_id)
SELECT employee_id, first_name, last_name, salary, department_id
FROM employees
Mark for Review
(1) Points
Correct Correct
You want to add the following row of data to the PRODUCTS table:
The row was created with the correct data in two of three columns.
The row was created completely wrong. No data ended up in the correct columns.
The row was created with the correct data in all three columns. (*)
The row was created with the correct data in one of the three columns.
Correct Correct
Section 12 Quiz
(Answer all questions in this section)
6. 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
Correct Correct
7. A multi-table insert statement can insert into more than one table. (True or False?) Mark for Review
(1) Points
True (*)
False
Correct Correct
8. Multi-table inserts can be conditional or unconditional. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
9. If a default value was set for a null column, Oracle sets the column to the default value. However, if
no default value was set when the column was created, Oracle inserts an empty space. True or False?
Mark for Review
(1) Points
True
False (*)
Correct Correct
10. A DEFAULT value can be specified for a column when the table is created. True or false? Mark for
Review
(1) Points
True (*)
False
Correct Correct
Section 12 Quiz
(Answer all questions in this section)
The statement deletes all the rows from the CUSTOMER table. (*)
The statement removes the structure of the CUSTOMER table from the database.
12. Which of the following represents the correct syntax for an INSERT statement? Mark for Review
(1) Points
INSERT VALUES INTO customers (3178 J. Smith 123 Main Street Nashville TN 37777;
INSERT INTO customers VALUES '3178' 'J.' 'Smith' '123 Main Street' 'Nashville' 'TN' '37777';
INSERT INTO customers VALUES ('3178', 'J.', 'Smith', '123 Main Street', 'Nashville', 'TN', '37777'); (*)
INSERT customers VALUES 3178, J., Smith, 123 Main Street, Nashville, TN, 37777;
Incorrect Incorrect. Refer to Section 12 Lesson 2.
13. Examine the structures of the PLAYERS, MANAGERS, and TEAMS tables:
PLAYERS:
PLAYER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
TEAM_ID NUMBER
MGR_ID NUMBER
SIGNING_BONUS NUMBER(9,2)
SALARY NUMBER(9,2)
MANAGERS:
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS:
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner (*)
To display each player, their manager, and their team name for all teams with an id value greater than
5000
The ON clause
15. If the subquery returns one row, how many rows will be deleted from the employees table?
DELETE FROM employees
WHERE department_id =
(SELECT department_id
FROM departments
WHERE department_name LIKE '%Public%');
One row will be deleted, as the subquery only returns one row.
All rows in the employees table of employees who work in the given department will be deleted. (*)
All rows in the employees table will be deleted, no matter the department_id.
Section 12 Quiz
(Answer all questions in this section)
1. 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
Correct Correct
2. Which statement below will not insert a row of data into a table? Mark for Review
(1) Points
Correct Correct
3. In a conditional multi-table insert, you can specify either __________ or __________. Mark for
Review
(1) Points
First; Second
All; Second
Null; Default
4. The default value must match the __________ of the column. Mark for Review
(1) Points
Table
Datatype (*)
Size
Column name
Correct Correct
5. If a default value was set for a null column, Oracle sets the column to the default value. However, if
no default value was set when the column was created, Oracle inserts an empty space. True or False?
Mark for Review
(1) Points
True
False (*)
Correct Correct
Section 12 Quiz
(Answer all questions in this section)
6. One of the sales representatives, Janet Roper, has informed you that she was recently married, and
she has requested that you update her name in the employee database. Her new last name is Cooper. Janet
is the only person with the last name of Roper that is employed by the company. The EMPLOYEES table
contains these columns and all data is stored in lowercase:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
UPDATE employees
SET cooper = 'last_name'
WHERE last_name = 'roper';
UPDATE employees
SET last_name = 'roper'
WHERE last_name = 'cooper';
UPDATE employees
SET last_name = 'cooper'
WHERE last_name = 'roper'; (*)
You need to increase the salary of each player for all players on the Tiger team by 12.5 percent. The
TEAM_ID value for the Tiger team is 5960. Which statement should you use?
UPDATE players
SET salary = salary * .125
WHERE team_id = 5960;
UPDATE players
SET salary = salary * 1.125
WHERE team_id = 5960;
(*)
UPDATE players (salary)
VALUES(salary * 1.125)
WHERE team_id = 5960;
Correct Correct
You want to execute one DML statement to change the salary of all employees in department 10 to equal
the new salary of employee number 89898. Currently, all employees in department 10 have the same
salary value. Which statement should you execute?
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898);
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898 AND department_id =
10);
UPDATE employees
SET salary = SELECT salary FROM employees WHERE employee_id = 89898;
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898)
WHERE department_id = 10;
(*)
Correct Correct
The statement deletes all the rows from the CUSTOMER table. (*)
The statement removes the structure of the CUSTOMER table from the database.
Correct Correct
Section 12 Quiz
(Answer all questions in this section)
You create another table, named FT_STUDENTS, with an identical structure.You want to insert all full-
time students who have a STU_TYPE_ID value of "F" into the new table. You execute this INSERT
statement:
An error occurs because the INSERT statement does NOT contain a VALUES clause.
All full-time students are inserted into the FT_STUDENTS table. (*)
12. 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
A SET clause
A subquery (*)
An ON clause
13. You have been instructed to add a new customer to the CUSTOMERS table. Because the new
customer has not had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
Correct Correct
14. When inserting a new row, the null keyword can be included in the values list for any column that
allows nulls. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
15. Using the INSERT statement and assuming that a column can accept null values, how can you
implicitly insert a null value in a column? Mark for Review
(1) Points
Use the ON clause
Correct Correct
Section 12 Quiz
(Answer all questions in this section)
1. 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, 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);
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);
(*)
Correct Correct
2. You need to add a row to an existing table. Which DML statement should you use? Mark for Review
(1) Points
UPDATE
DELETE
INSERT (*)
CREATE
Correct Correct
3. Is it possible to insert more than one row at a time using an INSERT statement with a VALUES
clause? Mark for Review
(1) Points
No, you can only create one row at a time when using the VALUES clause. (*)
Yes, you can just list as many rows as you want; just remember to separate the rows with commas.
4. Using the INSERT statement and assuming that a column can accept null values, how can you
implicitly insert a null value in a column? Mark for Review
(1) Points
Correct Correct
5. If the employees table has 7 rows, how many rows are inserted into the copy_emps table with the
following statement:
INSERT INTO copy_emps (employee_id, first_name, last_name, salary, department_id)
SELECT employee_id, first_name, last_name, salary, department_id
FROM employees
Mark for Review
(1) Points
Correct Correct
Section 12 Quiz
(Answer all questions in this section)
You want to execute one DML statement to change the salary of all employees in department 10 to equal
the new salary of employee number 89898. Currently, all employees in department 10 have the same
salary value. Which statement should you execute?
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898)
WHERE department_id = 10;
(*)
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898 AND department_id =
10);
UPDATE employees
SET salary = (SELECT salary FROM employees WHERE employee_id = 89898);
UPDATE employees
SET salary = SELECT salary FROM employees WHERE employee_id = 89898;
Correct Correct
MANAGERS:
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS:
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
To display the maximum and minimum player salary for each team
To display the names of the managers for all the teams owned by a given owner (*)
To display each player, their manager, and their team name for all teams with an id value greater than
5000
Correct Correct
8. To change an existing row in a table, you can use the UPDATE or INSERT statements. True or
False? Mark for Review
(1) Points
True
False (*)
You need to display the start date for each class taught by a given teacher.
You need to create a report to display the teachers who were hired more than five years ago.
You need to display the names of the teachers who teach classes that start within the next week.
You need to create a report to display the teachers who teach more classes than the average number of
classes taught by each teacher. (*)
Correct Correct
10. You want to enter a new record into the CUSTOMERS table. Which two commands can be used to
create new rows? Mark for Review
(1) Points
INSERT, CREATE
MERGE, CREATE
INSERT, UPDATE
Correct Correct
Section 12 Quiz
(Answer all questions in this section)
11. Using MERGE accomplishes an __________ and __________ simultaneously. Mark for Review
(1) Points
UPDATE; DELETE
UPDATE; SELECT
INSERT; SELECT
Correct Correct
12. Which statement below will not insert a row of data into a table? Mark for Review
(1) Points
13. If a default value was set for a null column, Oracle sets the column to the default value. However, if
no default value was set when the column was created, Oracle inserts an empty space. True or False?
Mark for Review
(1) Points
True
False (*)
Correct Correct
14. The DEFAULT keyword can be used in the following statements: Mark for Review
(1) Points
Correct Correct
15. Multi-table inserts can be conditional or unconditional. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
Previous Page 3 of 3 Summary
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
Correct Correct
2. 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 (*)
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 SET clause (*)
The ON clause
Correct Correct
4. You need to delete a record in the EMPLOYEES table for Tim Jones, whose unique employee
identification number is 348. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(5) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(30)
PHONE NUMBER(10)
Which DELETE statement will delete the appropriate record without deleting any additional records?
DELETE *
FROM employees
WHERE employee_id = 348;
DELETE 'jones'
FROM employees;
5. If the subquery returns one row, how many rows will be deleted from the employees table?
DELETE FROM employees
WHERE department_id =
(SELECT department_id
FROM departments
WHERE department_name LIKE '%Public%');
All rows in the employees table of employees who work in the given department will be deleted. (*)
One row will be deleted, as the subquery only returns one row.
All rows in the employees table will be deleted, no matter the department_id.
Correct Correct
Section 12 Quiz
(Answer all questions in this section)
You want to add the following row of data to the PRODUCTS table:
The row was created with the correct data in two of three columns.
The row was created with the correct data in one of the three columns.
The row was created completely wrong. No data ended up in the correct columns.
The row was created with the correct data in all three columns. (*)
Correct Correct
7. Insert statements can be combined with subqueries to create more than one row per statement. True
or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
8. When inserting a new row, the null keyword can be included in the values list for any column that
allows nulls. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
9. Is it possible to insert more than one row at a time using an INSERT statement with a VALUES
clause? Mark for Review
(1) Points
No, you can only create one row at a time when using the VALUES clause. (*)
Yes, you can just list as many rows as you want; just remember to separate the rows with commas.
Correct Correct
You create another table, named FT_STUDENTS, with an identical structure.You want to insert all full-
time students who have a STU_TYPE_ID value of "F" into the new table. You execute this INSERT
statement:
All full-time students are inserted into the FT_STUDENTS table. (*)
An error occurs because the INSERT statement does NOT contain a VALUES clause.
Correct Correct
Section 12 Quiz
(Answer all questions in this section)
Correct Correct
12. Multi-table inserts are used when the same source data should be inserted into _____________
target table. Mark for Review
(1) Points
A data warehouse
Ten
More than one (*)
A very large
Correct Correct
13. A multi-table insert statement can insert into more than one table. (True or False?) Mark for
Review
(1) Points
True (*)
False
Correct Correct
14. If a default value was set for a null column, Oracle sets the column to the default value. However, if
no default value was set when the column was created, Oracle inserts an empty space. True or False?
Mark for Review
(1) Points
True
False (*)
Correct Correct
15. Which statement below will not insert a row of data into a table? Mark for Review
(1) Points
Correct Correct
A great idea. When a new employee record is entered, if no hire_date is specified, the 0 (zero) will be
automatically specified.
A great idea. When new employee records are entered, they can be added faster by allowing the 0's
(zeroes) to be automatically specified.
A bad idea. The default value must match the DATE datatype of the column. (*)
Correct
Assuming there are no Foreign Keys on the EMPLOYEES table, if the following subquery returns one
row, how many rows will be deleted from the EMPLOYEES table?
DELETE FROM employees
WHERE department_id =
(SELECT department_id
FROM departments
WHERE department_name LIKE '%Public%');
One row will be deleted, as the subquery only returns one row.
All rows in the EMPLOYEES table will be deleted, regardless of their department_id.