List specific column names

You do not have to specify values for every column. Instead, you can list the column names after the table name and then supply values for only those columns that you named. The following example shows a statement that inserts a new row into the stock table:
INSERT INTO stock (stock_num,  description,  unit_price,  manu_code)
   VALUES (115,  'tyre pump ',  114,  'SHM');
Only the data for the stock number, description, unit price, and manufacturer code is provided. The database server supplies the following values for the remaining columns:
  • It generates a serial number for an unlisted serial column.
  • It generates a default value for a column with a specific default associated with it.
  • It generates a NULL value for any column that allows nulls but it does not specify a default value for any column that specifies NULL as the default value.

    You must list and supply values for all columns that do not specify a default value or do not permit NULL values.

You can list the columns in any order, as long as the values for those columns are listed in the same order. For information about how to designate null or default values for a column, see the HCL OneDB™ Database Design and Implementation Guide.

After the INSERT statement in the preceding example is executed, the following new row is inserted into the stock table:
stock_num manu_code  description  unit_price unit unit_descr

      115       SHM  tyre pump           114

Both unit and unit_descr are blank, which indicates that NULL values exist in those two columns. Because the unit column permits NULL values, the number of tire pumps that can be purchased for $114 is not known. Of course, if a default value of box were specified for this column, then box would be the unit of measure. In any case, when you insert values into specific columns of a table, pay attention to what data is needed for that row.