SQL Questions and Answers – SQL Subqueries

This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Subqueries”.

1. Which of the following statement(s) copies data from one table into a new table?
a) Copy
b) Select
c) Select into
d) Copy Paste
View Answer

Answer: c
Explanation: With SQL, we can copy information from one table into another. The SELECT INTO statement copies records from one table and inserts them into a new table.

2. How many columns can be copied using a SELECT INTO statement?
a) Only one
b) Two
c) Three
d) Any number of columns
View Answer

Answer: d
Explanation: We can copy any number of columns i.e. one or more columns using a SELECT INTO statement. The number of columns and data type of column must be same if the new table is already created.

3. WHERE clause must be used along with a SELECT INTO statement.
a) True
b) False
View Answer

Answer: b
Explanation: WHERE condition is optional to use along with SELECT INTO Clause. Using WHERE clause limits the number of records to copy from a table based on the given conditions.
advertisement
advertisement

4. SELECT INTO statement can be used in conjunction with which of the following clause(s)?
a) For
b) In
c) Like
d) Between
View Answer

Answer: b
Explanation: We can use SELECT INTO command along with IN clause for copying the data from a table into a new table of another database. IN is used to specify the database name.

5. If the condition in WHERE clause of a SELECT INTO statement returns no data, then ______
a) New table will not be created
b) New table with some random values will be created
c) An empty new table will be created
d) New table with default values will be created
View Answer

Answer: c
Explanation: We can use WHERE clause in a SELECT INTO statement to select specific rows of a table. If the condition in the WHERE clause returns no data then an empty new table will be created.

6. Which of the following can be done using a SELECT INTO statement?
a) Deleting a table
b) Creating a table
c) Updating a table
d) Dropping a table
View Answer

Answer: b
Explanation: SELECT INTO statement can be used to create a new, empty table using the schema of another. We should use the WHERE clause which doesn’t return any data to create a new table.

7. Which of the following statement(s) create a new empty table?
a)

advertisement
SELECT * INTO newtable
FROM oldtable;

b)

advertisement
SELECT * INTO newtable
FROM oldtable
WHERE 3=4;

c)

SELECT * INTO newtable
FROM oldtable
WHERE condition (TRUE FOR at least once);

d)

SELECT * INTO newtable
FROM oldtable
WHERE FALSE;
View Answer
Answer: b
Explanation: SELECT INTO statement can be used to create a new empty table. We need to add a WHERE clause that causes the query to return no data.

8. When using the SELECT INTO statement in SQL, the new table must not already exist.
a) True
b) False
View Answer

Answer: a
Explanation: New table used in SELECT INTO statement should be the one which doesn’t exist before. If it does already exist, the SELECT INTO statement will raise an error.

9. We can ________ some of the columns within new table rather than using them from old table of a SELECT INTO statement.
a) Delete
b) Modify
c) Rename
d) Insert
View Answer

Answer: c
Explanation: The new table will be created with the column names and data types as defined in the old table in a SELECT INTO statement. We can rename the new column names using the AS clause.

Sanfoundry Global Education & Learning Series – SQL.

To practice all areas of SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.