Adding table references to SQL statements in the SQL builder

In the SQL builder, you can add one or more table references to an SQL statement, depending on the type of statement that you are creating.

Table references are objects such as tables and views that you can include in an SQL statement. You can add table references at any time while you are working on the statement.

You can create an SQL statement with multiple table references by using SELECT, FULLSELECT, and WITH statements. INSERT, UPDATE, and DELETE statements operate on a single table reference.

You can add table references directly in the Tables pane, or by dragging them to the Tables pane. You can drag a table reference from a database in a database connection in the Database Explorer view. You can also drag a table reference from a physical data model in a data project in the Data Project Explorer view.

Prerequisites:
  • The SQL statement must be open in the SQL builder.
  • If you are dragging a table reference from a database, its database connection must be active.
  • If you are dragging a table reference from a physical data model, the model must exist in a data design project.

To add a table reference to an SQL statement in the SQL builder:

  1. Add the table reference directly in the Tables pane or drag it to the Tables pane:
    To add a table reference directly in the Tables pane
    1. Right-click in the Tables pane of the SQL builder, and then click Add Table on the pop-up menu.
    2. In the Table name list, expand a schema, and then click the table reference to add.
    3. If a table reference with the same name already exists in the statement, specify an alias.
    4. Click OK.
    To drag a table reference from a database
    1. In the Database Explorer view, expand the database connection.
    2. Expand the database, expand the Schemas folder, and then expand a schema.
    3. Expand the folder in the schema that contains the table reference to add, and then drag the table reference to the Tables pane.
    To drag a table reference from a physical data model
    1. In the Data Project Explorer view, expand a data design project that contains the physical data model, and then expand the Data Models folder.
    2. Double-click the physical data model (.dbm) file to open it.
    3. In the Data Project Explorer view, expand a schema that is in the physical data model.
    4. Drag the table reference that is in the schema to the Tables pane.
  2. Optional: If you dragged a table reference, specify an alias.
    1. In the Tables pane, right-click the table reference, and then click Update Alias on the pop-up menu.
    2. In the Change Table Alias window, type an alias and then click OK.

The table reference is added to the Tables pane and is reflected in the SQL Source pane.

If you rearrange the table graphics in the Tables pane and then save the SQL statement, the arrangement of the table graphics reverts to the linear format, and the order of the table graphics reverts to their order in the SQL statement.

Related tasks
Removing table references from SQL statements in the SQL builder
Updating aliases for table references in SQL statements in the SQL builder
Related reference
Add Table window

Feedback