# Creating an UPDATE Statement

Use SQL Query Builder to create an UPDATE statement to update data in a table. You can explicitly set the values or derive them from the results of a build expression.

Prerequisites

Connect to the data source through a connection profile.

By specifying one or more conditions, you can indicate which rows in the database table to update. If you do not specify any conditions, all rows of the target table are updated.

1. Open a new or an existing SQL file, and be sure to select the connection profile Type, Name, and Database.
2. In an appropriate place in the editor window, right-click and select Edit in SQL Query Builder.
3. In the Outline pane, right-click SELECT Statement and select Change Statement Type.
4. Select UPDATE and click OK.
5. Select the table by right-clicking in the Tables pane and selecting Add Table.
6. Specify the columns to use in the statement.

   Option | Description
   --- | ---
   Specify all columns | Right-click the table in the Tables pane, and select Select All Columns.

   Specify specific columns

   Use either method:
   - In the Tables pane, select the check box next to the column name.
   - In the Columns tab, select the specific column from the drop-down menu.

7. In the Set tab, indicate the columns to update and the update value.
   1. Select an individual column by clicking a column and then Add individual column to statement to select it for update, or select multiple columns by highlighting two or more columns and clicking Add columns to statement as a group.
   2. In the Expression box, enter an expression or value.

      Enter a value directly in the box or select Specify Value to enter one. Select Edit Expression or Replace Expression to build an expression using Expression Builder. Leave as DEFAULT if you do not wish to change the value during update.

8. (Optional) In the Where tab, indicate a condition that targets specific rows for update.
   1. Select a Column.

      Alternately, select define a condition using the Expression Builder wizard.

   2. Select an Operator.
   3. Enter a specific Value, select a column from the drop-down list, or build an expression.
   4. (Optional) Select AND or OR to specify another condition.
9. (Optional) To run the SQL code, in the SQL Source pane, right-click and select Run SQL.

   View the results in the SQL Results tab.

10. Click OK to exit SQL Query Builder and to return to the SQL File Editor, where the SQL code displays in the editor window.

    Clicking Cancel results in no changes to the SQL code in the SQL File Editor. You lose any changes you made in SQL Query Builder.

Parent topic: SQL Query Builder
Related concepts
SQL Query Builder
Related tasks
Creating a SELECT Statement
Creating an INSERT Statement From a Values Set
Creating an INSERT Statement From a Subquery
Creating a DELETE Statement
Building Expressions
Editing a SQL Statement
Running the SQL Statement Code
Related reference
SQL Query Builder Preferences