Work with different query types

You can use Query Builder to create different types of SQL queries, including SELECT, INSERT INTO, UPDATE, and DELETE.

Overview of query types

The table lists the supported query types.

Name Description
SELECT Creates a query that retrieves data from one or more tables.
INSERT RESULTS Creates an INSERT INTO statement that adds data from multiple tables into a single target table.
INSERT VALUES Creates an INSERT INTO statement that adds individual rows and values to a table.
UPDATE Creates a statement that updates one or more records in a table.
DELETE Creates a statement that deletes records from a table.

Note

You can use the INSERT VALUES statement to add a single row to a table.

Change the query type

The current query type appears in the upper-left corner of the diagram. The default query type is SELECT.

To change the query type, do one of the following:

  • Select Query > Change Type, then choose the query type from the list.
  • On the Query toolbar, select Change Type and choose the query type from the list.
  • In the upper-left corner of the diagram, right-click the query type and select Change Type, then choose the query type from the list.
  • Right-click the diagram and select Change Type, then choose the query type from the list.

Create an INSERT RESULTS statement

1. Change the query type to INSERT RESULTS.

2. In the Choose Target Table to Insert Data to dialog, select the target database, schema, and table or view to insert data into.

3. To save the changes, click OK.

Tip

If the list contains many tables, use the search box to quickly find a table or view. As you type, matching entries are highlighted in the Tables and Views column.

This tip applies to all query types.

INSERT RESULTS query

4. Specify the values and conditions in the corresponding tabs of Tabbed Editor. For more information, see:

  • Design conditions for the SELECT clause
  • Design conditions for JOIN clauses
  • Design conditions for WHERE clauses
  • Design conditions for GROUP BY clauses
  • Design conditions for HAVING clauses
  • Design conditions for ORDER BY clauses

5. Optional: To preview the query, click Text in the bottom panel of the Query Builder document.

Create an INSERT VALUES statement

1. Change the query type to INSERT VALUES.

2. In the Choose Target Table dialog, select the database, schema, and table or view to insert data into.

3. To save the changes, click OK.

INSERT INTO query

4. In Tabbed Editor, enter the values to the columns.

  • In the Name column, select the empty row and choose the target column from the list.
  • In the Value column, enter the value you want to insert.
  • In the Default column, select whether to apply the default value defined for the column.

Enter values in the target table

5. Optional: To preview the query, click Text in the bottom panel of the Query Builder document.

Create an UPDATE statement

1. Change the query type to UPDATE.

2. In the Choose Target Table dialog, select the database, schema, and table or view to update.

3. To save the changes, click OK.

UPDATE query

4. On the Update tab, define the column values:

  • In the Name column, select an empty row and choose the column to update.
  • In the Value column, enter the new value.
  • In the Default column, select whether to apply the default value defined for the column.

5. On the Where tab, add a filter condition to specify which records to update. For instructions, see Design conditions for WHERE clauses.

6. Optional: To preview the query, click Text in the bottom panel of the Query Builder document.

Create a DELETE statement

1. Change the query type to DELETE.

2. In the Choose Target Table dialog, select the database, schema, and table or view from which you want to delete records.

3. On the Where tab, define the condition that determines which rows to delete. For instructions, see Design conditions for WHERE clauses.

DELETE statement

4. Optional: To preview the query, click Text in the bottom panel of the Query Builder document.