Specifying INSERT statements in the SQL builder

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

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

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.
  • If the column was defined with a default value, the cell value is DEFAULT.
  • If the column was not defined with a default value and the column is nullable, the cell value is NULL.
  • If the column was not defined with a default value and the column is non-nullable, the cell value is a pair of single quotes.

Prerequisite: Before you specify an INSERT statement, create the statement in the SQL builder.

To specify an INSERT statement in the SQL builder:

  1. Add the table that you want to insert data in.
  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 or a subquery.
    To 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.
    To insert a row from a subquery
    1. In the Design pane, click Subquery.
    2. In the Query name list, click the query to use or choose to create a new one by clicking one of the Add selections in the list.
    3. If you created a new subquery, expand the statement in the Outline view, click the subquery and then build the SELECT, FULLSELECT, or WITH statement in the SQL builder. To return to the INSERT statement in the SQL builder, click the INSERT statement in the Outline view.
  4. Optional: Run the statement. A message in the Data Output view indicates whether the statement ran successfully.
Related reference
SQL builder for INSERT statements

Feedback