Monday, August 4, 2014

SQL - SELECT INTO - DUPLICATE TABLE ; INSERT INTO - COPY DATA FROM ONE TABLE TO ANOTHER

The SQL SELECT INTO Statement

The SELECT INTO statement selects data from one table and inserts it into a new table.

SQL SELECT INTO Syntax

We can copy all columns into the new table:
SELECT *
INTO newtable [IN externaldb]
FROM table1;


The SQL INSERT INTO SELECT Statement

The INSERT INTO SELECT statement selects data from one table and inserts it into an existing table. Any existing rows in the target table are unaffected.

SQL INSERT INTO SELECT Syntax

We can copy all columns from one table to another, existing table:
INSERT INTO table2
SELECT * FROM table1;









No comments:

Post a Comment