Previous Topic Next topic Print topic


Creating an INSERT Statement

Restriction: This topic applies to Windows environments only.

The easiest way to insert individual records is to run a query, and switch to ALLOW EDIT mode. However, if you want to perform a batch insert, you can use a query as the basis for an INSERT with SELECT statement.

To convert a SELECT statement to an INSERT statement :

  1. Create a query that retrieves the columns and rows from one table that you want to insert in another table. You may want to test the query to make certain it retrieves the correct rows. You should also save the query before proceeding if you want to access it again in the Query Design window.
  2. Switch to SQL view.
  3. In front of the SELECT keyword, enter the keywords INSERT INTO followed by the name of the table into which you want to insert rows.
  4. If the order of the columns in your SELECT clause does not match the order of the target columns in the table you are adding records to, you will have to create a comma-separated list of columns inside of parentheses. This list should be placed immediately after the name of the target table, and before the SELECT clause. You can drag the column names from the Catalog Browser so you don't have to type them.
  5. Run or save the SQL Statement from the SQL Edit window.
    Note: Insert Into is an XDB Server SQL extension. It is not available when running against non-XDB Server databases or when running in DB2 mode.
Previous Topic Next topic Print topic