Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views15 pages

PDF Quiz 12 PDF

This document contains 14 questions about SQL statements such as INSERT, UPDATE, DELETE, and MERGE. The questions cover topics such as inserting rows with null values, updating rows with subqueries, deleting rows that meet certain conditions, and copying rows between tables. Most of the questions include one or more answer options for the reader to choose the correct one.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views15 pages

PDF Quiz 12 PDF

This document contains 14 questions about SQL statements such as INSERT, UPDATE, DELETE, and MERGE. The questions cover topics such as inserting rows with null values, updating rows with subqueries, deleting rows that meet certain conditions, and copying rows between tables. Most of the questions include one or more answer options for the reader to choose the correct one.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

(Answer all the questions in this section)

1.With MERGE, you execute y at the same time.


Mark for Review
(1) Points

INSERT; SELECT

UPDATE;SELECT UPDATE;
DELETE
INSERT; UPDATE (*)

Incorrect. Please refer to section 12 of lesson 3.

2.An insert statement in multiple tables can be inserted into more than one.
table. (True or false?)
Mark for Review
(1) Points
TRUE
E
A
S
LF

Correct

3.Insertions into multiple tables are used when the same data source
it should be inserted in destination table(s).
Mark for Review
Points
Ten
A data warehouse More
of one (*)
A vast

Incorrect. Please refer to section 12 of lesson 3.

4.The MERGE function combines the commands:


Mark for Review
(1) Points

INSERT and UPDATE


E
D
T
U
A
PyE
T
A
C
R
E)*(
ALTER and
gnihtyrevE
E
T
D
AU
P
anterior

Correct
INSERT INTO student_table (id, lname, fname, lunch_num)
VALUES (143352, 'Roberts', 'Cameron', DEFAULT);
INSERT INTO (id, lname, fname, lunch_num)
VALUES (143354, 'Roberts', 'Cameron', 6543);

(*)
INSERT INTO student_table (id, lname, fname, lunch_num)

VALUESINTO
INSERT (143354,
student_table ' Roberts ' , Cameron, 6543);
VALUES (143354, 'Roberts', 'Cameron', 6543);

Answer all the questions in this section

6.If the subquery returns one row, how many rows will be deleted from the table?
employees? Mark for Review
(1) Points
DELETE FROM employees
WHERE department_id =
(SELECT department_id
FROM departments
WHERE department_name LIKE '%Public%');

All rows of the employees table will be deleted, regardless of the


value department_id.
No row will be deleted.
One row will be removed, since the subquery only returns one row.
All rows from the employees table of employees who work in the
specified department will be eliminated. (*)

Incorrect. Please refer to section 12 of lesson 2.

7. One of its employees has recently gotten married. Their employee ID


it is still 189, but his last name is now Rockefeller. What a sentence
Will SQL allow to reflect this change? Mark for Review
(1) Points

UPDATE my_employees SET last_name = 'Rockefeller' WHERE


employee_ID = 189; (*)
UPDATE INTO my_employees SET last_name = 'Rockefeller' WHERE
employee_ID = 189;
INSERT INTO my_employees SET last_name = 'Rockefeller' WHERE
employee_ID = 189;
INSERT my_employees SET last_name = 'Rockefeller' WHERE
employee_ID = 189;

Correct

8.Examine the structures of the PRODUCTS tables and


Mark for Review
:R
S
EIL
P
U
P
S:R
S
EIL
P
U
P
S (1) Points
VARCHAR2 (10)
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
NUMBER
UNIT_PRICE NUMBER (7,2)
NUMBER
Quantity on Order
NUMBER

Do you wish to remove any products supplied by the five providers?


located in Atlanta. What script should I use?

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');
DELETE FROM products
WHERE UPPER(city) = 'ATLANTA';

Correct

9. You must update the area code of employees living in Atlanta. Mark for Review
Evaluate this partial UPDATE statement:
(1) Points

UPDATE employee
SET area_code = 770

Which of the following elements should you include in your UPDATE statement?
to achieve the desired results?

SET city = 'Atlanta'; WHERE city = 'Atlanta'; (*) UPDATE city = Atlanta; LIKE 'At%';
10.If you are executing an UPDATE statement with a subquery, it MUST be
A correlated subquery? (True or false) Mark for Review
(1) Points
TRUE FALSE
(*)

(Answer all the questions in this section)

11.Using the INSERT statement and assuming that a column can


Accept null values, how can you implicitly insert a value?
null in a column? Mark for Review
Points
Using the keyword
.esualO
N
cehtgniU
sN
.U
L
Omitting the column in the list of columns. (*)
Cannot implicitly insert a null value into a

column.Correct
The PRODUCTS table contains these columns:
12. Mark for Review
PROD_ID NUMBER(4) (1) Points
PROD_NAME VARCHAR2(25)
PROD_PRICE NUMBER(3)

You want to add the following row of data to the PRODUCTS table:

a NULL value in the PROD_ID column


6-foot nylon leash
(3) 10 in the column

PROD_PRICE Issues this statement:

INSERT INTO products

VALUES (null,'6-foot nylon leash', 10);


What row data have you added to the table?

The row has been created with the correct data in the three columns. (*)

13.Which of the following statements will add a new customer to the


customers table from 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
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.You must copy the rows from the EMPLOYEE table to the EMPLOYEE_HIST table.
Mark for Review
What could I use in the INSERT statement to carry out this task?
(1) Points

A function
A subquery
esualA
c)*(
SET a clause
ON

15.You have been asked to add a new customer to the CUSTOMERS table. Mark for Review
Since the credit of the new customer has not been verified, it should not
Points
add an amount in the CREDIT column.
The CUSTOMERS table contains these columns:

NUMBER(10)
VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)

