There are several variations of the INSERT statement. In the simplest instance, a value is provided for each column of the new row in the order specified at the time the table was defined (or altered). In the preferable form of the INSERT statement, the columns are specified as part of the statement and they do not need to be in any specific order as long as the orders of the column list matches the order of the value list.
insert_value can be a literal, a scalar function, or a variable in a procedure.
Examples
INSERT INTO TEST (C, ID) VALUES (0.22, 5); INSERT INTO TEST VALUES (0.35, 9);
Multirow inserts can also be done. For example, to insert three rows in one statement, you can use the following command:
You can insert default values by using the DEFAULT VALUES statement as shown in the second example below. An equivalent form is “INSERT INTO TEST() VALUES()”. You can also assign a specific value for one column and use the default value for another column. These methods as shown in the examples below:
INSERT INTO TEST () VALUES ();
INSERT INTO TEST DEFAULT VALUES;
INSERT INTO TEST (C, ID) VALUES (0.35, DEFAULT);
INSERT INTO TEST (C, ID) SELECT A, B FROM INPUT_TO_TEST;