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 upon 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 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.
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:
- Add the table that you
want to insert data in.
- In the Tables pane, select the check boxes of the columns
into which to insert data.
- Insert a row from a set of values or a subquery.
|
|
To insert a row from a set of values |
- In the Design pane, click Values. The columns
that you selected in step 2 are listed in the grid.
- 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 |
- In the Design pane, click Subquery.
- 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.
- 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 Query Builder. To return to the INSERT statement in the
SQL Query Builder, click the INSERT statement in the Outline view.
|
- Optional: Run the statement. A message in the SQL Results view indicates whether the statement
ran successfully.