Insert (SQL)

An SQL INSERT statement adds one or more records to any single table in a relational database.

All this is done in a single SQL statement that does not involve any intermediary processing in the client application.

The subselect can contain joins, function calls, and it can even query the same table into which the data is inserted.

However, some databases reject the statement if no data is given, such as Microsoft SQL Server, and in this case the DEFAULT keyword can be used.

For example, MySQL and SQLite will fill in with a blank value (except when in strict mode), while many other databases will reject the statement.

AFTER INSERT triggers cannot modify the data anymore, but can be used to initiate actions on other tables, for example, to implement auditing mechanism.