Inserting data into a table

Use the insert keyword to insert data into a table.

Example

The following example shows how to use the insert keyword:

insert into             database_name.table_name
( 
        column 
        [ , column ]
        [ , column ]
        [ ... ] 
)
values 
(
        data
        [ , data ]
        [ , data ]
        [ ... ]
);

Each data value is inserted into the corresponding column name, so the number of data values (and the data types) must correspond with the number of column names specified. Although it is not good practice, it is acceptable to omit the list of column names. If you choose to omit the column names, the first value specified after the values keyword is inserted into the first column of the database, the second value into the second column, and so on. Additionally, if you omit the column names, the number of values must correspond to the number of columns in the database, so you must either insert a value into each database column or explicitly specify NULL for columns into which you do not wish to insert a value.

The following topics provide further examples of the insert keyword.