This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Insert Into Select”.
1. Which of the following statement(s) can be used in SQL to copy and insert data from one table to another table?
a) Copy Select
b) Select copy
c) Select Insert
d) Insert Into Select
View Answer
Explanation: Data of a table can be copied and inserted into another table in SQL by making use of INSERT INTO SELECT statement.
2. In an INSERT INTO SELECT statement, which of the following must match in both source and target table?
a) Column names
b) Column data types, names
c) Column data types and their number
d) Number of columns and their names
View Answer
Explanation: In an INSERT INTO SELECT statement the data types in source and target tables must match and they must be same in number. If not, an error occurs.
3. When an INSERT INTO SELECT statement is used, the existing records of the target table _________
a) Remains unaffected
b) Remains affected
c) Only some of the records are affected
d) Only some of the records re unaffected
View Answer
Explanation: The existing records of the target table of INSERT INTO SELECT statement remain unaffected. The new records from source table will be inserted into the target table without affecting the previous records.
4. What is the syntax of INSERT INTO SELECT statement?
a)
INSERT INTO SELECT * FROM source_table, target_table WHERE condition;
b)
INSERT INTO target_table SELECT * FROM source_table WHERE condition;
c)
INSERT INTO SELECT * FROM (source_table, target_table) WHERE condition;
d)
SELECT * FROM source_table INSERT INTO target_table WHERE condition;
Explanation: Syntax for an INSERT INTO SELECT statement is as follows:
INSERT INTO target_table SELECT * FROM source_table WHERE condition;
5. The SELECT statement of an INSERT INTO SELECT statement can contain HAVING, GROUP BY and WHERE clauses.
a) True
b) False
View Answer
Explanation: The SELECT statement of INSERT INTO SELECT can easily contain WHERE, GROUP BY, and HAVING clauses, as well as table joins and aliases.
6. Using INSERT INTO SELECT statement it is not possible to copy only specific columns from a table.
a) True
b) False
View Answer
Explanation: We can copy only specific columns of a table using an INSERT INTO SELECT statement by specifying the column names in the statement.
7. Using which of the following clause(s) we can copy only specific rows from the source table in an INSERT INTO SELECT statement?
a) Specify
b) Specific
c) Where
d) Few
View Answer
Explanation: To copy only specific records from the source table of INSERT INTO SELECT statement, WHERE clause is used to restrict the rows.
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]