Contents IndexChapter 10.  Updating the Database Modifying rows in a table

User's Guide
   Part II. Tutorials
     Chapter 10. Updating the Database
      Adding rows to a table

Suppose that a new eastern sales department is created, with the same manager as the current Sales department. You can add this information to the database using the following INSERT statement:

     INSERT
     INTO department ( dept_id, dept_name, dept_head_id )
     VALUES ( 220, 'Eastern Sales', 902 )

If you make a mistake and forget to specify one of the columns, SQL Anywhere reports an error.

The NULL value is a special value used to indicate that something is either not known or not applicable. Some columns are allowed to contain the NULL value, and others are not.

A short form for INSERT

There is a short form that can be used if you are entering values for all the columns in a table in the order they appear when you SELECT * from the table (the same as the order in which they were created). The following is equivalent to the previous INSERT command:

     INSERT
     INTO department
     VALUES ( 220, 'Eastern Sales', 902 )

Caution
You should use this form of INSERT with caution; it will not work as expected if you ever change the order of the columns in the table or if you add or remove a column from the table.

Contents IndexChapter 10.  Updating the Database Modifying rows in a table