INSERT - Multiple Rows
To INSERT multiple rows into a table, the column names must be specified or the field values must be in exactly the same order as the columns are defined in the table.
All notes in the One Row topic apply to Multiple Rows.
Positional Insert: INSERT INTO table
subselect;
This command copies all rows and column values from the subselect to the INSERT table.
                                                                     or
Named Columns: INSERT INTO table
(column1, column2, column3, ...)
subselect;
This command copies column values from the subselect to the INSERT table.
> The process of adding data to a new table is called “populating” the table.
> A subselect is a SELECT statement as described previously that has been attached to another SQL command.
> When column names are specified, SQL ignores the column names in the subselect and uses column position to match with the column names specified in the INSERT table.
> An omitted column is given its default value or null.
> The table in the subselect remains unchanged.
> You can also INSERT rows through a VIEW.
> With some RDBMS systems, the INTO keyword is optional. But you should include the word INTO for portability.
> The SQL2 standard allows UNION and JOIN in the subselect.
Â
Â