SQL
[Basic Grammar] SQL SELECT INTO Statement
grace21110
2023. 10. 24. 23:34
반응형
The SELECT INTO Statement copies data from one table into a new table.
- Syntax
SELECT *
INTO newtable [IN externaldb]
FROM oldtable
WHERE condition;
Example
The following SQL statement copies only the German customers into a new table:
SELECT * INTO CustomersGermany
FROM Customers
WHERE Country = 'Germany';
Exercises
You have a table called Employees with columns EmployeeID, FirstName, LastName, and Salary. Write a SQL query to create a new table called HighSalaryEmployees that contains the records of employees with a salary greater than $60,000. Use the SELECT INTO statement to accomplish this.
SELECT *
INTO HighSalaryEmployees
FROM Employees
WHERE Salary > 60000;