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
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
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
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.
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
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
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
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)
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;
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
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
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.