Update Statement
The update_statement node represents a SQL UPDATE statement, used to modify existing records in a table.
Structure
| <xs:element name="update_statement">
<xs:complexType>
<xs:sequence>
<xs:element name="cte_list" type="cte_list_type" minOccurs="0"/>
<xs:element name="target_table" type="table_reference_type"/>
<xs:element name="set_clause" type="expression_type" maxOccurs="unbounded"/>
<xs:element ref="from_clause" minOccurs="0"/>
<xs:element ref="where_clause" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
|
Elements
| Element |
Type |
Description |
cte_list |
cte_list_type |
Represents a Common Table Expression (CTE). Optional. |
target_table |
table_reference_type |
The table to update. Required. |
set_clause |
expression_type |
One or more assignment expressions that specify which columns to modify and their new values. Required. |
from_clause |
from_clause |
Specifies additional tables for lookup or filtering. Optional. |
where_clause |
where_clause |
The condition that determines which rows to update. Optional. If omitted, all rows are updated. |
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 | <statement type="update_statement">
<target_table type="named_table_reference">
<named_table_reference>
<table_name>
<full_name>employees</full_name>
<object_name>employees</object_name>
</table_name>
</named_table_reference>
</target_table>
<set_clause>
<expression expr_type="assignment_expr">
<assignment_expr>
<first_expr expr_type="column_referenced_expr">
<objectName>
<full_name>salary</full_name>
<object_name>salary</object_name>
</objectName>
</first_expr>
<second_expr expr_type="binary_expr">
<binary_expr operator="*">
<first_expr expr_type="column_referenced_expr">
<objectName>
<full_name>salary</full_name>
<object_name>salary</object_name>
</objectName>
</first_expr>
<second_expr expr_type="constant_expr">
<literal>
<value>1.1</value>
</literal>
</second_expr>
</binary_expr>
</second_expr>
</assignment_expr>
</expression>
</set_clause>
<where_clause>
<condition expr_type="comparison_expr">
<comparison_expr type="=">
<first_expr expr_type="column_referenced_expr">
<objectName>
<full_name>department</full_name>
<object_name>department</object_name>
</objectName>
</first_expr>
<second_expr expr_type="constant_expr">
<literal>
<value>'Sales'</value>
</literal>
</second_expr>
</comparison_expr>
</condition>
</where_clause>
</statement>
|