Which two INSERT statements will achieve your objective?

(Select all the correct answers)

INSERT INTO customers


VALUES (200, 'InterCargo', null, 'tflanders', 'samerica');

(*)
INSERT INTO customers (cust_id, company, poc, location)

VALUES (200, 'InterCargo', 'tflanders', 'samerica');


(*)

(Answer all the questions in this section)

What is the quickest way to use today's date when creating


a new row? Mark for Review
(1) Points

Use the function TODAY'S_DATE.


dd-month
Incorrect. Please refer to section 12 of lesson 1.

2. In order to return a summary table from the customers table, what of


Is the following correct? Mark for Review
(1) Points

DEFINE customers or DEF customers DISTINCT


customers or DIST customers DESCRIBE
SHOW customers in descending order.
customers or SEE customers

Incorrect. Please refer to section 12 of lesson 1.

4.You should add a row to an existing table. What DML statement should you use?
to use? Mark for Review
(1) Points

DELETE
UPDATE

CREATE INSERT
(*)

Incorrect. Please refer to section 12 of lesson 1.

5.Can more than one row be inserted at a time using a statement?


INSERT with a VALUES clause?
Mark for Review
Points

Yes, you can show as many rows as you want; you just have to remember
separate the rows with commas.
No, there is nothing like INSERT... VALUES.
No, you can only create one row at a time when using the clause

VALUES.
(Answer all the questions(*)
in this section)

