The SQL INSERT INTO SELECT Statement

Total Post:123

Points:615

 627  View(s)
Ratings:
Rate this:
  1. The SQL INSERT INTO SELECT Statement

    It copies data from one table and paste it into another table. 

    INSERT INTO SELECT requires same data types in source and target tables match

    The existing records in the target table are unaffected

    INSERT INTO SELECT Syntax

    Copy all columns from one table and paste into another table:

    INSERT INTO table2
    
    SELECT * FROM table1
    WHERE condition;

    Copy only some columns from one table and paste into another table:

    INSERT INTO table2 (column1, column2, column3, ...)
    
    SELECT column1, column2, column3, ...
    FROM table1
    WHERE condition;

Answer