A core statement in SQL that does what it says on the tin: inserts data into a table.
INSERT
is one of the major keywords in SQL and has the function of inserting data into a table. It can optionally specify a list of columns to load into and a set of literal values (VALUES
) or the results of a select statement.
The syntax is of the form:
INSERT INTO [destination table] ([optional column list])
VALUES ([value list])
or
INSERT INTO [destination table] ([optional column list])
SELECT (select statement)
On some systems (sql-server for example), the INTO
is optional.
INSERT
statements can be used to add multiple rows to a table at a time, and is preferable when loading bulk data instead of a single INSERT statement per row added.
To do so, separate the ([value list])
with a comma:
INSERT INTO [destination table] ([optional column list])
VALUES ([value list]), [([value list]), ([value list]), ([value list])...]