6.An insert statement into multiple tables can be inserted into more than
A table. (True or false?) Mark for Review
(1) Points
TRUE
E
A
S
LF)*(

Incorrect. Please refer to section 12 of lesson 3.

7.Inserts into multiple tables are used when the same source of
An immense
A data warehouse
More than one (*) Ten

Incorrect. Please refer to section 12 of lesson 3.

8.The insert statement in multiple tables must have a subquery to the


end of the sentence. (True or false?)

Mark for Review


TRUE (1) Points
E
A
S
LF)*(

Correct

9.The default value must match with (the) from the column.
Mark for Review
(1) Pu
nts

Size
Table
Type of data (*) Name
from the column

Incorrect. Please refer to section 12 of lesson 3.

10.The MERGE function combines the commands:


Mark for Review
(1) Pu
ntos

CREATE and UPDATE


ALTER and UPDATE All
the previous INSERT
y UPDATE (*)
Answer all the questions in this section

11.Using what you know from the employees table, what would be the result of the
next sentence?
Mark for Review
DELETE FROM employees;
(1) Points
The first row of the employees table is
It will be removed. Nothing. No data will be changed.
All rows from the employees table will be deleted if there is no
Correct

12. Which of the following statements best describes what will happen in
the table of students in this SQL statement? Mark for Review
(1) Points
UPDATE students
SET lunch_number =
(SELECT lunch_number
FROM student
WHERE student_id = 17)
WHERE student_id = 19;

It does nothing, as subqueries cannot be used in statements.


UPDATE.
Insert a new row in the students table.
Delete the lunch_number value of student 17 and insert a new value.
of the student 19.
The sentence updates the student_table value by replacing the number.
for lunch of student ID 19 by the lunch number of ID
of student 17. (*)

Incorrect. Please refer to section 12 of lesson 2.

13.Examine the structures of the TABLES PLAYERS, MANAGERS and


Mark for Review
A
E
M
TS (1) Points
NUMBER Primary Key
VARCHAR2 (30)
FIRST_NAME VARCHAR2 (25)
NUMBER
MGR_ID NUMBER
NUMBER(9,2)
SALARY NUMBER(9,2)

MANAGERS:
NUMBER Primary Key
VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER

TEAMS
NUMBER Primary Key
VARCHAR2 (20)
VARCHAR2 (20)
VARCHAR2 (20)

In which of the situations would a subquery be needed to return the


desired outcome?

To show each player, their manager, and the name of their team
for all teams with an ID value greater than 5000
To show the names of the managers of all the teams of a
determined owner (*)

Incorrect. Please refer to section 12 of lesson 2.

14.One of the saleswomen, Janet Roper, has informed you that she has gotten married.
recently and has asked you to update your name in the database Mark for Review
employee data. Her new last name is Cooper. Janet is the only one.
(1) Points
person with the last name Roper hired by the company. The table
EMPLOYEES contains these columns and all the data is stored in
lowercase:

EMPLOYEE_ID NUMBER(10) PRIMARY KEY


LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID VARCHAR2 (20)
DATE
SALARY NUMBER(10)

What UPDATE statement will allow you to achieve your objective?

UPDATE employees
SET last_name = 'roper'
WUPHD A E T RE E l
a employees
s t_ n a m =
' cooper '; SET cooper =
last_name WHERE
roper
UPDATE employees SET last_name = 'cooper'
WHERE last_name = 'roper';
UPDATE employees
cooper
WHERE last_name = 'roper'; (*)

Incorrect. Please refer to section 12 of lesson 2.

15.If it is assumed that there are no foreign keys in the EMPLOYEES table, if
the following subquery returns a row, how many rows will be suppressed from Mark for Review
the
EMPLOYEES table?
(1) Points

DELETE FROM employees


WHERE department_id =
(SELECT department_id
FROM departments
WHERE department_name LIKE '%Public%');

No row will be deleted.


All rows of the EMPLOYEE table will be removed.
regardless of its value department_id.
All the rows of the EMPLOYEES table with department_id values that
1.The PRODUCTS table contains these columns:
Mark for Review
PROD_ID NUMBER(4) (1) Points
PRODUCT_NAME VARCHAR2(25)
PROD_PRICE NUMBER(3)

Do you want to add the following row of data to the PRODUCTS table:

a NULL value in the column PROD_ID


6-foot nylon leash
(3) "10" in the column

PROD_PRICE Issues this statement:

INSERT INTO products


VALUES (null,'6-foot nylon leash', 10);

What row data has been added to the table?

The row has been created with the correct data in two of the three.
columns. The row has been created with the correct data in the three
columns. (*)
The row has been created completely incorrectly. None of the
data has ended in the correct columns.
The row has been created with the correct data in one of the three columns.

correct

2.INSERT statements can be combined with subqueries to create more


One row per statement. True or false?
Mark for Review
(1) Points
TRUE
E
A
S
LF)*(

correct

3.What statement is true about the VALUES clause of a statement?


INSERT?
Mark for Review
(1) Points

If no column list is specified, the values must


appear in the same order in which the columns are shown in the
table. (*)
The VALUES clause of an INSERT statement is mandatory in a
subquery.
To specify a null value in the VALUES clause, use a string
4.Which of the following statements will add a new customer? Mark for Review
customers table from the Global Fast Foods database?
(1) Points

INSERT INTO customers


(id 145, first_name 'Katie', last_name 'Hernandez', address '92 Chico
Way

8 INSERT
5 8 INTO
6 66 customers
7 6 4 (id, 1 first_name,
); last_name,
address
VALUES (145, 'Katie', 'Hernandez', '92 Chico Way', 'Los Angeles', 'CA',
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

correct

5.Using the INSERT statement and assuming that a column can


accept null values, how can it implicitly insert a null value
Mark for Review
in one column?
(1) Points
Omitting the column from the list of columns.
.esualO
N
cehtgniU
s
Using the keyword NULL.
A null value cannot be implicitly inserted into a column.

7.To change an existing row in a table, you can use the statements
UPDATE or INSERT. True or false?
Mark for Review
Points

VERDADERO FALSO
(*)

Incorrect. Please refer to section 12 of lesson 2.

8.Is the following statement valid, that is to say, can the rows be updated in
a table, based on a subquery from another table?
Mark for Review
UPDATE copy_emp (1) Points
SET department_id = (SELECT department_id
FROM employees
Yes, it is a perfectly valid sentence.
No, this statement will return an error.
No, it doesn't do anything.

The statement will fail because the subqueries are returning data.
from different rows.

Incorrect. Please refer to section 12 of lesson 2.

9.What two commands can be used to modify existing data?


in a row of the database?
Mark for Review
(1) Points

(Select all the correct answers)

DELETE MERGE
(*) UPDATE
(*) SELECT

Incorrect. Please refer to section 12 of lesson 2.

10.You must update the area code of employees living in Atlanta.


Evaluate this partial UPDATE statement: Mark for Review
(1) Points
UPDATE employee
SET area_code = 770

Which of the following elements should you include in your UPDATE statement?
to achieve the desired results?

LIKE 'At%';
UPDATE city = Atlanta;

SET city = 'Atlanta';


WHERE city = 'Atlanta'; (*)

12. When developing the Employees table, a column named


hire_date. Assign a DATE data type to the hire_date column with a Mark for Review
default value 0 (zero). A user will be able to return later and enter the
Points
correct value for hire date. This is .

A good idea. When a new employee record is introduced,


if no value is specified for hire_date, it will be specified
automatically 0 (zero).
A good idea. When new employee records are introduced,
they can be added faster by allowing the 0s (zeros)
they are specified automatically.

Incorrect. Please refer to section 12 of lesson 3.

13. Which of the following statements 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 (143352, 'Roberts', 'Cameron', DEFAULT);
INSERT INTO student_table (id, lname, fname, lunch_num)
VALUES (143354, 'Roberts', 'Cameron', 6543);
INSERT INTO student_table
VALUES (143354, 'Roberts', 'Cameron', 6543);
INSERT INTO (id, lname, fname, lunch_num)
VALUES (143354, 'Roberts', 'Cameron', 6543);

Correct

to

14. Insertions in several can be conditional or unconditional.


True or false? Mark for Review
(1) Points

TRUE
E
A
S
LF)*(

Correct

15. If a default value has been defined for a null column, Oracle defines
the column in the default value. However, if it has not been defined
no default value when creating the column, Oracle inserts a space Mark for Review
empty. True or false? Points

TRUE FALSE
(*)

2.When the WHERE clause is missing in a DELETE statement, what is the


result?
Mark for Review
(1) Points
The table is deleted from the database.
An error message appears indicating that the syntax is incorrect. Nothing.
Correct

3.You must update the expiration date of products manufactured before


June 30. In which clause of the UPDATE sentence will this be specified? Mark for Review
condition? (1) Points

The SET clause


The WHERE clause(*) The
USING clause
The ON clause

Incorrect. Please refer to section 12 of lesson 2.

4.Evaluate this
Mark for Review
sentence:DELETEFROM
Points

customer

Which statement is true?

The statement deletes all rows from the CUSTOMER table.

(*) The statement removes the CUSTOMER column.


The statement deletes the first row of the CUSTOMERS table.
The statement deletes the structure of the CUSTOMER table from the database.
data.

Correct

Mark for Review


5. You must delete a row from the EMPLOYEES table. What statement should you use?
use? Points

DELETE with a WHERE clause


(*) UPDATE with a WHERE clause

INSERT
WHERE with a clause
MERGE with a clause
WHERE
Answer all the questions in this section
Mark for Review
6.The STUDENTS table contains these Points
columns:STU_IDNUMBER(9)NOTNULL
LAST_NAME VARCHAR2 (30) NOT NULL
VARCHAR2 (25) NOT NULL
DOB DATE
STU_TYPE_ID VARCHAR2(1) NOT NULL
Create another table, called FT_STUDENTS, with an identical structure.
He wants to insert all full-time students who have a value
STU_TYPE_ID 'F' in the new table. Execute this INSERT statement:

INSERT INTO ft_students


(SELECT stu_id, last_name, first_name, dob, stu_type_id, enroll_date
FROM students
WHERE UPPER(stu_type_id) = 'F');

What is the result of executing this INSERT statement?

An error occurs because you CANNOT use a subquery in a


INSERT statement.
An error occurs because the FT_STUDENTS table already exists.
An error occurs because the INSERT statement does NOT contain a
VALUES clause.
All full-time students are included in the table.
FT_STUDENTS. (*)

14.Aliases can be used with MERGE statements. True or false?


Mark for Review
(1) Points

LF)*TRUE
E
A
S (

You might also like