Structured Query Language/INSERT 1

Hint: Be carefull and deactivate AUTOCOMMIT.

The INSERT command stores one or more new rows into one table. The content of the new rows consists of either fixed values or results from a SELECT, which is evaluated at runtime. So there are two different syntaxes to do the job.

Static Insert
Following the tablename, we can list the affected columns and after the keyword 'VALUES' state one or more lists of values to insert. Each list of values represents one new row. The lists of columns and values have to be in accordance such that the quantity of list entries is identical and their data types correlate.

We can choose any order of columns, but column names and values should be in concordance.

We can omit unnecessary columns.

Clean up your table.

Dynamic Insert
Unlike in the above paragraph, we can insert values that are not fixed but dynamic such that they are evaluated at runtime from any table, a function, or a computation. Even the number of new rows can be dynamic. All this is done in a subselect which replaces the VALUE clause. We explain this technique at page Advanced Insert. The other rules concerning number and sequence of columns or omitting values retain their validity.

Exercises
Insert a new row for Mr. Peter Hufington with its body weight of 67 kg. He is born in LA.