## SQL As Understood By SQLite

# UPDATE

#### update-stmt:

#### qualified-table-name:

The UPDATE statement is used to change the value of columns in selected rows of a table. Each assignment in an UPDATE specifies a column name to the left of the equals sign and an arbitrary expression to the right. The expressions may use the values of other columns. All expressions are evaluated before any assignments are made. A WHERE clause can be used to restrict which rows are updated.

The optional conflict-clause allows the specification of an alternative constraint conflict resolution algorithm to use during this one command. See the section titled ON CONFLICT for additional information.

### Restrictions on UPDATE Statements Within CREATE TRIGGER

There are additional syntax restrictions on UPDATE statements that occur within the body of a CREATE TRIGGER statement. The table-name must be unqualified. In other words, the database-name. prefix on the table name is not allowed within triggers. The table to be modified must be in the same database as the table to which the trigger is attached.

The INDEXED BY and NOT INDEXED clauses are not allowed on UPDATE statements within triggers.

The LIMIT clause (described below) is unsupported within triggers.

### Optional LIMIT and ORDER BY Clauses

If SQLite is built with the SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile-time option then the syntax of the UPDATE statement is extended with optional ORDER BY and LIMIT clauses as follows:

#### update-stmt-limited:

The optional LIMIT clause can be used to limit the number of rows modifed, and thereby limit the size of the transaction. The ORDER BY clause is used only to determine which rows fall within the LIMIT. The order in which rows are modified is arbitrary and is not determined by the ORDER BY clause.