What does the SELECT INTO statement do in SQL?
A
Updates records in a table B
Copies data from one table into a new table C
Deletes rows from a table D
Inserts data into an existing table
Analysis & Theory
SELECT INTO copies data into a *new* table.
Which of the following is the correct syntax for SELECT INTO?
A
SELECT * INTO NewTable FROM OldTable; B
INSERT INTO NewTable SELECT * FROM OldTable; C
UPDATE NewTable SET SELECT * FROM OldTable; D
COPY INTO NewTable SELECT * FROM OldTable;
Analysis & Theory
The correct syntax is: SELECT columns INTO NewTable FROM ExistingTable;
What happens if the target table specified in SELECT INTO already exists?
A
The existing table will be appended to B
The existing table will be replaced C
An error will occur D
Rows will be merged
Analysis & Theory
SELECT INTO creates a new table; if it exists already, it causes an error.
Which query creates a new table with only the 'Name' and 'Age' columns from 'Employees'?
A
SELECT Name, Age INTO NewEmployees FROM Employees; B
INSERT INTO NewEmployees SELECT Name, Age FROM Employees; C
CREATE TABLE NewEmployees AS SELECT Name, Age FROM Employees; D
SELECT Name, Age FROM Employees INTO NewEmployees;
Analysis & Theory
SELECT column1, column2 INTO NewTable FROM ExistingTable;
Can you use WHERE with SELECT INTO to filter rows?
A
Yes B
No
Analysis & Theory
You can use WHERE to filter which rows are inserted into the new table.
Which statement creates a backup table containing all orders placed in 2024?
A
SELECT * INTO OrdersBackup FROM Orders WHERE YEAR(OrderDate) = 2024; B
INSERT INTO OrdersBackup SELECT * FROM Orders WHERE YEAR(OrderDate) = 2024; C
COPY Orders INTO OrdersBackup WHERE YEAR(OrderDate) = 2024; D
SELECT INTO OrdersBackup FROM Orders WHERE YEAR(OrderDate) = 2024;
Analysis & Theory
SELECT INTO + WHERE filters rows into the new table.
True or False: You can copy data from multiple tables into a new table using SELECT INTO with JOINs.
A
True B
False
Analysis & Theory
You can JOIN tables in SELECT INTO to create a combined table.
Which of the following is NOT true about SELECT INTO?
A
It creates a new table B
It can copy all columns or specific columns C
It appends rows to an existing table D
It can use WHERE to filter rows
Analysis & Theory
SELECT INTO cannot append to existing tables; it always creates a new one.
Fill in the blank:
SELECT * INTO ______ FROM Customers WHERE Country = 'USA';
A
CustomersBackup B
FROM CustomersBackup C
INSERT CustomersBackup D
NEW TABLE CustomersBackup
Analysis & Theory
Syntax: SELECT * INTO NewTable FROM ExistingTable;
How do you copy only certain columns into a new table?
A
Use SELECT column1, column2 INTO NewTable FROM OldTable; B
Use INSERT INTO NewTable SELECT * FROM OldTable; C
Use SELECT INTO NewTable FROM OldTable WHERE column1 = column2; D
Use CREATE TABLE NewTable SELECT column1, column2 FROM OldTable;
Analysis & Theory
You specify columns explicitly in SELECT INTO.