Description:
Adds new record into the database table.
Syntax:
INSERT table_name [
( column_list
) ]
VALUES ([ expression |
NULL |
DEFAULT ] [, ...]
)
table_name |
Name of the table. |
column_list |
List of columns for which values of new record will be stated. |
expression |
Value of the appropriate column itself defined by an expression. |
Example1:
Adds new record into the table "data". The most simplest variant where no column list needs to be stated because all values of record are stated in the VALUES in the correct order. The current time (with the precision of about 3ms) got by the function GETDATE() is inserted into the column time. 0 is put into the column flags. A random value in the range of 0-100 got by the function RAND() is inserted into the column value.
INSERT data VALUES (GETDATE(), 0, RAND()*100)
Example2:
Adds new record into the table "data". Next possible variant where a column list is stated for which values are stated in the VALUES (value for the column flags is not stated that's why the default value of the column is used). The current time (with the precision of about 3ms) got by the function GETDATE() is inserted into the column time. The default value of the column 0 is put into the column flags. A random value in the range of 0-100 got by the function RAND() is inserted into the column value.
INSERT data (time, value) VALUES (GETDATE(), RAND()*100)