What could be the reason?

View the Exhibit and examine the structure of the customers table.

NEW_CUSTOMERS is a new table with the columns CUST_ID, CUST_NAME and CUST_CITY
that have the same data types and size as the corresponding columns in the customers table.
Evaluate the following insert statement:
The insert statement fails when executed.

What could be the reason?

View the Exhibit and examine the structure of the customers table.

NEW_CUSTOMERS is a new table with the columns CUST_ID, CUST_NAME and CUST_CITY
that have the same data types and size as the corresponding columns in the customers table.
Evaluate the following insert statement:
The insert statement fails when executed.

What could be the reason?

A.
The values clause cannot be used in an INSERT with a subquery.

B.
Column names in the NEW_CUSTOMERS and CUSTOMERS tables do not match.

C.
The where clause cannot be used in a subquery embedded in an INSERT statement.

D.
The total number of columns in the NEW_CUSTOMERS table does not match the total number
of columns in the CUSTOMERS table.

Explanation:

Copying Rows from Another Table

Write your INSERT statement with a subquery:
Do not use the VALUES clause.
Match the number of columns in the INSERT clause to those in the subquery.
Inserts all the rows returned by the subquery in the table, sales_reps.



Leave a Reply 4

Your email address will not be published. Required fields are marked *


Mr. T

Mr. T

A!

A subquery can be used to select rows for insertion but not in a VALUES clause of an INSERT statement.

Tom

Tom

Sometimes subqueries can be used with VALUES keyword, but they should return SCALAR values and be enclosed in the additional parenthesis.

INSERT INTO new_customers (cust_id, cust_name, cust_salary) VALUES ((SELECT cust_id FROM customers where CUST_ID = 1929), ‘John’, 10000);

The statement above will work fine.

In this questions

Tom

Tom

In this question options A is correct.