Basic Queries  «Prev  Next»

Lesson 6 Using INSERT
Objective Insert new rows into a database table.

SQL Insert Statement

The UPDATE statement is used to change existing rows in a table. In this lesson, you will see how new rows are added.
The INSERT statement adds a new row into a specified table. To use the INSERT statement you generally specify the data fields and their corresponding values for the row to insert. However, if values for every field are being provided then it is not necessary to specify the data fields. In this case, the values are added to the fields from left to right, beginning with the first field. If values for only some fields are being provided then the data fields are specified, unless the values are to go into the first fields as they appear in the row.
The syntax for the INSERT statement is illustrated in the following SlideShow:

1) INSERT statement begins by specifying the table name to insert the row into 2) You can optionally supply a list of column names in parentheses that will be assigned values in the new row 3) The VALUES clause contains the column values to assign when the row is inserted 4) A list of values is provided in parentheses. 5) The complete insert statement. 6) CustTable table is specified 7) Then, you add the column names which will be assigned values 8) Finally, the values are added.
Using Insert Statement
In the next lesson, removing rows using the DELETE statement will be discussed.

SQL Insert Statement - Exercise

Click the Exercise link below to practice adding a row to the VirtualBookShelf.com BookTable. 
SQL Insert Exercise