Specifying INSERT statements in the SQL Query Builder

Using an INSERT statement, you can insert rows from a values set or from a subquery results table into a database table.

Before you begin

There might be variations in syntax depending on the database vendor that you are using. If you use the SQL Query Builder to create the INSERT statement, the tool attempts to create the correct syntax.

If you insert a row from a set of values, the default value that is shown for each column depends on how the column was defined when the table was created.
  • The cell value is a pair of single quotation marks. Fill in the value.

Before you specify an INSERT statement, create the statement in the SQL Query Builder.

Procedure

To specify an INSERT statement in the SQL Query Builder:

  1. Add the table into which you want to insert data.
  2. In the Tables pane, select the check boxes of the columns into which to insert data.
  3. Insert a row from a set of values:
    1. In the Design pane, click Values. The columns that you selected in step 2 are listed in the grid.
    2. Double-click the Value cell beside each column that you want to insert data into and type the value or expression to insert. You can also use the Expression Builder wizard to create a more complex expression. You must enter values for non-nullable columns, otherwise an error occurs at run time.
  4. Optional: Run the statement. A message in the SQL Results view indicates whether the statement ran successfully.




© Copyright IBM Corporation 2010, 2017.