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

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

Answer: a
Explanation: SELECT INTO is used to create a new table and copy data from one or more existing tables into that new table. The general syntax is:

SELECT column1, column2, …
INTO new_table
FROM existing_table
WHERE condition;

Free 30-Day Java Certification Bootcamp is Live. Join Now!

IN, LIKE and BETWEEN can be used with WHERE clause. FOR is generally NOT valid in the context of SELECT INTO.

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)

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.

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
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 40s–60s and exploring new directions in your career, I also offer mentoring. Learn more here.