Creating SQL statements in the SQL builder by using a database connection

You can use a database connection in the Database Explorer view to create an SQL statement in the SQL builder.

The SQL builder supports creating SELECT, INSERT, UPDATE, DELETE, FULLSELECT, and WITH (DB2® only) statements. A statement that you create is stored in a file with the extension .sql.

Prerequisites: Before you create an SQL statement by using a database connection:
  • Define a database connection in the Database Explorer view.
  • If you plan to save the SQL statement, create the project in which to store the statement.
Restriction:
  • If you want to reopen the SQL statement in the SQL builder or the SQL editor, save the statement in a data project.
  • If you save the SQL statement in a data development project, the project must be associated with a database that contains the database tables that you use in the statement. Otherwise, you cannot run the statement successfully.

To create an SQL statement in the SQL builder by using a database connection:

  1. Open the Data perspective.
  2. In the Database Explorer view, expand the database connection.
  3. Right-click the database connection or the database, and then click New SQL or XQuery Script on the pop-up menu.
  4. In the New SQL or XQuery Script window, type a name for the statement.
  5. Click SQL builder.
  6. Select the type of statement that you want to create.
  7. Click OK. The SQL statement opens in the SQL builder.
  8. Use the SQL builder to specify the type of statement that you selected in the New SQL or XQuery Script window:
  9. In the Save As window, select the project in which to save the SQL statement, and then click OK. If you select a data project, the SQL statement is added to the SQL Scripts folder of the selected project.
Related tasks
Connecting to a database by using a wizard
Creating a data development project
Related reference
New SQL or XQuery Script window

Feedback